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

public EventTracerFrame() {
    setTitle("EventTracerTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    // add a slider and a button
    add(new JSlider(), BorderLayout.NORTH);
    add(new JButton("Test"), BorderLayout.SOUTH);

    // trap all events of components inside the frame
    EventTracer tracer = new EventTracer();
    tracer.add(this);
}

From source file:com.thoughtworks.go.agent.bootstrapper.osx.MacPreferencesPane.java

public MacPreferencesPane(final AgentMacWindow agentMacWindow) {
    super();//from w  w w .j  a  va 2  s  .c om

    getContentPane().setLayout(new BorderLayout(10, 10));
    JLabel prefsText = new JLabel("Go Server Hostname or IP");

    serverTextField = new JTextField("");
    serverTextField.setColumns(15);
    serverTextField.selectAll();

    JPanel textPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));
    textPanel.add(prefsText);
    textPanel.add(serverTextField);

    getContentPane().add(textPanel, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));

    JButton okButton = new JButton("OK");
    buttonPanel.add(okButton);
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent newEvent) {
            String newHost = serverTextField.getText();
            if (!originalHost.equals(newHost)) {
                LOG.info("Server changed to " + newHost);
                agentMacWindow.setHost(newHost);
            } else {
                LOG.info("Server is still " + originalHost);
            }

            setVisible(false);
        }
    });
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    setSize(getPreferredSize());
    setLocation(20, 40);
    setResizable(false);
}

From source file:DatabaseTest.java

public DatabaseTest() {
    super("Database Test Frame");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(350, 200);/*from   w w w. j av  a2 s.co  m*/

    qtm = new QueryTableModel();
    JTable table = new JTable(qtm);
    JScrollPane scrollpane = new JScrollPane(table);
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(3, 2));
    p1.add(new JLabel("Enter the Host URL: "));
    p1.add(hostField = new JTextField());
    p1.add(new JLabel("Enter your query: "));
    p1.add(queryField = new JTextField());
    p1.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());
        }
    });
    p1.add(jb);
    getContentPane().add(p1, BorderLayout.NORTH);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
}

From source file:ButtonScroll.java

