Example usage for java.awt BorderLayout PAGE_END

List of usage examples for java.awt BorderLayout PAGE_END

Introduction

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

Prototype

String PAGE_END

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

Click Source Link

Document

The component comes after the last line of the layout's content.

Usage

From source file:QandE.Beeper2.java

public Beeper2() {
    super(new BorderLayout());

    //Create and set up the spinner.
    String numBeepsString = "Number of Beeps: ";
    beepsModel = new SpinnerNumberModel(1, 1, 10, 1);
    JLabel numBeepsLabel = new JLabel(numBeepsString);
    add(numBeepsLabel, BorderLayout.PAGE_START);
    JSpinner spinner = new JSpinner(beepsModel);
    numBeepsLabel.setLabelFor(spinner);/*  w  ww.  j  ava 2  s  . c  o  m*/
    add(spinner, BorderLayout.CENTER);

    button = new JButton("Click Me");
    button.setPreferredSize(new Dimension(200, 80));
    add(button, BorderLayout.PAGE_END);
    button.setActionCommand(BUTTON_CMD);
    button.addActionListener(this);
}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    listModel.addElement("A");
    listModel.addElement("B");
    listModel.addElement("C");

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);/*w  w  w  .java  2  s.c  o  m*/
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton hireButton = new JButton(addCommand);
    HireListener hireListener = new HireListener(hireButton);
    hireButton.setActionCommand(addCommand);
    hireButton.addActionListener(hireListener);
    hireButton.setEnabled(false);

    fireButton = new JButton(deleteCommand);
    fireButton.setActionCommand(deleteCommand);
    fireButton.addActionListener(new FireListener());

    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(list.getSelectedIndex()).toString();
    System.out.println(name);

    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(employeeName);
    buttonPane.add(hireButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
}

From source file:components.ColorChooserDemo.java

public ColorChooserDemo() {
    super(new BorderLayout());

    //Set up the banner at the top of the window
    banner = new JLabel("Welcome to the Tutorial Zone!", JLabel.CENTER);
    banner.setForeground(Color.yellow);
    banner.setBackground(Color.blue);
    banner.setOpaque(true);/*from  ww  w . j  av  a2  s .  c  o m*/
    banner.setFont(new Font("SansSerif", Font.BOLD, 24));
    banner.setPreferredSize(new Dimension(100, 65));

    JPanel bannerPanel = new JPanel(new BorderLayout());
    bannerPanel.add(banner, BorderLayout.CENTER);
    bannerPanel.setBorder(BorderFactory.createTitledBorder("Banner"));

    //Set up color chooser for setting text color
    tcc = new JColorChooser(banner.getForeground());
    tcc.getSelectionModel().addChangeListener(this);
    tcc.setBorder(BorderFactory.createTitledBorder("Choose Text Color"));

    add(bannerPanel, BorderLayout.CENTER);
    add(tcc, BorderLayout.PAGE_END);
}

From source file:Main.java

public Main() {
    super(new BorderLayout());

    listModel = new DefaultListModel();
    listModel.addElement("Debbie Scott");
    listModel.addElement("Scott Hommel");
    listModel.addElement("Sharon Zakhour");

    // Create the list and put it in a scroll pane.
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);/*  w ww . java2 s .c  o  m*/
    list.addListSelectionListener(this);
    list.setVisibleRowCount(5);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton hireButton = new JButton(hireString);
    HireListener hireListener = new HireListener(hireButton);
    hireButton.setActionCommand(hireString);
    hireButton.addActionListener(hireListener);
    hireButton.setEnabled(false);

    fireButton = new JButton(fireString);
    fireButton.setActionCommand(fireString);
    fireButton.addActionListener(new FireListener());

    employeeName = new JTextField(10);
    employeeName.addActionListener(hireListener);
    employeeName.getDocument().addDocumentListener(hireListener);
    String name = listModel.getElementAt(list.getSelectedIndex()).toString();

    // Create a panel that uses BoxLayout.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.add(fireButton);
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(new JSeparator(SwingConstants.VERTICAL));
    buttonPane.add(Box.createHorizontalStrut(5));
    buttonPane.add(employeeName);
    buttonPane.add(hireButton);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    add(listScrollPane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.PAGE_END);
}

