Example usage for java.awt BorderLayout NORTH

List of usage examples for java.awt BorderLayout NORTH

Introduction

In this page you can find the example usage for java.awt BorderLayout NORTH.

Prototype

String NORTH

To view the source code for java.awt BorderLayout NORTH.

Click Source Link

Document

The north layout constraint (top of container).

Usage

From source file:ShowAddListeners.java

public void init() {
    NameL nameListener = new NameL();
    name.addActionListener(nameListener);
    JPanel top = new JPanel();
    top.add(new JLabel("Swing class name (press ENTER):"));
    top.add(name);//from w  w  w  .jav a  2s . com
    Container cp = getContentPane();
    cp.add(BorderLayout.NORTH, top);
    cp.add(new JScrollPane(results));
    // Initial data and test:
    name.setText("JTextArea");
    nameListener.actionPerformed(new ActionEvent("", 0, ""));
}

From source file:TableSortDemo.java

public TableSortDemo() {
    super();//from  w  w w. j  av  a  2 s.  c  o m
    setSize(600, 300);

    tableModel = new MyTableModel();

    getContentPane().add(titleLabel, BorderLayout.NORTH);
    table.setModel(tableModel);

    JTableHeader header = table.getTableHeader();
    header.setUpdateTableInRealTime(true);
    header.addMouseListener(tableModel.new ColumnListener(table));
    header.setReorderingAllowed(true);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(table);
    getContentPane().add(ps, BorderLayout.CENTER);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:customprogressindicatordemo.WeatherData.java

public WeatherData() {
    setBackground(Color.WHITE);/*from  w  w  w  .  j  a v  a  2s.c  om*/
    setLayout(new BorderLayout());
    JLabel lbl = new JLabel("World-Wide Weather Data");
    add(lbl, BorderLayout.NORTH);

    String[] columnNames = { "City", "Temperature" };
    JTable table = new JTable(getData(), columnNames);

    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBackground(Color.WHITE);

    //Add the scroll pane to this panel.
    add(scrollPane, BorderLayout.SOUTH);
}

From source file:TArea.java

public void init() {
    Container container = getContentPane();

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 2));

    resetButton = new JRadioButton("Reset", true);

    addButton = new JRadioButton("Add");
    subtractButton = new JRadioButton("Subtract");
    intersectButton = new JRadioButton("Intersect");
    exclusiveORButton = new JRadioButton("ExclusiveOR");

    ButtonGroup group = new ButtonGroup();
    group.add(resetButton);/*from   w w  w .java 2s  .  c o m*/
    group.add(addButton);
    group.add(subtractButton);
    group.add(intersectButton);
    group.add(exclusiveORButton);
    group.add(resetButton);

    resetButton.addActionListener(this);
    addButton.addActionListener(this);
    subtractButton.addActionListener(this);
    intersectButton.addActionListener(this);
    exclusiveORButton.addActionListener(this);

    panel.add(addButton);
    panel.add(subtractButton);
    panel.add(intersectButton);
    panel.add(exclusiveORButton);

    container.add(panel, BorderLayout.NORTH);
    container.add(resetButton, BorderLayout.SOUTH);

    canvas = new DrawingCanvas();
    container.add(canvas);
}

From source file:InterruptibleSocketTest.java

public InterruptibleSocketFrame() {
    setSize(WIDTH, HEIGHT);/*  w ww . j a v a2 s .  co m*/
    setTitle("InterruptibleSocketTest");

    JPanel northPanel = new JPanel();
    add(northPanel, BorderLayout.NORTH);

    messages = new JTextArea();
    add(new JScrollPane(messages));

    interruptibleButton = new JButton("Interruptible");
    blockingButton = new JButton("Blocking");

    northPanel.add(interruptibleButton);
    northPanel.add(blockingButton);

    interruptibleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            interruptibleButton.setEnabled(false);
            blockingButton.setEnabled(false);
            cancelButton.setEnabled(true);
            connectThread = new Thread(new Runnable() {
                public void run() {
                    try {
                        connectInterruptibly();
                    } catch (IOException e) {
                        messages.append("\nInterruptibleSocketTest.connectInterruptibly: " + e);
                    }
                }
            });
            connectThread.start();
        }
    });

    blockingButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            interruptibleButton.setEnabled(false);
            blockingButton.setEnabled(false);
            cancelButton.setEnabled(true);
            connectThread = new Thread(new Runnable() {
                public void run() {
                    try {
                        connectBlocking();
                    } catch (IOException e) {
                        messages.append("\nInterruptibleSocketTest.connectBlocking: " + e);
                    }
                }
            });
            connectThread.start();
        }
    });

    cancelButton = new JButton("Cancel");
    cancelButton.setEnabled(false);
    northPanel.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            connectThread.interrupt();
            cancelButton.setEnabled(false);
        }
    });
    server = new TestServer();
    new Thread(server).start();
}

From source file:com.emental.mindraider.ui.dialogs.FtsJDialog.java

