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

public PrimeCheck() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel pnl = new JPanel();
    JButton btnCheck = new JButton("Check");
    ActionListener al;//www  . j ava2s  .com
    al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                BigInteger bi = new BigInteger("1234567");
                System.out.println("One moment...");
                new PrimeCheckTask(bi).execute();
            } catch (NumberFormatException nfe) {
                System.out.println("Invalid input");
            }
        }
    };
    btnCheck.addActionListener(al);
    pnl.add(btnCheck);
    getContentPane().add(pnl, BorderLayout.NORTH);
    pack();
    setResizable(false);
    setVisible(true);
}

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 ww.  j av  a  2 s  .  c  om
    };
    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);
}

From source file:DropTest2.java

public DropTest2() {
    super("Drop Test");
    setSize(300, 300);//from w  ww.  j ava2s . c o  m

    getContentPane().add(new JLabel("Drop a list from your file chooser here:"), BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta, BorderLayout.CENTER);

    // Set up our text area to recieve drops...
    // This class will handle drop events
    dt = new DropTarget(ta, this);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);/*from  w w  w  . j  av a2  s .com*/

    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JButton btnNewButton = new JButton("Click Me");
    btnNewButton.addActionListener(e -> doClick());
    contentPane.add(btnNewButton, BorderLayout.NORTH);
    jarFilesDB = new MyTreeModel();
    jarFilesDB.load(isAlpha);
    isAlpha = !isAlpha;
    jtree = new JTree(jarFilesDB);
    JScrollPane scrollPane = new JScrollPane(jtree);
    contentPane.add(scrollPane, BorderLayout.CENTER);
}

From source file:StocksTable3.java

public StocksTable3() {
    super("Stocks Table");
    setSize(600, 300);//from   www . jav a2  s  .c o m

    m_data = new StockTableData();

    m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT);
    m_title.setFont(new Font("TimesRoman", Font.BOLD, 24));
    m_title.setForeground(Color.black);
    getContentPane().add(m_title, BorderLayout.NORTH);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);

    for (int k = 0; k < StockTableData.m_columns.length; k++) {
        DefaultTableCellRenderer renderer = new ColoredTableCellRenderer();
        renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment);
        TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

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

From source file:SecretTest.java

public SecretTest() {
    super("EventListenerList Demo");
    setSize(200, 100);//from   www . ja  v a  2 s .  co m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    SecretLabel secret = new SecretLabel("Try Clicking Me");
    final JLabel reporter = new JLabel("Event reports will show here...");
    secret.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            reporter.setText("Got it: " + ae.getActionCommand());
        }
    });
    getContentPane().add(secret, BorderLayout.NORTH);
    getContentPane().add(reporter, BorderLayout.SOUTH);
}

From source file:SliderControlPaintLine.java

public SliderControlPaintLine() {
    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new GridLayout(3, 3));
    getContentPane().add(controlPanel, BorderLayout.NORTH);

    JLabel label1 = new JLabel("Translate(dx,dy): ");
    JLabel label2 = new JLabel("Rotate(Theta,ox,oy): ");
    JLabel label3 = new JLabel("Scale(sx,sy)x10E-2:");

    controlPanel.add(label1);/*w  w w  .j  ava 2 s .  c  om*/

    slider1 = createSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50);
    slider2 = createSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50);

    controlPanel.add(label2);

    slider3 = createSlider(controlPanel, JSlider.HORIZONTAL, 0, 360, 0, 90, 45);

    JPanel subPanel = new JPanel();
    subPanel.setLayout(new GridLayout(1, 2));

    slider4 = createSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50);
    slider5 = createSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50);
    controlPanel.add(subPanel);

    controlPanel.add(label3);

    slider6 = createSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);
    slider7 = createSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);

    JPanel widthPanel = new JPanel();
    JLabel label4 = new JLabel("Width Control:", JLabel.RIGHT);
    slider8 = createSlider(widthPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);
    slider8.addChangeListener(new SliderListener());

    widthPanel.setLayout(new GridLayout(1, 2));
    widthPanel.add(label4);
    widthPanel.add(slider8);
    getContentPane().add(widthPanel, BorderLayout.SOUTH);

    getContentPane().add(canvas);

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

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);//from ww w . j a v  a  2  s.com

    ListSelectionListener lis = new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.toString());
        }
    };

    m.addListSelectionListener(lis);
    m.removeListSelectionListener(lis);

    add(pane, BorderLayout.NORTH);
}

From source file:House.java

public House() {
    super(new BorderLayout());
    JPanel controlPanel = new JPanel(new GridLayout(3, 3));
    add(controlPanel, BorderLayout.NORTH);

    controlPanel.add(new JLabel("Translate(dx,dy): "));

    sliderTransX = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50);
    sliderTransY = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50);

    // To control rotation
    controlPanel.add(new JLabel("Rotate(Theta,ox,oy): "));
    sliderRotateTheta = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 360, 0, 90, 45);

    JPanel subPanel = new JPanel();
    subPanel.setLayout(new GridLayout(1, 2));

    sliderRotateX = setSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50);

    sliderRotateY = setSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50);
    controlPanel.add(subPanel);/*from   w ww .j a  va2s  .co m*/

    // To control scaling
    controlPanel.add(new JLabel("Scale(sx,sy)x10E-2:"));

    sliderScaleX = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);

    sliderScaleY = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);

    // To control width of line segments
    JLabel label4 = new JLabel("Width Control:", JLabel.RIGHT);
    sliderWidth = new JSlider(JSlider.HORIZONTAL, 0, 20, 1);
    sliderWidth.setPaintTicks(true);
    sliderWidth.setMajorTickSpacing(5);
    sliderWidth.setMinorTickSpacing(1);
    sliderWidth.setPaintLabels(true);
    sliderWidth.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            width = sliderWidth.getValue();
            canvas.repaint();
        }
    });
    JPanel widthPanel = new JPanel();
    widthPanel.setLayout(new GridLayout(1, 2));
    widthPanel.add(label4);
    widthPanel.add(sliderWidth);
    add(widthPanel, BorderLayout.SOUTH);

    canvas = new MyCanvas();
    add(canvas, "Center");
}

From source file:ImageLoader.java

public ImageLoader() {
    super("Image Loader");

    this.log = new JTextArea(4, 4);
    this.viewer = new JPanel();

    JButton start = new JButton("Start");
    start.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String[] files = new String[] { "Bodie_small.png", "Carmela_small.png", "Death Valley_small.png",
                    "Lake_small.png" };
            new ImageLoadingWorker(log, viewer, files).execute();
        }/* www . jav  a2 s.  c o  m*/
    });

    add(new JScrollPane(log), BorderLayout.NORTH);
    add(new JScrollPane(viewer), BorderLayout.CENTER);
    add(start, BorderLayout.SOUTH);

    setSize(360, 280);
}