From source file:org.kepler.gui.PlotsEditorPanel.java

public PlotsEditorPanel(TableauFrame parent, String title) {
    super();/*from  ww  w.  j a v a  2 s.co m*/
    _title = title;
    _frame = parent;
    setBackground(TabManager.BGCOLOR);
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    plotsPanel = new JPanel();
    plotsPanel.setLayout(new BoxLayout(plotsPanel, BoxLayout.PAGE_AXIS));

    fixGraphics();

    JScrollPane scrollPane = new JScrollPane(plotsPanel);

    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    this.add(scrollPane, BorderLayout.CENTER);
    JButton addPlotButton = createAddPlotButton();
    this.add(addPlotButton, BorderLayout.PAGE_END);

    // This thread will try to wait until the PlotsPanel is available
    // before adding a plot to it. If a plot is added before the
    // applicable tab pane is available, an NPE will be triggered.
    // The thread will poll for tab pane setup completion every 100 ms,
    // up to a maximum of 10 seconds (100 iterations). If after 10 seconds
    // the tab pane is not available, something has probably gone wrong,
    // and further attempts would do no good.
    new Thread(new Runnable() {
        private void pause(long l) {
            try {
                Thread.sleep(l);
            } catch (InterruptedException ignored) {
            }
        }

        public void run() {
            int maxIterations = 100;
            for (int i = 0; i < maxIterations; i++) {
                log.debug("PlotsEditorPanel thread waiting " + "for TabPane to become available...");
                pause(100);
                if (canAddPlot()) {
                    log.debug("PlotsEditorPanel thread got TabPane, adding Plot.");
                    addPlot();
                    return;
                }
            }
        }
    }).start();
}

From source file:ComponentEventDemo.java

