List of usage examples for java.awt BorderLayout SOUTH
String SOUTH
To view the source code for java.awt BorderLayout SOUTH.
Click Source Link
From source file:CommonLayouts.java
public CommonLayouts() { super("Common Layout Managers"); setSize(500, 380);//w w w .j av a 2 s .c o m JPanel desktop = new JPanel(); getContentPane().add(desktop); JPanel fr1 = new JPanel(); fr1.setBorder(new TitledBorder("FlowLayout")); fr1.setLayout(new FlowLayout()); fr1.add(new JButton("1")); fr1.add(new JButton("2")); fr1.add(new JButton("3")); fr1.add(new JButton("4")); desktop.add(fr1, 0); JPanel fr2 = new JPanel(); fr2.setBorder(new TitledBorder("GridLayout")); fr2.setLayout(new GridLayout(2, 2)); fr2.add(new JButton("1")); fr2.add(new JButton("2")); fr2.add(new JButton("3")); fr2.add(new JButton("4")); desktop.add(fr2, 0); JPanel fr3 = new JPanel(); fr3.setBorder(new TitledBorder("BorderLayout")); fr3.add(new JButton("1"), BorderLayout.NORTH); fr3.add(new JButton("2"), BorderLayout.EAST); fr3.add(new JButton("3"), BorderLayout.SOUTH); fr3.add(new JButton("4"), BorderLayout.WEST); desktop.add(fr3, 0); JPanel fr4 = new JPanel(); fr4.setBorder(new TitledBorder("BoxLayout - X")); fr4.setLayout(new BoxLayout(fr4, BoxLayout.X_AXIS)); fr4.add(new JButton("1")); fr4.add(Box.createHorizontalStrut(12)); fr4.add(new JButton("2")); fr4.add(Box.createGlue()); fr4.add(new JButton("3")); fr4.add(Box.createHorizontalGlue()); fr4.add(new JButton("4")); desktop.add(fr4, 0); JPanel fr5 = new JPanel(); fr5.setBorder(new TitledBorder("BoxLayout - Y")); fr5.setLayout(new BoxLayout(fr5, BoxLayout.Y_AXIS)); fr5.add(new JButton("1")); fr5.add(Box.createVerticalStrut(10)); fr5.add(new JButton("2")); fr5.add(Box.createGlue()); fr5.add(new JButton("3")); fr5.add(Box.createVerticalGlue()); fr5.add(new JButton("4")); desktop.add(fr5, 0); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:Main.java
public ProgressBarFrame() { setSize(300, 300);/*from w w w.j a va 2 s.c o m*/ JPanel panel = new JPanel(); progressBar.setStringPainted(true); panel.add(startButton); panel.add(progressBar); checkBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { progressBar.setIndeterminate(checkBox.isSelected()); progressBar.setStringPainted(!progressBar.isIndeterminate()); } }); panel.add(checkBox); add(new JScrollPane(textArea), BorderLayout.CENTER); add(panel, BorderLayout.SOUTH); startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { startButton.setEnabled(false); activity = new SimulatedActivity(MAX); activity.execute(); } }); }
From source file:ColorConvertDemo.java
public ColorConvertDemo() { super();//from w ww . j a v a2s . c o m Container container = getContentPane(); displayPanel = new ColorPanel(); container.add(displayPanel); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1, 2)); panel.setBorder(new TitledBorder("Click the Gray Scale Button to Create Gray Scale Image...")); grayButton = new JButton("Gray Scale"); grayButton.addActionListener(new ButtonListener()); resetButton = new JButton("Reset"); resetButton.addActionListener(new ButtonListener()); panel.add(grayButton); panel.add(resetButton); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowEventHandler()); setSize(displayPanel.getWidth(), displayPanel.getHeight() + 15); setVisible(true); }
From source file:Main.java
public Main() { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); iconLabel = new JLabel("Please select an image."); iconLabel.setHorizontalAlignment(SwingConstants.CENTER); fileChooser = new JFileChooser(); frame.add(iconLabel, BorderLayout.CENTER); frame.add(new JButton(new SelectImageAction("Select Image...")), BorderLayout.SOUTH); frame.setBounds(16, 16, 640, 480);/*from w w w . j ava2s . com*/ frame.setVisible(true); }
From source file:Main.java
public Main() { textField.setText("Hit Enter to Add Text to Text Pane"); getContentPane().add(textField, BorderLayout.NORTH); textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Document doc = textPane.getDocument(); doc.insertString(doc.getLength(), " " + textField.getText(), null); textField.setText("");//clear Dimension d = textPane.getPreferredSize(); Rectangle r = textPane.modelToView(textPane.getDocument().getLength()); d.height = r.y + r.height; textPane.setPreferredSize(d); getContentPane().validate(); } catch (Exception e2) { }/*from w w w . jav a 2 s. com*/ } }); JPanel south = new JPanel(); textPane = new JTextPane(); textPane.setText("Some \ntext"); textPane.setEditable(false); textPane.setPreferredSize(new Dimension(120, 23)); south.add(textPane); getContentPane().add(south, BorderLayout.SOUTH); }
From source file:Main.java
Main(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); source.setForeground(Color.red); getContentPane().add(source, BorderLayout.NORTH); target.addActionListener(this); getContentPane().add(target, BorderLayout.SOUTH); new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this); setSize(205, 100);/*from ww w. j av a 2 s .com*/ setVisible(true); }
From source file:Main.java
public Main(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); source.setForeground(Color.red); getContentPane().add(source, BorderLayout.NORTH); target.addActionListener(this); getContentPane().add(target, BorderLayout.SOUTH); new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this); setSize(205, 100);//from ww w. j a v a 2s.com setVisible(true); }
From source file:FactoryDemo.java
public static JPanel demo2() { // Demo 2: Change the format of a field when the user presses a button. // We can't call field.setFormatter() because that's a protected method. // (Plus it wouldn't work anyway. The old factory would replace our new // formatter with an "old" one next time the field gains or loses // focus.)/* www . ja v a2 s. c o m*/ // The thing to do is send a new factory to field.setFormatterFactory(). JPanel pan = new JPanel(new BorderLayout()); pan.setBorder(new TitledBorder("Demo 2: change format midstream")); MaskFormatter lowercase = null; try { lowercase = new MaskFormatter("LLLL"); } catch (ParseException pe) { } final JFormattedTextField field = new JFormattedTextField(lowercase); field.setValue("Fore"); pan.add(field, BorderLayout.CENTER); final JButton change = new JButton("change format"); JPanel changePanel = new JPanel(); changePanel.add(change); pan.add(changePanel, BorderLayout.SOUTH); change.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { field.commitEdit(); // commit current edit (if any) MaskFormatter uppercase = new MaskFormatter("UUUU"); DefaultFormatterFactory factory = new DefaultFormatterFactory(uppercase); field.setFormatterFactory(factory); change.setEnabled(false); } catch (ParseException pe) { } } }); return pan; }
From source file:MainClass.java
MainClass(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); source.setForeground(Color.red); getContentPane().add(source, BorderLayout.NORTH); target.addActionListener(this); getContentPane().add(target, BorderLayout.SOUTH); new DropTarget(target, DnDConstants.ACTION_COPY_OR_MOVE, this); setSize(205, 100);//w w w. j a va 2s .c om setVisible(true); }
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JButton button = new JButton("Print"); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m);/*from w w w. ja v a 2s .c o m*/ list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }); button.addActionListener(new PrintListener()); add(pane, BorderLayout.NORTH); add(button, BorderLayout.SOUTH); }