public ButtonScroll() {
    super("Scrolling Programmatically");
    setSize(400, 400);//w w w . jav a 2 s. c  o 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:com.idealista.solrmeter.view.component.TablePropertyPanel.java

public TablePropertyPanel(String text, String property, boolean editable, PropertyChangeListener listener) {
    super(text, property, editable, listener);

    this.table = new PropertiesTable(new InnerTableListener(this), new HashMap<String, String>());
    this.table.setSorted(false);

    this.pane = new JPanel();

    JTableHeader header = this.table.getTableHeader();
    pane.setLayout(new BorderLayout());
    this.pane.add(header, BorderLayout.NORTH);
    this.pane.add(this.table, BorderLayout.CENTER);

    this.initGUI(text);
}

From source file:Main.java

public Main() {
    Calendar cal = Calendar.getInstance();
    Date date = cal.getTime();/*from ww  w .ja va  2  s .  c o  m*/
    model.setValue(date);
    spinner = new JSpinner(model);
    spinner.addChangeListener(e -> {
        Date d = (Date) ((JSpinner) e.getSource()).getValue();
        for (int i = 0; i < labels.length; i++) {
            labels[i].setText(formats[i].format(d));
        }
    });
    format = ((JSpinner.DateEditor) spinner.getEditor()).getFormat();
    format.setTimeZone(TimeZone.getTimeZone(zones[0]));
    format.applyPattern("yyyy-MM-dd HH:mm:ss");
    format.applyPattern("HH:mm:ss");
    panel = new JPanel(new GridLayout(zones.length, 2, 10, 10));
    for (int i = 0; i < zones.length; i++) {
        formats[i] = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
        formats[i] = new SimpleDateFormat("HH:mm:ss");
        formats[i].setTimeZone(TimeZone.getTimeZone(zones[i]));
        JLabel label = new JLabel(zones[i]);
        labels[i] = new JLabel(formats[i].format(date));
        labels[i].setHorizontalAlignment(JLabel.RIGHT);
        panel.add(label);
        panel.add(labels[i]);
    }
    frame.setLayout(new BorderLayout(10, 10));
    frame.add(spinner, BorderLayout.NORTH);
    frame.add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:de.codesourcery.geoip.Main.java

public static void main(String[] args) throws Exception {
    final IGeoLocator<StringSubject> locator = createGeoLocator();

    final JFrame frame = new JFrame("GeoIP");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent e) {
            try {
                locator.dispose();/*from   ww  w.  java  2s  .c  o  m*/
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        };
    });

    final MapImage image = MapImage.getRobinsonWorldMap(); // MapImage.getMillerWorldMap();      
    final MapCanvas canvas = new MapCanvas(image);

    for (GeoLocation<StringSubject> loc : locator.locate(getSpammers())) {
        if (loc.hasValidCoordinates()) {
            canvas.addCoordinate(PointRenderer.createPoint(loc, Color.YELLOW));
        }
    }

    //      canvas.addCoordinate( PointRenderer.createPoint( ZERO , Color.YELLOW ) );
    //      canvas.addCoordinate( PointRenderer.createPoint( WELLINGTON , Color.RED ) );
    //      canvas.addCoordinate( PointRenderer.createPoint( MELBOURNE , Color.RED ) );
    //      canvas.addCoordinate( PointRenderer.createPoint( HAMBURG , Color.RED ) );

    final double heightToWidth = image.height() / (double) image.width(); // preserve aspect ratio of map
    canvas.setPreferredSize(new Dimension(640, (int) Math.round(640 * heightToWidth)));

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    panel.add(new JLabel("Scale-X"));
    final JTextField scaleX = new JTextField(Double.toString(image.getScaleX()));
    scaleX.setColumns(5);

    final JTextField scaleY = new JTextField(Double.toString(image.getScaleY()));
    scaleY.setColumns(5);

    final ActionListener listener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            double x = Double.parseDouble(scaleX.getText());
            double y = Double.parseDouble(scaleY.getText());
            image.setScale(x, y);
            canvas.repaint();
        }
    };
    scaleX.addActionListener(listener);
    scaleY.addActionListener(listener);

    panel.add(new JLabel("Scale-X"));
    panel.add(scaleX);

    panel.add(new JLabel("Scale-Y"));
    panel.add(scaleY);

    final JTextField ipAddress = new JTextField("www.kickstarter.com");
    ipAddress.setColumns(20);

    final ActionListener ipListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final String destinationIP = ipAddress.getText();
            if (StringUtils.isBlank(destinationIP)) {
                return;
            }

            /*
             * Perform traceroute.
             */
            final List<String> hops;
            try {
                if (TracePath.isPathTracingAvailable()) {
                    hops = TracePath.trace(destinationIP);
                } else {
                    System.err.println("tracepath not available.");
                    if (TracePath.isValidAddress(destinationIP)) {
                        hops = new ArrayList<>();
                        hops.add(destinationIP);
                    } else {
                        System.err.println(destinationIP + " is no valid IP");
                        return;
                    }
                }
            } catch (Exception ex) {
                System.err.println("Failed to trace " + destinationIP);
                ex.printStackTrace();
                return;
            }

            System.out.println("Trace contains " + hops.size() + " IPs");

            /*
             * Gather locations.
             */
            final List<StringSubject> subjects = new ArrayList<>();
            for (String ip : hops) {
                subjects.add(new StringSubject(ip));
            }

            final List<GeoLocation<StringSubject>> locations;
            try {
                long time = -System.currentTimeMillis();
                locations = locator.locate(subjects);
                time += System.currentTimeMillis();

                System.out.println("Locating hops for " + destinationIP + " returned " + locations.size()
                        + " valid locations ( time: " + time + " ms)");
                System.out.flush();

            } catch (Exception e2) {
                e2.printStackTrace();
                return;
            }

            /*
             * Weed-out invalid/unknown locations.
             */
            {
                GeoLocation<StringSubject> previous = null;
                for (Iterator<GeoLocation<StringSubject>> it = locations.iterator(); it.hasNext();) {
                    final GeoLocation<StringSubject> location = it.next();
                    if (!location.hasValidCoordinates()
                            || (previous != null && previous.coordinate().equals(location.coordinate()))) {
                        it.remove();
                        System.err.println("Ignoring invalid/duplicate location for " + location);
                    } else {
                        previous = location;
                    }
                }
            }

            /*
             * Populate chart.
             */

            System.out.println("Adding " + locations.size() + " hops to chart");
            System.out.flush();

            canvas.removeAllCoordinates();

            if (locations.size() == 1) {
                canvas.addCoordinate(
                        PointRenderer.createPoint(locations.get(0), getLabel(locations.get(0)), Color.BLACK));
            } else if (locations.size() > 1) {
                GeoLocation<StringSubject> previous = locations.get(0);
                MapPoint previousPoint = PointRenderer.createPoint(previous, getLabel(previous), Color.BLACK);
                final int len = locations.size();
                for (int i = 1; i < len; i++) {
                    final GeoLocation<StringSubject> current = locations.get(i);
                    //                  final MapPoint currentPoint = PointRenderer.createPoint( current , getLabel( current ) , Color.BLACK );
                    final MapPoint currentPoint = PointRenderer.createPoint(current, Color.BLACK);

                    //                  canvas.addCoordinate( LineRenderer.createLine( previousPoint , currentPoint , Color.RED ) );
                    canvas.addCoordinate(CurvedLineRenderer.createLine(previousPoint, currentPoint, Color.RED));

                    previous = locations.get(i);
                    previousPoint = currentPoint;
                }
            }
            System.out.println("Finished adding");
            System.out.flush();
            canvas.repaint();
        }
    };
    ipAddress.addActionListener(ipListener);

    panel.add(new JLabel("IP"));
    panel.add(ipAddress);

    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(panel, BorderLayout.NORTH);
    frame.getContentPane().add(canvas, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}

