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

public PopupDemo() {
    MenuBar mb = new MenuBar();
    setMenuBar(mb);//from w  w  w  .j  a v  a2 s.  c  o m
    Menu m = new Menu("file");
    mb.add(m);
    MenuItem item = new MenuItem("file-1");
    item.addActionListener(this);
    m.add(item);
    item = new MenuItem("file-2");
    m.add(item);

    setSize(100, 100);
    setLayout(new BorderLayout());

    Label l = new Label("label");
    addPopup(l, "label");
    add(l, "North");

    Panel p = new Panel();
    addPopup(p, "Panel");
    add(p, "Center");

    Button b = new Button("button");
    addPopup(b, "button");
    add(b, "South");
}

From source file:SwingBar.java

public SwingBar() {
    fileMenu.add(fileExit);//from ww  w . j  a  va  2  s.  c o m
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);

    frameContainer = getContentPane();
    frameContainer.setLayout(new BorderLayout());
    for (int i = 0; i < buttonLabels.length; ++i) {
        icons[i] = new ImageIcon(iconFiles[i]);
        buttons[i] = new JButton(icons[i]);
        buttons[i].setToolTipText(buttonLabels[i]);
        if (i == 3)
            toolBar.addSeparator();
        toolBar.add(buttons[i]);
    }
    frameContainer.add("North", toolBar);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fileExit.addActionListener(new MenuItemHandler());

    setSize(500, 500);
    setVisible(true);
}

From source file:com.opendoorlogistics.components.geocode.postcodes.impl.SummaryPanel.java

public SummaryPanel() {
    setLayout(new BorderLayout());
    text.setEditable(false);//w  w  w  . ja  v  a2 s  .c o  m
    JScrollPane scrollpane = new JScrollPane(text);
    scrollpane.setViewportView(text);
    add(scrollpane, BorderLayout.CENTER);
    Dimension size = new Dimension(350, 100);
    scrollpane.setMinimumSize(new Dimension(1, (int) size.getHeight()));
    scrollpane.setPreferredSize(size);
    scrollpane.setMaximumSize(new Dimension(2000, (int) size.getHeight()));
    text.setBackground(new Color(220, 220, 220));
    text.setOpaque(true);

}

From source file:Main.java

/**
 * Creates (and displays) a JInternalFrame for a specified component. <br />
 * The size of the JInternalFrame will be <code>frameSize</code>. <br />
 * The frame is <i>just</i> closeable. <br />
 * //from   www  .  j a v a 2 s . c  o m
 * @param desktop the JDesktopPane
 * @param comp the component to display in the created frame
 * @param title the title of the frame
 * @param frameSize the size of the frame
 * @return the created and displayed frame
 */
