Example usage for java.awt BorderLayout BorderLayout

List of usage examples for java.awt BorderLayout BorderLayout

Introduction

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

Prototype

public BorderLayout() 

Source Link

Document

Constructs a new border layout with no gaps between components.

Usage

From source file:MainClass.java

public CurveApplet() {
    super(new BorderLayout());
    pane = new CurvePane();
    add(pane, "Center");

    MouseHandler handler = new MouseHandler();
    pane.addMouseListener(handler);//www.jav  a  2  s  .  com
    pane.addMouseMotionListener(handler);
}

From source file:Main.java

private void makeGUI() {

    setLayout(new BorderLayout());

    JPanel jp = new JPanel();
    jp.setLayout(new GridLayout(20, 20));
    int b = 0;/*from w  ww. java  2s . c om*/
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 20; j++) {
            jp.add(new JButton("Button " + b));
            ++b;
        }
    }

    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
    JScrollPane jsp = new JScrollPane(jp, v, h);

    add(jsp, BorderLayout.CENTER);
}

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 www . j  ava 2  s.  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);
}

From source file:JMFTest.java

JMFTest() {
    Player _player;/* w w  w .jav a 2s.  c  o  m*/
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            _player.stop();
            _player.deallocate();
            _player.close();
            System.exit(0);
        }
    });
    setExtent(0, 0, 320, 260);
    JPanel panel = (JPanel) getContentPane();
    panel.setLayout(new BorderLayout());
    String mediaFile = "vfw://1";
    try {
        MediaLocator mlr = new MediaLocator(mediaFile);
        _player = Manager.createRealizedPlayer(mlr);
        if (_player.getVisualComponent() != null)
            panel.add("Center", _player.getVisualComponent());
        if (_player.getControlPanelComponent() != null)
            panel.add("South", _player.getControlPanelComponent());
    } catch (Exception e) {
        System.err.println("Got exception " + e);
    }
}

From source file:kuvalataaja.user_interface.GUI.java

public GUI() {
    textPanel = new JPanel(new BorderLayout());
    buttonPanel = new JPanel(new FlowLayout());
    textArea = createJLabel();//from  w ww  .  j a  va2 s . c  o m
    runButton = new JButton("Run");
    tutButton = new JButton("Tutorial");
    //testButton = new JButton("Test");
    textPanel.add(textArea);
    buttonPanel.add(tutButton);
    buttonPanel.add(runButton);
    //buttonPanel.add(testButton);
    this.getContentPane().add(textPanel, BorderLayout.NORTH);
    this.getContentPane().add(buttonPanel);
    this.init();
}

From source file:SimpleList2.java

public SimpleList2() {
    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);/*  ww  w .j a va2 s.  c om*/

    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);
}

From source file:Main.java

public Main() {
    Box box1 = Box.createVerticalBox();
    for (int i = 1; i <= 100; i++) {
        box1.add(new JLabel("This is Label #" + i));
    }//  w  w  w .j  av  a  2 s . co m

    Box box2 = Box.createVerticalBox();
    for (int i = 1; i <= 100; i++) {
        box2.add(new JLabel("This is Label #" + i));
    }

    JPanel boxPanel1 = new JPanel();
    JPanel boxPanel2 = new JPanel();
    boxPanel1.add(box1);
    boxPanel2.add(box2);
    JScrollPane panel1Scroll = new JScrollPane(boxPanel1);
    JScrollPane panel2Scroll = new JScrollPane(boxPanel2);

    panelTab1 = new JPanel(new BorderLayout());
    panelTab2 = new JPanel(new BorderLayout());
    panelTab1.add(panel1Scroll);
    panelTab2.add(panel2Scroll);

    tabbedPane = new JTabbedPane();
    tabbedPane.add(panelTab1, "Panel 1");
    tabbedPane.add(panelTab2, "Panel 2");

    JFrame frame = new JFrame();
    frame.add(tabbedPane);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:XMLTreeView.java

public XMLTreeView(JFrame frame) {
    frame.getContentPane().setLayout(new BorderLayout());
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(file);
    //              DefaultMutableTreeNode top = new DefaultMutableTreeNode("XML Document"); 

    saxTree = new SAXTreeBuilder(top);

    try {// w  w  w. ja va 2 s .com
        SAXParser saxParser = new SAXParser();
        saxParser.setContentHandler(saxTree);
        saxParser.parse(new InputSource(new FileInputStream(file)));
    } catch (Exception ex) {
        top.add(new DefaultMutableTreeNode(ex.getMessage()));
    }
    JTree tree = new JTree(saxTree.getTree());
    JScrollPane scrollPane = new JScrollPane(tree);

    frame.getContentPane().add("Center", scrollPane);
    frame.setVisible(true);

}

From source file:Main.java

public Main() {
    // Build a mapping from book titles to their entries
    for (int i = 0; i < items.length; i++) {
        itemMap.put(items[i].getTitle(), items[i]);
    }//from  w  w w  .j  a v  a 2 s.c om

    setLayout(new BorderLayout());

    JComboBox bookCombo = new JComboBox(items);
    bookCombo.setEditable(true);
    bookCombo.setEditor(new MyComboBoxEditor(itemMap, items[0]));
    bookCombo.setMaximumRowCount(4);
    bookCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("You chose " + ((JComboBox) e.getSource()).getSelectedItem() + "!");
        }
    });
    bookCombo.setActionCommand("Hello");
    add(bookCombo, BorderLayout.CENTER);
}

From source file:SplashScreen.java

public SplashScreen(final BufferedImage img) {
    JPanel panel = new JPanel() {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2d = (Graphics2D) g.create();

            g2d.drawImage(img, 0, 0, img.getWidth(), img.getHeight(), SplashScreen.this);
        }/*from   w w w  .  jav  a  2s . co  m*/
    };
    panel.setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));

    Container content = getContentPane();
    content.setLayout(new BorderLayout());
    content.add(panel, BorderLayout.NORTH);
    content.add(label = new JLabel(), BorderLayout.CENTER);
    content.add(bar = new JProgressBar(), BorderLayout.SOUTH);
    pack();
    setLocationRelativeTo(null);
}