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: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   w  w  w.j  av a2s  . c o  m*/

    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);// w w  w . ja va 2 s. co  m

    setVisible(true);
}

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);//from  w  w w . j  av  a  2s. c  o m

    setVisible(true);
}

From source file:Main.java

public MyPanel() {
    JTextField labelA = new JTextField("Your A component");
    JTextField labelB = new JTextField("Your B component");
    JTextField labelC = new JTextField("Your C component");
    JTextField labelD = new JTextField("Top Right D");

    JPanel north = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.FIRST_LINE_END;
    gbc.weightx = 1;//from w w w .  j a v  a  2  s.  c o m
    gbc.insets = new Insets(10, 10, 10, 10);
    north.add(labelD, gbc);

    JPanel south = new JPanel(new GridBagLayout());
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridy = 0;
    south.add(labelA, gbc);
    gbc.gridy = 1;
    south.add(labelB, gbc);
    gbc.gridy = 2;
    south.add(labelC, gbc);

    setLayout(new BorderLayout());
    add(north, BorderLayout.NORTH);
    add(south, BorderLayout.CENTER);
}

From source file:AppletMenuBarDemo.java

public void init() {
    AppletMenuBar menubar = new AppletMenuBar();
    menubar.setForeground(Color.black);
    menubar.setHighlightColor(Color.red);
    menubar.setFont(new Font("helvetica", Font.BOLD, 12));
    this.setLayout(new BorderLayout());
    this.add(menubar, BorderLayout.NORTH);

    PopupMenu file = new PopupMenu();
    file.add("New...");
    file.add("Open...");
    file.add("Save As...");
    PopupMenu edit = new PopupMenu();
    edit.add("Cut");
    edit.add("Copy");
    edit.add("Paste");

    menubar.addMenu("File", file);
    menubar.addMenu("Edit", edit);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    model = new DefaultListModel();
    list = new JList(model);
    JScrollPane pane = new JScrollPane(list);
    JButton addButton = new JButton("Add Element");
    JButton removeButton = new JButton("Remove Element");
    for (int i = 0; i < 15; i++)
        model.addElement("Element " + i);

    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            model.addElement("Element " + counter);
            counter++;//from w ww .  j ava  2 s  .c om
        }
    });
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (model.getSize() > 0)
                model.removeElementAt(0);
        }
    });

    add(pane, BorderLayout.NORTH);
    add(addButton, BorderLayout.WEST);
    add(removeButton, BorderLayout.EAST);
}

From source file:teambootje.A1.java