public static JInternalFrame showInternalFrame(JDesktopPane desktop, JComponent comp, String title,
        Dimension frameSize) {
    JInternalFrame frm = new JInternalFrame(title);
    frm.setClosable(true);
    frm.setLayout(new BorderLayout());
    frm.add(comp, BorderLayout.CENTER);
    frm.setSize(frameSize);
    frm.setVisible(true);

    Dimension size = frm.getSize();
    frm.setLocation(desktop.getWidth() / 2 - size.width / 2, desktop.getHeight() / 2 - size.height / 2);
    desktop.add(frm, 0);

    try {
        frm.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {
    }

    return frm;
}

From source file:Tela.java

/**
 * Creates new form Tela/*from  w w  w  .  j av  a  2s. c o  m*/
 */
public Tela() {
    initComponents();
    jPanel2.setLayout(new BorderLayout());
    exibeGrafico(new ArrayList<Double>());

    this.setVisible(true);

    StyledDocument doc = txtArtigos.getStyledDocument();
    SimpleAttributeSet center = new SimpleAttributeSet();
    doc.setParagraphAttributes(0, doc.getLength(), center, false);
}

From source file:Main.java

public Main() {
    editorPane.setDocument(doc);/* w w  w .  j a va2 s.  com*/
    editorPane.setEditorKit(styledEditorKit);
    JScrollPane scrollpane = new JScrollPane(editorPane);
    scrollpane.setPreferredSize(new Dimension(500, 400));
    JPanel comboPanel = new JPanel();
    comboPanel.add(fontBox);

    setLayout(new BorderLayout());
    add(scrollpane, BorderLayout.CENTER);
    add(comboPanel, BorderLayout.SOUTH);

    Document doc = editorPane.getDocument();
    for (int i = 0; i < 20; i++) {
        int offset = doc.getLength();
        String str = "This is line number: " + i + "\n";
        try {
            doc.insertString(offset, str, null);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    }

    fontBox.addActionListener(e -> {
        int size = (Integer) fontBox.getSelectedItem();
        Action fontAction = new StyledEditorKit.FontSizeAction(String.valueOf(size), size);
        fontAction.actionPerformed(e);
    });
}

From source file:Main.java

public Main() {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTree tree = new JTree(buildDemoModel());

    JPanel buttonsPanel = new JPanel();

    JButton saveButton = new JButton("Capture state");
    saveButton.addActionListener(e -> expansionState = saveExpansionState(tree));

    JButton loadButton = new JButton("Load state");
    loadButton.addActionListener(e -> {
        loadExpansionState(tree, expansionState);
        expansionState = saveExpansionState(tree);
    });//from   w w  w . j  a  v  a 2  s .co m

    buttonsPanel.add(saveButton);
    buttonsPanel.add(loadButton);

    JPanel content = new JPanel(new BorderLayout());
    content.add(buttonsPanel, BorderLayout.SOUTH);
    content.add(new JScrollPane(tree), BorderLayout.CENTER);

    frame.add(content);
    frame.pack();
    frame.setVisible(true);
}

From source file:ButtonScroll.java

public ButtonScroll() {
    super("Scrolling Programmatically");
    setSize(400, 400);//w  w w  . j a v  a 2s . co  m
    getContentPane().setLayout(new BorderLayout());

    ImageIcon shuttle = new ImageIcon("largeJava2sLogo.GIF");
    pgVertical = shuttle.getIconHeight() / 5;
    pgHorzontal = shuttle.getIconWidth() / 5;
    JLabel lbl = new JLabel(shuttle);

    viewport = new JViewport();
    viewport.setView(lbl);
    viewport.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            enableButtons(ButtonScroll.this.viewport.getViewPosition());
        }
    });
    getContentPane().add(viewport, BorderLayout.CENTER);

    JPanel pv = new JPanel(new BorderLayout());
    upButton = createButton("up", 'u');
    ActionListener lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(0, -1);
        }
    };
    upButton.addActionListener(lst);
    pv.add(upButton, BorderLayout.NORTH);

    downButton = createButton("down", 'd');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(0, 1);
        }
    };
    downButton.addActionListener(lst);
    pv.add(downButton, BorderLayout.SOUTH);
    getContentPane().add(pv, BorderLayout.EAST);

    JPanel ph = new JPanel(new BorderLayout());
    leftButton = createButton("left", 'l');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(-1, 0);
        }
    };
    leftButton.addActionListener(lst);
    ph.add(leftButton, BorderLayout.WEST);

    rightButton = createButton("right", 'r');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(1, 0);
        }
    };
    rightButton.addActionListener(lst);
    ph.add(rightButton, BorderLayout.EAST);
    getContentPane().add(ph, BorderLayout.SOUTH);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
    movePanel(0, 0);
}

From source file:Main.java

private JPanel createTabbedPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    JTextField field = new JTextField(50);
    JEditorPane pane = new JEditorPane();
    pane.setPreferredSize(new Dimension(700, 500));

    panel.add(field, BorderLayout.NORTH);
    panel.add(pane, BorderLayout.CENTER);
    return panel;
}

From source file:projects.upc.exec.HrDiagram.java

/**
 * Main application entry point./*from   www.  j  a  v a2 s. co m*/
 * @param args
 *    The args - ignored.
 */
public static void main(String[] args) {

    final JFrame frame = new JFrame("UPC HR diagram");

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLayout(new BorderLayout());
            frame.add(new HrDiagram(), BorderLayout.CENTER);
            frame.setSize(1500, 750);
            frame.pack();
            frame.setVisible(true);
        }
    });
}