Example usage for java.awt BorderLayout SOUTH

List of usage examples for java.awt BorderLayout SOUTH

Introduction

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

Prototype

String SOUTH

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

Click Source Link

Document

The south layout constraint (bottom of container).

Usage

From source file:ScreenDump.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Action Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final Action printAction = new PrintHelloAction();

    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menuBar.add(menu);// ww  w.  j  a va  2s.  c om
    JMenuItem menuItem = new JMenuItem("Print");
    KeyStroke ctrlP = KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK);
    menuItem.setAccelerator(ctrlP);
    menuItem.addActionListener(printAction);
    menu.add(menuItem);

    JButton fileButton = new JButton("About");
    fileButton.setMnemonic(KeyEvent.VK_A);
    fileButton.addActionListener(printAction);

    frame.setJMenuBar(menuBar);

    Container contentPane = frame.getContentPane();
    contentPane.add(fileButton, BorderLayout.SOUTH);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:ElementSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Element Example");
    Container content = frame.getContentPane();

    final JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);

    JButton button = new JButton("Show Elements");
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Document document = textArea.getDocument();
            ElementIterator iterator = new ElementIterator(document);
            Element element = iterator.first();
            while (element != null) {
                System.out.println(element.getStartOffset());
                element = iterator.next();
            }// ww  w .  jav  a  2s.c o  m
        }
    };
    button.addActionListener(actionListener);

    content.add(scrollPane, BorderLayout.CENTER);
    content.add(button, BorderLayout.SOUTH);

    frame.setSize(250, 250);
    frame.setVisible(true);
}

From source file:PasswordFieldSample.java

public static void main(String args[]) {
    String title = "Password Example";
    JFrame frame = new JFrame(title);
    Container content = frame.getContentPane();

    JPanel userPanel = new JPanel(new BorderLayout());
    JLabel userLabel = new JLabel("Username: ");
    userLabel.setDisplayedMnemonic(KeyEvent.VK_U);
    JTextField userTextField = new JTextField();
    userLabel.setLabelFor(userTextField);
    userPanel.add(userLabel, BorderLayout.WEST);
    userPanel.add(userTextField, BorderLayout.CENTER);

    JPanel passPanel = new JPanel(new BorderLayout());
    JLabel passLabel = new JLabel("Password: ");
    passLabel.setDisplayedMnemonic(KeyEvent.VK_P);
    JPasswordField passTextField = new JPasswordField();
    passLabel.setLabelFor(passTextField);
    passPanel.add(passLabel, BorderLayout.WEST);
    passPanel.add(passTextField, BorderLayout.CENTER);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(userPanel, BorderLayout.NORTH);
    panel.add(passPanel, BorderLayout.SOUTH);
    content.add(panel, BorderLayout.NORTH);

    frame.setSize(250, 150);/* w w w  .  j  a v a 2 s  .c  o  m*/
    frame.setVisible(true);
}

From source file:RolloverSpinnerListModel.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSpinner Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String[] values = new String[] { "a", "b", "c" };

    RolloverSpinnerListModel model = new RolloverSpinnerListModel(values);

    JSpinner spinner1 = new JSpinner(model);

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.SOUTH);

    frame.setSize(200, 90);/*from   www.  j  av a  2s .c  om*/
    frame.setVisible(true);
}

From source file:CheckMenuItem.java

