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

private void createTable() {
    Object[][] data = { { "a", "b", "e", 4, false } };
    String[] columnNames = { "A", "B", "C", "D", "E" };

    table = new JTable(data, columnNames);

    JPanel tPanel = new JPanel(new BorderLayout());
    tPanel.add(table.getTableHeader(), BorderLayout.NORTH);
    tPanel.add(table, BorderLayout.CENTER);

    getContentPane().add(tPanel, BorderLayout.CENTER);
}

From source file:UndoEditor.java

public UndoEditor() {
    setLayout(new BorderLayout());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextPane editor = new JTextPane();
    editor.getDocument().addUndoableEditListener(new UndoListener());

    menuBar.add(editMenu);//from ww  w. jav  a2 s.c  o  m
    editMenu.add(undoAction);
    editMenu.add(redoAction);
    this.setJMenuBar(menuBar);
    add(new JScrollPane(editor));
    setSize(400, 300);
    setVisible(true);
}

From source file:UndoEditor.java

public UndoEditor() {
    setLayout(new BorderLayout());
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextPane editor = new JTextPane();
    editor.getDocument().addUndoableEditListener(new UndoListener());

    JScrollPane scroller = new JScrollPane(editor);
    menuBar.add(editMenu);//from w w  w.  j a  v a  2s  . co m
    editMenu.add(undoAction);
    editMenu.add(redoAction);
    this.setJMenuBar(menuBar);
    add(scroller);
    setSize(400, 300);
    setVisible(true);
}

From source file:Main.java

public Main() {

    GridLayout g = new GridLayout(3, 3);
    pan = new JPanel(g);
    pan.add(new JButton("1"));
    pan.add(new JButton("2"));
    pan.add(new JButton("3"));
    pan.add(new JButton("4"));
    pan.add(new JButton("5"));
    pan.add(new JButton("6"));
    pan.add(new JButton("7"));
    pan.add(new JButton("8"));
    pan.add(new JButton("9"));
    JLabel l = new JLabel("grid layout");
    l.setHorizontalAlignment(SwingConstants.CENTER);

    setLayout(new BorderLayout());
    add(l, BorderLayout.NORTH);/*from w ww.  j a v a 2s  .c  om*/
    add(pan, BorderLayout.CENTER);
    setSize(1000, 500);
    setVisible(true);
}

From source file:com.js.quickestquail.ui.stats.ExtensionStat.java

public ExtensionStat() {
    setLayout(new BorderLayout());
    add(new ChartPanel(generateChart()), BorderLayout.CENTER);
}

From source file:WebBrowserBasedOnJEditorPane.java

public WebBrowserBasedOnJEditorPane() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel pnlURL = new JPanel();
    pnlURL.setLayout(new BorderLayout());
    pnlURL.add(new JLabel("URL: "), BorderLayout.WEST);
    pnlURL.add(txtURL, BorderLayout.CENTER);
    getContentPane().add(pnlURL, BorderLayout.NORTH);
    getContentPane().add(ep, BorderLayout.CENTER);

    getContentPane().add(lblStatus, BorderLayout.SOUTH);

    ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                String url = ae.getActionCommand().toLowerCase();
                if (url.startsWith("http://"))
                    url = url.substring(7);
                ep.setPage("http://" + IDN.toASCII(url));
            } catch (Exception e) {
                e.printStackTrace();//from w  ww  .  jav  a2  s  .c  om
                JOptionPane.showMessageDialog(WebBrowserBasedOnJEditorPane.this,
                        "Browser problem: " + e.getMessage());
            }
        }
    };
    txtURL.addActionListener(al);

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

From source file:Main.java

public TestPane() {
    setLayout(new BorderLayout());
    tree = new JTree();
    File rootFile = new File(".");
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(rootFile);
    model = new DefaultTreeModel(root);

    tree.setModel(model);//from w  w  w  .  j  a v a  2s.  c o m
    tree.setRootVisible(true);
    tree.setShowsRootHandles(true);

    add(new JScrollPane(tree));

    JButton load = new JButton("Load");
    add(load, BorderLayout.SOUTH);

    load.addActionListener(e -> {
        DefaultMutableTreeNode r = (DefaultMutableTreeNode) model.getRoot();
        root.removeAllChildren();
        model.reload();
        File f = (File) r.getUserObject();
        addFiles(f, model, r);
        tree.expandPath(new TreePath(r));
    });
}

From source file:CombiningShapes.java

public CombiningShapes() {
    mShapeOne = new Ellipse2D.Double(40, 20, 80, 80);
    mShapeTwo = new Rectangle2D.Double(60, 40, 80, 80);
    setBackground(Color.white);/*ww w .  jav  a 2 s  .co m*/
    setLayout(new BorderLayout());

    JPanel controls = new JPanel();

    mOptions = new JComboBox(new String[] { "outline", "add", "intersection", "subtract", "exclusive or" });

    mOptions.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ie) {
            repaint();
        }
    });
    controls.add(mOptions);
    add(controls, BorderLayout.SOUTH);
}

From source file:SimpleApp3.java

public SimpleApp3(JFrame frame) {
    frame.getContentPane().setLayout(new BorderLayout());
    XMLComponent xmlComponent = new XMLComponent();
    frame.getContentPane().add("Center", xmlComponent.build("ui.xml"));
    frame.setVisible(true);//from   www .j  a  v a  2 s .co  m
}

From source file:Main.java

public FileTree(File dir) {
    setLayout(new BorderLayout());
    JTree tree = new JTree(addNodes(null, dir));
    tree.addTreeSelectionListener(e -> {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
        System.out.println("You selected " + node);
    });//from  w  w  w  . j  a  va2 s  .c  o m
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    JScrollPane scrollpane = new JScrollPane();
    scrollpane.getViewport().add(tree);
    add(BorderLayout.CENTER, scrollpane);
}