public ComponentEventDemo() {
    super(new BorderLayout());

    display = new JTextArea();
    display.setEditable(false);//from   www  . j a  va  2 s .c  o  m
    JScrollPane scrollPane = new JScrollPane(display);
    scrollPane.setPreferredSize(new Dimension(350, 200));

    JPanel panel = new JPanel(new BorderLayout());
    label = new JLabel("This is a label", JLabel.CENTER);
    label.addComponentListener(this);
    panel.add(label, BorderLayout.CENTER);

    JCheckBox checkbox = new JCheckBox("Label visible", true);
    checkbox.addItemListener(this);
    checkbox.addComponentListener(this);
    panel.add(checkbox, BorderLayout.PAGE_END);
    panel.addComponentListener(this);

    add(scrollPane, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
    frame.addComponentListener(this);
}

From source file:LabelDnD2.java

public LabelDnD2() {
    super(new BorderLayout());

    JColorChooser chooser = new JColorChooser();
    chooser.setDragEnabled(true);//from w  w w .j  a v a  2  s .c  om

    label = new JLabel("I'm a Label and I accept color!", SwingConstants.LEADING);
    label.setTransferHandler(new TransferHandler("foreground"));

    MouseListener listener = new DragMouseAdapter();
    label.addMouseListener(listener);
    JPanel lpanel = new JPanel(new GridLayout(1, 1));
    TitledBorder t2 = BorderFactory.createTitledBorder("JLabel: drop color onto the label");
    lpanel.add(label);
    lpanel.setBorder(t2);

    add(chooser, BorderLayout.CENTER);
    add(lpanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
}

From source file:misc.FocusTraversalDemo.java

public FocusTraversalDemo() {
    super(new BorderLayout());

    JTextField tf1 = new JTextField("Field 1");
    JTextField tf2 = new JTextField("A Bigger Field 2");
    JTextField tf3 = new JTextField("Field 3");
    JTextField tf4 = new JTextField("A Bigger Field 4");
    JTextField tf5 = new JTextField("Field 5");
    JTextField tf6 = new JTextField("A Bigger Field 6");
    JTable table = new JTable(4, 3);
    togglePolicy = new JCheckBox("Custom FocusTraversalPolicy");
    togglePolicy.setActionCommand("toggle");
    togglePolicy.addActionListener(this);
    togglePolicy.setFocusable(false); //Remove it from the focus cycle.
    //Note that HTML is allowed and will break this run of text
    //across two lines.
    label = new JLabel(
            "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>");

    JPanel leftTextPanel = new JPanel(new GridLayout(3, 2));
    leftTextPanel.add(tf1, BorderLayout.PAGE_START);
    leftTextPanel.add(tf3, BorderLayout.CENTER);
    leftTextPanel.add(tf5, BorderLayout.PAGE_END);
    leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel rightTextPanel = new JPanel(new GridLayout(3, 2));
    rightTextPanel.add(tf2, BorderLayout.PAGE_START);
    rightTextPanel.add(tf4, BorderLayout.CENTER);
    rightTextPanel.add(tf6, BorderLayout.PAGE_END);
    rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel tablePanel = new JPanel(new GridLayout(0, 1));
    tablePanel.add(table, BorderLayout.CENTER);
    tablePanel.setBorder(BorderFactory.createEtchedBorder());
    JPanel bottomPanel = new JPanel(new GridLayout(2, 1));
    bottomPanel.add(togglePolicy, BorderLayout.PAGE_START);
    bottomPanel.add(label, BorderLayout.PAGE_END);

    add(leftTextPanel, BorderLayout.LINE_START);
    add(rightTextPanel, BorderLayout.CENTER);
    add(tablePanel, BorderLayout.LINE_END);
    add(bottomPanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    Vector<Component> order = new Vector<Component>(7);
    order.add(tf1);/*from w  w w  .  j  av  a  2  s. co  m*/
    order.add(tf2);
    order.add(tf3);
    order.add(tf4);
    order.add(tf5);
    order.add(tf6);
    order.add(table);
    newPolicy = new MyOwnFocusTraversalPolicy(order);
}

From source file:ComboBoxDemo.java

public ComboBoxDemo() {
    super(new BorderLayout());

    String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };

    //Create the combo box, select the item at index 4.
    //Indices start at 0, so 4 specifies the pig.
    JComboBox petList = new JComboBox(petStrings);
    petList.setSelectedIndex(4);/*w ww.jav  a2s . co  m*/
    petList.addActionListener(this);

    //Set up the picture.
    picture = new JLabel();
    picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
    picture.setHorizontalAlignment(JLabel.CENTER);
    updateLabel(petStrings[petList.getSelectedIndex()]);
    picture.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //The preferred size is hard-coded to be the width of the
    //widest image and the height of the tallest image + the border.
    //A real program would compute this.
    picture.setPreferredSize(new Dimension(177, 122 + 10));

    //Lay out the demo.
    add(petList, BorderLayout.PAGE_START);
    add(picture, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:FocusConceptsDemo.java

public FocusConceptsDemo() {
    super(new BorderLayout());

    b1 = new JButton("JButton");
    b2 = new JButton("JButton");
    b3 = new JButton("JButton");
    b4 = new JButton("JButton");
    JPanel buttonPanel = new JPanel(new GridLayout(1, 1));
    buttonPanel.add(b1);/*  ww  w  .j a  va2 s.  com*/
    buttonPanel.add(b2);
    buttonPanel.add(b3);
    buttonPanel.add(b4);

    text1 = new JTextArea("JTextArea", 15, 40);
    JPanel textAreaPanel = new JPanel(new BorderLayout());
    textAreaPanel.add(text1, BorderLayout.CENTER);

    t1 = new JTextField("JTextField");
    t2 = new JTextField("JTextField");
    t3 = new JTextField("JTextField");
    t4 = new JTextField("JTextField");
    JPanel textFieldPanel = new JPanel(new GridLayout(1, 1));
    textFieldPanel.add(t1);
    textFieldPanel.add(t2);
    textFieldPanel.add(t3);
    textFieldPanel.add(t4);

    add(buttonPanel, BorderLayout.PAGE_START);
    add(textAreaPanel, BorderLayout.CENTER);
    add(textFieldPanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}