public static void main(String[] args) {
    final JLabel statusbar = new JLabel(" Statusbar");

    JMenuBar menubar = new JMenuBar();
    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    JMenu view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);

    JCheckBoxMenuItem sbar = new JCheckBoxMenuItem("Show StatuBar");
    sbar.setState(true);/*from  www.j  av  a  2s.com*/

    sbar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            if (statusbar.isVisible()) {
                statusbar.setVisible(false);
            } else {
                statusbar.setVisible(true);
            }
        }
    });

    view.add(sbar);

    menubar.add(file);
    menubar.add(view);

    JFrame f = new JFrame();
    f.setJMenuBar(menubar);
    statusbar.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    f.add(statusbar, BorderLayout.SOUTH);
    f.setSize(360, 250);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    SynthLookAndFeel synth = new SynthLookAndFeel();
    try {//from  www.j  av a2  s  .c om
        Class aClass = MainClass.class;
        InputStream is = aClass.getResourceAsStream("config.xml");
        if (is == null) {
            System.err.println("Unable to find theme configuration");
            System.exit(-1);
        }
        synth.load(is, aClass);
    } catch (ParseException e) {
        System.err.println("Unable to load theme configuration");
        System.exit(-2);
    }
    try {
        UIManager.setLookAndFeel(synth);
    } catch (javax.swing.UnsupportedLookAndFeelException e) {
        System.err.println("Unable to change look and feel");
        System.exit(-3);
    }
    JFrame frame = new JFrame("Synth Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Hello, Synth");
    frame.add(button, BorderLayout.CENTER);
    JTextField textField = new JTextField();
    frame.add(textField, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:SharedDataSample.java

public static void main(String args[]) {
    final String labels[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" };
    final DefaultComboBoxModel model = new DefaultComboBoxModel(labels);

    JFrame frame = new JFrame("Shared Data");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();

    JPanel panel = new JPanel();
    JComboBox comboBox1 = new JComboBox(model);
    comboBox1.setMaximumRowCount(5);/*from  w w  w  . j  a v a2 s  . co  m*/
    comboBox1.setEditable(true);

    JComboBox comboBox2 = new JComboBox(model);
    comboBox2.setMaximumRowCount(5);
    comboBox2.setEditable(true);
    panel.add(comboBox1);
    panel.add(comboBox2);
    contentPane.add(panel, BorderLayout.NORTH);

    JList jlist = new JList(model);
    JScrollPane scrollPane = new JScrollPane(jlist);
    contentPane.add(scrollPane, BorderLayout.CENTER);

    JButton button = new JButton("Add");
    contentPane.add(button, BorderLayout.SOUTH);
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            int index = (int) (Math.random() * labels.length);
            model.addElement(labels[index]);
        }
    };
    button.addActionListener(actionListener);

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Examples.java

public static void main(String args[]) {

    JFrame frame = new JFrame("Example Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(0, 1));

    JFrame frame2 = new JFrame("Desktop");
    final JDesktopPane desktop = new JDesktopPane();
    frame2.getContentPane().add(desktop);
    JButton pick = new JButton("Pick");
    pick.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("Hi");
        }//from   w  ww .j  ava 2s  .c  o  m
    });
    frame2.getContentPane().add(pick, BorderLayout.SOUTH);

    JButton messagePopup = new JButton("Message");
    contentPane.add(messagePopup);
    messagePopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();
            JOptionPane.showMessageDialog(source, "Printing complete");
            JOptionPane.showInternalMessageDialog(desktop, "Printing complete");
        }
    });

    JButton confirmPopup = new JButton("Confirm");
    contentPane.add(confirmPopup);
    confirmPopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();
            JOptionPane.showConfirmDialog(source, "Continue printing?");
            JOptionPane.showInternalConfirmDialog(desktop, "Continue printing?");
        }
    });

    JButton inputPopup = new JButton("Input");
    contentPane.add(inputPopup);
    inputPopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();
            JOptionPane.showInputDialog(source, "Enter printer name:");
            // Moons of Neptune
            String smallList[] = { "Naiad", "Thalassa", "Despina", "Galatea", "Larissa", "Proteus", "Triton",
                    "Nereid" };
            JOptionPane.showInternalInputDialog(desktop, "Pick a printer", "Input",
                    JOptionPane.QUESTION_MESSAGE, null, smallList, "Triton");
            // Moons of Saturn - includes two provisional designations to
            // make 20
            String bigList[] = { "Pan", "Atlas", "Prometheus", "Pandora", "Epimetheus", "Janus", "Mimas",
                    "Enceladus", "Tethys", "Telesto", "Calypso", "Dione", "Helene", "Rhea", "Titan", "Hyperion",
                    "Iapetus", "Phoebe", "S/1995 S 2", "S/1981 S 18" };
            //        Object saturnMoon = JOptionPane.showInputDialog(source, "Pick
            // a printer", "Input", JOptionPane.QUESTION_MESSAGE, null,
            // bigList, "Titan");
            Object saturnMoon = JOptionPane.showInputDialog(source, "Pick a printer", "Input",
                    JOptionPane.QUESTION_MESSAGE, null, bigList, null);
            System.out.println("Saturn Moon: " + saturnMoon);
        }
    });

    JButton optionPopup = new JButton("Option");
    contentPane.add(optionPopup);
    optionPopup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component) actionEvent.getSource();

            Icon greenIcon = new DiamondIcon(Color.green);
            Icon redIcon = new DiamondIcon(Color.red);
            Object iconArray[] = { greenIcon, redIcon };
            JOptionPane.showOptionDialog(source, "Continue printing?", "Select an Option",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]);

            Icon blueIcon = new DiamondIcon(Color.blue);
            Object stringArray[] = { "Do It", "No Way" };
            JOptionPane.showInternalOptionDialog(desktop, "Continue printing?", "Select an Option",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray,
                    stringArray[0]);
        }
    });

    frame.setSize(300, 200);
    frame.setVisible(true);
    frame2.setSize(300, 200);
    frame2.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTextField[] txtAllAverages;/*w  ww  . j  ava 2 s . co  m*/
    int testCount = 2;

    txtAllAverages = new JTextField[testCount];

    JPanel inputControls = new JPanel(new BorderLayout(5, 5));

    JPanel inputControlsLabels = new JPanel(new GridLayout(0, 1, 3, 3));
    JPanel inputControlsFields = new JPanel(new GridLayout(0, 1, 3, 3));
    inputControls.add(inputControlsLabels, BorderLayout.WEST);
    inputControls.add(inputControlsFields, BorderLayout.CENTER);
    for (int i = 0; i < testCount; i++) {
        inputControlsLabels.add(new JLabel("Test score: "));
        JTextField field = new JTextField(10);
        inputControlsFields.add(field);
        txtAllAverages[i] = field;
    }

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 2));

    controls.add(new JButton("Reset"));
    controls.add(new JButton("Submit"));

    JPanel gui = new JPanel(new BorderLayout(10, 10));
    gui.setBorder(new TitledBorder("Averages"));
    gui.add(inputControls, BorderLayout.CENTER);
    gui.add(controls, BorderLayout.SOUTH);

    JFrame f = new JFrame();
    f.setContentPane(gui);

    f.pack();
    f.setLocationByPlatform(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:FilterSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JFileChooser Filter Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container contentPane = frame.getContentPane();

    final JLabel directoryLabel = new JLabel();
    contentPane.add(directoryLabel, BorderLayout.NORTH);

    final JLabel filenameLabel = new JLabel();
    contentPane.add(filenameLabel, BorderLayout.SOUTH);

    final JButton button = new JButton("Open FileChooser");
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Component parent = (Component) actionEvent.getSource();
            JFileChooser fileChooser = new JFileChooser(".");
            fileChooser.setAccessory(new LabelAccessory(fileChooser));
            FileFilter filter1 = new ExtensionFileFilter(null, new String[] { "JPG", "JPEG" });
            //        fileChooser.setFileFilter(filter1);
            fileChooser.addChoosableFileFilter(filter1);
            FileFilter filter2 = new ExtensionFileFilter("gif", new String[] { "gif" });
            fileChooser.addChoosableFileFilter(filter2);
            fileChooser.setFileView(new JavaFileView());
            int status = fileChooser.showOpenDialog(parent);
            if (status == JFileChooser.APPROVE_OPTION) {
                File selectedFile = fileChooser.getSelectedFile();
                directoryLabel.setText(selectedFile.getParent());
                filenameLabel.setText(selectedFile.getName());
            } else if (status == JFileChooser.CANCEL_OPTION) {
                directoryLabel.setText(" ");
                filenameLabel.setText(" ");
            }//from w ww  .ja v  a2  s . c o m
        }
    };
    button.addActionListener(actionListener);
    contentPane.add(button, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
}