From source file:Demo.LineGraph.java

public LineGraph(int sampleNb) {
    this.sampleNb = sampleNb;

    InitDataSet();//from   w w w .ja v a2  s  .  c  o m
    InitChart();

    // layout
    setLayout(new BorderLayout());

    add(Box.createHorizontalStrut(30), BorderLayout.WEST);
    add(Box.createHorizontalStrut(30), BorderLayout.EAST);
    add(Box.createVerticalStrut(30), BorderLayout.NORTH);
    add(chartPane, BorderLayout.CENTER);
}

From source file:org.fhaes.fhfilechecker.FrameViewHelp.java

private void jbInit() throws Exception {
    panel1.setLayout(borderLayout);/*from  w  ww  .j a va  2 s  .  c o m*/
    this.setTitle("FHAES File Format Report (Outputfile)");
    setIconImage(Builder.getApplicationIcon());
    btnPrint.setText("Print");
    btnPrint.addActionListener(new Frame_HelpView_btnPrint_actionAdapter(this));
    btnClose.setText("Close");
    btnClose.addActionListener(new Frame_HelpView_btnClose_actionAdapter(this));
    TArea.setText("");
    this.addWindowListener(new Frame_HelpView_this_windowAdapter(this));
    getContentPane().add(panel1);
    jPanel.add(btnPrint);
    jPanel.add(btnClose);
    panel1.add(jPanel, java.awt.BorderLayout.NORTH);
    panel1.add(jScrollPane, java.awt.BorderLayout.CENTER);
    // panel1.add(mygraph, java.awt.BorderLayout.SOUTH);
    jScrollPane.getViewport().add(TArea);
    // System.out.println(jScrollPane.getVerticalScrollBar().getMinimum());
}

From source file:SwingWorkerProcessor.java

public SwingWorkerFrame() {
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container contentPane = this.getContentPane();
    cancelButton.setEnabled(false);/* ww w  . j a  v a 2 s  .com*/

    contentPane.add(statusLabel, BorderLayout.NORTH);
    contentPane.add(startButton, BorderLayout.WEST);
    contentPane.add(cancelButton, BorderLayout.EAST);

    startButton.addActionListener(e -> startProcessing());
    cancelButton.addActionListener(e -> cancelProcessing());
}