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:teambootje.A2.java

public A2() {
    initComponents();/* w  ww.ja v  a2 s  .  c o m*/
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 2");
    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 en Label
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String sql = "SELECT Datum, COUNT(*) AS Aantal FROM posts GROUP BY Datum";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(sql);
        while (rs.next()) {
            String datum = rs.getString("Datum");
            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);
            //chart
            JButton chart = new JButton("Chart");
            add(chart, BorderLayout.SOUTH);

            chart.addActionListener(new ActionListener() {
                String dat = datum;
                int a1 = aantal;

                @Override
                public void actionPerformed(ActionEvent e) {

                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                    pieDataset.setValue(dat, a1);
                    pieDataset.setValue("2015-04-06", new Integer(5));
                    pieDataset.setValue("2015-04-05", new Integer(5));
                    pieDataset.setValue("2015-04-04", new Integer(14));
                    pieDataset.setValue("2015-04-03", new Integer(4));
                    pieDataset.setValue("2015-04-02", new Integer(1));
                    pieDataset.setValue("2015-04-01", new Integer(32));
                    pieDataset.setValue("2015-03-31", new Integer(32));
                    pieDataset.setValue("2015-03-30", new Integer(9));
                    pieDataset.setValue("2015-03-29", new Integer(4));
                    pieDataset.setValue("2015-03-28", new Integer(1));
                    pieDataset.setValue("2015-03-27", new Integer(3));
                    pieDataset.setValue("2015-03-26", new Integer(6));
                    pieDataset.setValue("2015-03-25", new Integer(1));
                    pieDataset.setValue("2015-03-24", new Integer(1));
                    pieDataset.setValue("2015-03-23", new Integer(1));
                    pieDataset.setValue("2015-03-22", new Integer(1));
                    pieDataset.setValue("2015-03-21", new Integer(1));
                    pieDataset.setValue("2015-03-20", new Integer(1));
                    pieDataset.setValue("2015-03-19", new Integer(1));
                    pieDataset.setValue("2015-03-18", new Integer(2));
                    pieDataset.setValue("2015-03-17", new Integer(1));
                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal Posts per datum", pieDataset, true,
                            true, true);
                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                    ChartFrame pie = new ChartFrame("Aantal Posts per datum", 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 e) {
        JOptionPane.showMessageDialog(null, e);
    }

    Object[][] array = new Object[list.size()][];
    Object columnNames[] = { "Datum", "Aantal" };
    list.toArray(array);

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

}

From source file:DatabaseBrowser.java

public DatabaseBrowser() throws Exception {
    ConnectionDialog cd = new ConnectionDialog(this);
    connection = cd.getConnection();/*w  ww .ja  va  2s .  co m*/
    Container pane = getContentPane();
    pane.add(getSelectionPanel(), BorderLayout.NORTH);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    refreshTable();
    pane.add(new JScrollPane(table), BorderLayout.CENTER);

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(600, 450);

    setVisible(true);
}

From source file:MemComboBoxDemo.java

public MemComboBoxDemo() {
    super();// w w  w  . jav a  2  s.c  o  m
    setSize(300, 100);
    getContentPane().setLayout(new BorderLayout());

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(new JLabel("Address"));

    urlComboBox.load("addresses.dat");
    ComboBoxListener lst = new ComboBoxListener();
    urlComboBox.addActionListener(lst);

    MemComboAgent agent = new MemComboAgent(urlComboBox);

    p.add(urlComboBox);
    getContentPane().add(p, BorderLayout.NORTH);

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

    setVisible(true);
    urlComboBox.grabFocus();
}

From source file:Main.java

public Main() {
    super("Swing Editor");
    textComp = createTextComponent();/*from w w  w.  j a  v a2 s  .c  o m*/
    makeActionsPretty();

    Container content = getContentPane();
    content.add(textComp, BorderLayout.CENTER);
    content.add(createToolBar(), BorderLayout.NORTH);
    setJMenuBar(createMenuBar());
    setSize(320, 240);
}

From source file:it.unibo.alchemist.boundary.gui.asmc.SimplePlot.java

/**
 * Default constructor./*from  www  .j ava  2  s  . c  om*/
 */
public SimplePlot() {
    super();
    this.setLayout(new BorderLayout());
    final JPanel placeHolder = new JPanel();
    final JLabel wait = new JLabel("Please wait.");
    placeHolder.add(wait);
    this.add(placeHolder, BorderLayout.NORTH);
}

From source file:my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java

private void initComponents() {
    try {//w  w w  .  j  a v  a 2  s  .  co m
        String licenseStr = FileUtils.readFileToString(new File(ConfigManager.GPL_LICENSE_FILE));
        licenseText = new JTextArea(licenseStr);
        licenseText.setColumns(20);
        licenseText.setRows(15);
        licenseText.setBorder(BorderFactory.createLineBorder(UIAccessories.BORDER_GRAY));
        licenseText.setBackground(UIAccessories.WHITE);
        licenseText.setEditable(false);

        JScrollPane scrollPane = new JScrollPane(licenseText);
        scrollPane.setBorder(null);
        scrollPane.setOpaque(false);
        scrollPane.getViewport().setOpaque(false);
        scrollPane.getViewport().setBorder(null);
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        setLayout(new BorderLayout(20, 20));
        add(createTransparentFillerPanel(), BorderLayout.NORTH);
        add(scrollPane, BorderLayout.CENTER);
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.setOpaque(false);
}

From source file:Operacional.Janela2.java

public Janela2() {
    super();//from w w  w .j  av a  2s . c om
    IntervalXYDataset intervalxydataset = createDataset();
    jfreechart = createChart(intervalxydataset);
    chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 300));
    setLayout(new BorderLayout());
    add(chartpanel, BorderLayout.NORTH);
}

From source file:MainClass.java

public MainClass() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(350, 200);//from w  w  w  . j  a va  2s.  co  m

    JTable table = new JTable(qtm);
    JScrollPane scrollpane = new JScrollPane(table);
    JPanel commandPanel = new JPanel();
    commandPanel.setLayout(new GridLayout(3, 2));
    commandPanel.add(new JLabel("Enter the Host URL: "));
    commandPanel.add(hostField = new JTextField());
    commandPanel.add(new JLabel("Enter your query: "));
    commandPanel.add(queryField = new JTextField());
    commandPanel.add(new JLabel("Click here to send: "));

    JButton jb = new JButton("Search");
    jb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            qtm.setHostURL(hostField.getText().trim());
            qtm.setQuery(queryField.getText().trim());
        }
    });
    commandPanel.add(jb);
    getContentPane().add(commandPanel, BorderLayout.NORTH);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
}

