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:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("Text Slider");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final TextSlider ts = new TextSlider();
    ts.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Text: " + ts.getText());
        }/*from   www  . java2 s  .  c  om*/
    });

    frame.add(ts, BorderLayout.NORTH);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    AdjustmentListener adjustmentListener = new AdjustmentListener() {
        public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) {
            System.out.println("Adjusted: " + adjustmentEvent.getValue());
        }//from   w w w . java2  s . c  o  m
    };
    JScrollBar oneJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    oneJScrollBar.addAdjustmentListener(adjustmentListener);

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(oneJScrollBar, BorderLayout.NORTH);

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

From source file:Main.java

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

    final JTextField textField = new JTextField();

    JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    BoundedRangeModel brm = textField.getHorizontalVisibility();
    scrollBar.setModel(brm);/*w w w  . j  av a  2s . c o  m*/
    panel.add(textField);
    panel.add(scrollBar);

    frame.add(panel, BorderLayout.NORTH);
    frame.setSize(300, 100);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setValue(1);//from  w w  w . j a v a 2 s  .com

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

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

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setExtent(10);/*from w w  w .jav a2s. com*/

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

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

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setMinimum(10);/* w  ww  . ja  va2s.  c  o  m*/

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

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

From source file:Main.java

public static void main(String args[]) throws Exception {
    ChangeListener changeListener = new BoundedChangeListener();
    JScrollBar anotherJScrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
    BoundedRangeModel model = anotherJScrollBar.getModel();
    model.addChangeListener(changeListener);
    model.setMaximum(10);/*from  w ww. ja  v a2  s.co m*/

    JFrame frame = new JFrame("ScrollBars R Us");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(anotherJScrollBar, BorderLayout.NORTH);

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

From source file:SizingSamples.java

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

    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList(labels);
    jlist1.setVisibleRowCount(4);/*  ww w .j  a v a  2s.c o m*/
    DefaultListModel model = new DefaultListModel();
    model.ensureCapacity(100);
    for (int i = 0; i < 100; i++) {
        model.addElement(Integer.toString(i));
    }
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    JList jlist2 = new JList(model);
    jlist2.setVisibleRowCount(4);
    jlist2.setFixedCellHeight(12);
    jlist2.setFixedCellWidth(200);

    JScrollPane scrollPane2 = new JScrollPane(jlist2);
    frame.add(scrollPane2, BorderLayout.CENTER);

    JList jlist3 = new JList(labels);
    jlist3.setVisibleRowCount(4);
    frame.add(jlist3, BorderLayout.SOUTH);

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

From source file:Main.java

public static void main(final String args[]) {
    final String labels[] = { "A", "B", "C", "D", "E" };
    final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(labels);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JComboBox<String> comboBox1 = new JComboBox<String>(model);
    comboBox1.setMaximumRowCount(5);//from w w w . java 2s  . c o  m
    comboBox1.setEditable(true);
    frame.add(comboBox1, BorderLayout.NORTH);

    JList<String> jlist = new JList<String>(model);
    JScrollPane scrollPane = new JScrollPane(jlist);
    frame.add(scrollPane, BorderLayout.CENTER);

    JButton button = new JButton("Add");
    frame.add(button, BorderLayout.SOUTH);
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            model.addElement("a");
        }
    };
    button.addActionListener(actionListener);

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

From source file:CutPasteSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Cut/Paste Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = frame.getContentPane();

    JTextField textField = new JTextField();
    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);

    content.add(textField, BorderLayout.NORTH);
    content.add(scrollPane, BorderLayout.CENTER);

    Action actions[] = textField.getActions();

    Action cutAction = TextUtilities.findAction(actions, DefaultEditorKit.cutAction);
    Action copyAction = TextUtilities.findAction(actions, DefaultEditorKit.copyAction);
    Action pasteAction = TextUtilities.findAction(actions, DefaultEditorKit.pasteAction);

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

    JButton cutButton = new JButton(cutAction);
    cutButton.setText("Cut");
    panel.add(cutButton);/* w  ww.j a  va2s  .  c  o m*/

    JButton copyButton = new JButton(copyAction);
    copyButton.setText("Copy");
    panel.add(copyButton);

    JButton pasteButton = new JButton(pasteAction);
    pasteButton.setText("Paste");
    panel.add(pasteButton);

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