public FtsJDialog() {
    super(Messages.getString("FtsJDialog.title"));

    JPanel dialogPanel = new JPanel();
    dialogPanel.setBorder(new EmptyBorder(5, 10, 0, 10));
    dialogPanel.setLayout(new BorderLayout());

    JPanel contentAndButtons = new JPanel(new GridLayout(2, 1));
    JPanel contentPanel = new JPanel(new BorderLayout());

    // 1a.//from   w  ww. j a va 2  s.c  om
    // TODO add help like in eclipse
    contentPanel.add(new JLabel(Messages.getString("FtsJDialog.searchString")), BorderLayout.NORTH);
    // 1b.
    String[] knownSearches = new String[] { "", "RDF", "mind", "concept", "China" };
    ftsCombo = new JComboBox(knownSearches);
    ftsCombo.setPreferredSize(new Dimension(200, 18));
    ftsCombo.setEditable(true);
    ftsCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if ("comboBoxEdited".equals(e.getActionCommand())) {
                search();
            }
        }
    });
    contentPanel.add(ftsCombo, BorderLayout.SOUTH);
    contentAndButtons.add(contentPanel);

    // 2.
    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5));
    JButton searchButton = new JButton(Messages.getString("FtsJDialog.searchButton"));
    searchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            search();
        }
    });
    p.add(searchButton);

    JButton cancelButton = new JButton(Messages.getString("FtsJDialog.cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    p.add(cancelButton);

    contentAndButtons.add(p);

    dialogPanel.add(contentAndButtons, BorderLayout.CENTER);

    getContentPane().add(dialogPanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:ArcApp.java

public ArcApp() {
    super(new BorderLayout());
    canvas = new MyCanvas();
    int width = 600;
    int height = 55;
    sliderX = setSlider(0, width, width / 4, width / 2, width / 4);
    sliderY = setSlider(0, height, height / 4, height / 2, height / 4);
    sliderWidth = setSlider(0, width, width / 2, width / 2, width / 4);
    sliderHeight = setSlider(0, height, height / 2, height / 2, height / 4);
    sliderT0 = setSlider(0, 360, 45, 180, 45);
    sliderT = setSlider(0, 360, 135, 180, 45);

    JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayout(3, 3));
    panel1.add(new JLabel("Location (x,y): ", JLabel.RIGHT));
    panel1.add(sliderX);/*from w w  w  .jav  a 2  s .  co  m*/
    panel1.add(sliderY);
    panel1.add(new JLabel("Size (w,h): ", JLabel.RIGHT));
    panel1.add(sliderWidth);
    panel1.add(sliderHeight);
    panel1.add(new JLabel("Angles (Th0, Th): ", JLabel.RIGHT));
    panel1.add(sliderT0);
    panel1.add(sliderT);

    add(panel1, BorderLayout.NORTH);

    arcBox = new JComboBox(arcLabels);
    arcBox.setSelectedIndex(0);
    arcBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    arcBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            canvas.arcType = arcTypes[cb.getSelectedIndex()];
            canvas.repaint();
        }
    });

    fillBox = new JComboBox(colorLabels);
    fillBox.setSelectedIndex(0);
    fillBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    fillBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            canvas.fillColor = colors[cb.getSelectedIndex()];
            canvas.repaint();
        }
    });

    JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayout(1, 4));
    panel2.add(new JLabel("Arc Type: ", JLabel.RIGHT));
    panel2.add(arcBox);
    panel2.add(new JLabel("Fill Type: ", JLabel.RIGHT));
    panel2.add(fillBox);

    add(panel2, BorderLayout.SOUTH);
    add(canvas, BorderLayout.CENTER);
}

From source file:ModelJTable.java

public ModelJTable() {
    super();/*w w w .  ja  va2 s.  c  o m*/
    model = new DefaultTableModel();
    model.addColumn("First Name");
    model.addColumn("Last Name");
    model.addColumn("Years");

    String[] socrates = { "Socrates", "", "469-399 B.C." };
    model.addRow(socrates);

    String[] plato = { "Plato", "", "428-347 B.C." };
    model.addRow(plato);

    String[] aquinas = { "Thomas", "Aquinas", "1225-1274" };
    model.addRow(aquinas);

    String[] kierkegaard = { "Soren", "Kierkegaard", "1813-1855" };
    model.addRow(kierkegaard);

    String[] kant = { "Immanuel", "Kant", "1724-1804" };
    model.addRow(kant);

    String[] nietzsche = { "Friedrich", "Nietzsche", "1844-1900" };
    model.addRow(nietzsche);

    String[] arendt = { "Hannah", "Arendt", "1906-1975" };
    model.addRow(arendt);

    table = new JTable(model);

    JButton addButton = new JButton("Add Philosopher");
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            String[] philosopher = { "", "", "" };
            model.addRow(philosopher);
        }
    });

    JButton removeButton = new JButton("Remove Selected Philosopher");

    removeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            model.removeRow(table.getSelectedRow());
        }
    });
    JPanel inputPanel = new JPanel();
    inputPanel.add(addButton);
    inputPanel.add(removeButton);

    Container container = getContentPane();
    container.add(new JScrollPane(table), BorderLayout.CENTER);
    container.add(inputPanel, BorderLayout.NORTH);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(400, 300);
    setVisible(true);
}

From source file:MainClass.java

public MainClass() {
    JFrame frame = new JFrame();
    JTextPane textPane = new JTextPane();
    JScrollPane scrollPane = new JScrollPane(textPane);

    JPanel north = new JPanel();

    JMenuBar menu = new JMenuBar();
    JMenu styleMenu = new JMenu();
    styleMenu.setText("Style");

    Action boldAction = new BoldAction();
    boldAction.putValue(Action.NAME, "Bold");
    styleMenu.add(boldAction);//from   ww  w  .  jav a 2 s.co  m

    Action italicAction = new ItalicAction();
    italicAction.putValue(Action.NAME, "Italic");
    styleMenu.add(italicAction);

    Action foregroundAction = new ForegroundAction();
    foregroundAction.putValue(Action.NAME, "Color");
    styleMenu.add(foregroundAction);

    Action formatTextAction = new FontAndSizeAction();
    formatTextAction.putValue(Action.NAME, "Font and Size");
    styleMenu.add(formatTextAction);

    menu.add(styleMenu);

    north.add(menu);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(north, BorderLayout.NORTH);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setSize(800, 500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}