From source file:SimpleDraw.java

public SimpleDraw() {
    this.setTitle("Simple DRAW");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // add check box group
    ButtonGroup cbg = new ButtonGroup();
    JRadioButton lineButton = new JRadioButton("Line");
    JRadioButton ovalButton = new JRadioButton("Oval");
    JRadioButton rectangleButton = new JRadioButton("Rectangle");
    cbg.add(lineButton);/*from   ww  w .j  a  v a  2 s  .  c  o  m*/
    cbg.add(ovalButton);
    cbg.add(rectangleButton);
    lineButton.addActionListener(this);
    ovalButton.addActionListener(this);
    rectangleButton.addActionListener(this);
    rectangleButton.setSelected(true);
    JPanel radioPanel = new JPanel(new FlowLayout());
    radioPanel.add(lineButton);
    radioPanel.add(ovalButton);
    radioPanel.add(rectangleButton);
    this.addMouseListener(this);
    this.setLayout(new BorderLayout());
    this.add(radioPanel, BorderLayout.NORTH);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    JButton button = new JButton("Print");
    button.addActionListener(new PrintListener());

    booklist = new JList(books);
    booklist.setCellRenderer(new BookCellRenderer());
    booklist.setVisibleRowCount(4);//from   w  w  w.  j a v a2s  . c  o  m
    JScrollPane pane = new JScrollPane(booklist);

    add(pane, BorderLayout.NORTH);
    add(button, BorderLayout.SOUTH);
}