public A1() {
    initComponents();//from   w ww.  j  a  v a2  s . c  o m
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());
    setSize(500, 500);

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 1");
    ImageIcon icon = new ImageIcon("img/bootje.jpg");
    setIconImage(icon.getImage());

    // back BTN
    JButton back = new JButton("Back");
    add(back, BorderLayout.NORTH);

    back.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    // panel
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String nvt = "SELECT Geslacht, COUNT(*) AS Aantal FROM persoon GROUP BY geslacht";
    String male = "SELECT Geslacht AS male, COUNT(*) AS Aantal_Male FROM persoon WHERE Geslacht = 'man'";
    String Female = "SELECT Geslacht AS female, COUNT(*) AS Aantal_Female FROM persoon WHERE Geslacht = 'vrouw'";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(nvt);
        while (rs.next()) {
            String geslacht = rs.getString("Geslacht");
            int aantal = rs.getInt("Aantal");
            String[] row = new String[rs.getMetaData().getColumnCount()];
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                row[i - 1] = rs.getString(i);
            }
            list.add(row);

            try {
                rs = db.runSql(male);
                while (rs.next()) {
                    String man = rs.getString("male");
                    int am = rs.getInt("Aantal_Male");
                    String[] row1 = new String[rs.getMetaData().getColumnCount()];
                    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                        row1[i - 1] = rs.getString(i);
                    }

                    try {
                        rs = db.runSql(Female);
                        while (rs.next()) {
                            String vrouw = rs.getString("female");
                            int af = rs.getInt("Aantal_Female");
                            String[] row2 = new String[rs.getMetaData().getColumnCount()];
                            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                                row2[i - 1] = rs.getString(i);
                            }
                            Object[][] array = new Object[list.size()][];
                            Object columnNames[] = { "Geslacht", "Aantal" };
                            list.toArray(array);

                            JTable table = new JTable(array, columnNames);
                            JScrollPane scroll = new JScrollPane(table);
                            scroll.setPreferredSize(new Dimension(400, 400));
                            ana.add(scroll);

                            //chart
                            JButton chart = new JButton("Chart");
                            add(chart, BorderLayout.SOUTH);

                            chart.addActionListener(new ActionListener() {
                                String g1 = geslacht;
                                String m = man;
                                String v = vrouw;
                                int a1 = aantal;
                                int a2 = am;
                                int a3 = af;

                                @Override
                                public void actionPerformed(ActionEvent e) {

                                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                                    pieDataset.setValue("Niet vrij gegeven", a1);
                                    pieDataset.setValue("Man", a2);
                                    pieDataset.setValue("vrouw", a3);

                                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal mannen en vrouwen",
                                            pieDataset, true, true, true);
                                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                                    ChartFrame pie = new ChartFrame("Aantal mannen en vrouwen", chart);
                                    pie.setVisible(true);
                                    pie.setSize(500, 500);
                                    pie.setLocationRelativeTo(null);

                                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                                }
                            });
                        }
                    } catch (SQLException v) {
                        JOptionPane.showMessageDialog(null, v);
                    }
                }
            } catch (SQLException m) {
                JOptionPane.showMessageDialog(null, m);
            }

        }
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

From source file:ListModelExample.java

public ListModelExample() {
    setLayout(new BorderLayout());
    model = new DefaultListModel();
    list = new JList(model);
    JScrollPane pane = new JScrollPane(list);
    JButton addButton = new JButton("Add Element");
    JButton removeButton = new JButton("Remove Element");
    for (int i = 0; i < 15; i++)
        model.addElement("Element " + i);

    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            model.addElement("Element " + counter);
            counter++;// w  w w.java  2  s . c o m
        }
    });
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (model.getSize() > 0)
                model.removeElementAt(0);
        }
    });

    add(pane, BorderLayout.NORTH);
    add(addButton, BorderLayout.WEST);
    add(removeButton, BorderLayout.EAST);
}

From source file:Main.java

public Main() {
    super("Demostrating BoxLayout");
    final int SIZE = 3;
    Container c = getContentPane();
    c.setLayout(new BorderLayout(30, 30));

    Box boxes[] = new Box[4];

    boxes[0] = Box.createHorizontalBox();
    boxes[1] = Box.createVerticalBox();
    boxes[2] = Box.createHorizontalBox();
    boxes[3] = Box.createVerticalBox();

    for (int i = 0; i < SIZE; i++)
        boxes[0].add(new JButton("boxes[0]: " + i));

    for (int i = 0; i < SIZE; i++) {
        boxes[1].add(Box.createVerticalStrut(25));
        boxes[1].add(new JButton("boxes[1]: " + i));
    }//from  w  w  w .j a  v a 2s.com

    for (int i = 0; i < SIZE; i++) {
        boxes[2].add(Box.createHorizontalGlue());
        boxes[2].add(new JButton("boxes[2]: " + i));
    }

    for (int i = 0; i < SIZE; i++) {
        boxes[3].add(Box.createRigidArea(new Dimension(12, 8)));
        boxes[3].add(new JButton("boxes[3]: " + i));
    }

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

    for (int i = 0; i < SIZE; i++) {
        panel.add(Box.createGlue());
        panel.add(new JButton("panel: " + i));
    }

    c.add(boxes[0], BorderLayout.NORTH);
    c.add(boxes[1], BorderLayout.EAST);
    c.add(boxes[2], BorderLayout.SOUTH);
    c.add(boxes[3], BorderLayout.WEST);
    c.add(panel, BorderLayout.CENTER);

    setSize(350, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    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);//w w w. jav a 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);
}