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(int hgap, int vgap) 

Source Link

Document

Constructs a border layout with the specified gaps between components.

Usage

From source file:EditorPaneExample1.java

public EditorPaneExample1() {
    super("JEditorPane Example 1");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(4, 4));
    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, "West");
    textField = new JTextField(32);
    panel.add(textField, "Center");

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();
            try {
                // Try to display the page
                pane.setPage(url);//from w  ww .  j av  a 2  s .com
            } catch (IOException e) {
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
}

From source file:analisisnumerico.Graficador.java

public Graficador(Funcion F, double lower, double upper) {
    //super("Graficador");
    JFrame f = new JFrame("Grafica");
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setLayout(new BorderLayout(0, 5));

    XYDataset paresDeDatos = generarDatos(F, lower, upper);
    JFreeChart diagrama = crearDiagrama(paresDeDatos);
    ChartPanel chartPanel = new ChartPanel(diagrama);
    chartPanel.setPreferredSize(new Dimension(500, 400));
    //setContentPane(chartPanel);
    f.add(chartPanel, BorderLayout.CENTER);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setHorizontalAxisTrace(true);
    chartPanel.setVerticalAxisTrace(true);
    f.pack();/*from  w  ww  . ja va2  s . c  om*/
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:Main.java

public Main() {
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(new JButton("Foo"));
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(new JButton("Bar"));

    String[] columnNames = { "Mon", "Tues", "Wed" };
    DefaultTableModel model = new DefaultTableModel(columnNames, 25);
    JTable table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setPreferredSize(table.getPreferredSize());

    JLabel southLabel = new JLabel("OK!");
    southLabel.setForeground(Color.white);
    JPanel southPanel = new JPanel();
    southPanel.add(southLabel);//w ww .  ja  va 2s  .  c  om

    setLayout(new BorderLayout(5, 5));
    add(buttonPanel, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(southPanel, BorderLayout.SOUTH);
}

From source file:UserInterface.FarmerRole.HumidityGraph.java

public HumidityGraph(double value, String type) {

    data = new DefaultValueDataset(value);
    final JFrame frame = new JFrame();
    meterPlot = new MeterPlot(data);
    frame.getContentPane().setLayout(new BorderLayout(5, 5));
    frame.setDefaultCloseOperation(3);//w  w w.  jav  a 2 s . co m
    frame.setTitle("Inventory Humidity");
    meterChart = new JFreeChart("Humidity Chart", JFreeChart.DEFAULT_TITLE_FONT, this.meterPlot, false);
    panelMeter = new ChartPanel(this.meterChart);
    frame.getContentPane().add(panelMeter, BorderLayout.CENTER);
    frame.setSize(700, 400);
    final Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
    frame.setVisible(true);

}

From source file:cool.pandora.modeller.ui.jpanel.base.ProfilesView.java

@Override
protected JComponent createControl() {
    final JPanel bagViewPanel = new JPanel(new BorderLayout(2, 2));
    final InfoFormsPane infoPanel = ApplicationContextUtil.getBagView().infoInputPane;
    bagViewPanel.add(infoPanel);/*ww  w  . jav  a 2  s . c  o  m*/
    return bagViewPanel;
}

From source file:com.game.ui.views.UserDialog.java

public UserDialog(String message, JFrame frame) {
    setLayout(new BorderLayout(5, 5));
    setModalityType(ModalityType.APPLICATION_MODAL);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setResizable(false);/*from   w  w w  .  j  ava2s.  co m*/
    ImageIcon icon = null;
    try {
        icon = GameUtils.shrinkImage("warning.gif", 30, 30);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JPanel panel = new JPanel();
    JLabel label = new JLabel(icon);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    label.setText(message);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    label.setHorizontalAlignment(0);
    panel.add(label);
    add(panel, BorderLayout.NORTH);
    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
    txt = new JTextField();
    txt.setPreferredSize(new Dimension(150, 30));
    txt.setAlignmentX(.5f);
    txt.setMaximumSize(new Dimension(150, 30));
    contentPanel.add(txt);
    contentPanel.add(Box.createVerticalStrut(10));
    JButton btn = new JButton("Submit.");
    btn.setAlignmentX(.5f);
    btn.setPreferredSize(new Dimension(50, 25));
    btn.addActionListener(this);
    validationMess = new JLabel("All fields are mandatory");
    validationMess.setVisible(false);
    validationMess.setForeground(Color.red);
    validationMess.setAlignmentX(.5f);
    contentPanel.add(btn);
    contentPanel.add(Box.createVerticalStrut(10));
    contentPanel.add(validationMess);
    contentPanel.add(Box.createVerticalGlue());
    add(contentPanel, BorderLayout.CENTER);
    pack();
    setSize(new Dimension(300, 200));
    setLocationRelativeTo(frame);
    setVisible(true);
}

From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.panels.Server.java

public Server() {

    setLayout(new BorderLayout(0, 0));
    JTabbedPane serverFunctions = new JTabbedPane(JTabbedPane.LEFT);

    serverFunctions.setBackground(Color.WHITE);
    this.setBackground(Color.WHITE);
    serverFunctions.addTab("Display", null, null, null);
    serverFunctions.addTab("File Manager", null, null, null);
    serverFunctions.addTab("Console", null, null, null);

    add(serverFunctions, BorderLayout.CENTER);

}

From source file:org.onesun.sdi.swing.app.views.dialogs.ChartDialog.java

public ChartDialog(Frame parent, JFreeChart moodChart, JFreeChart sentimentChart) {
    super(parent, true);

    this.parent = parent;

    this.setLayout(new BorderLayout(5, 5));

    setTitle("Chart");
    setSize(350, 225);/*from   www .ja  v  a  2s. c o  m*/
    setResizable(false);
    setVisible(false);

    JPanel chartPanel = new JPanel(new GridLayout(1, 2));

    chartPanel.add(new ChartPanel(moodChart));
    chartPanel.add(new ChartPanel(sentimentChart));

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 15));
    panel.add(okButton);

    this.add(chartPanel, BorderLayout.CENTER);
    this.add(panel, BorderLayout.SOUTH);

    UserActionListener userActionListener = new UserActionListener();
    okButton.addActionListener(userActionListener);
}

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

public MacPreferencesPane(final AgentMacWindow agentMacWindow) {
    super();/* w  w  w . ja va2s  . 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:Main.java

public ConfirmDialog(Frame parent) {
    super(parent, true);

    JPanel gui = new JPanel(new BorderLayout(3, 3));
    gui.setBorder(new EmptyBorder(5, 5, 5, 5));
    content = new JPanel(new BorderLayout());
    gui.add(content, BorderLayout.CENTER);
    JPanel buttons = new JPanel(new FlowLayout(4));
    gui.add(buttons, BorderLayout.SOUTH);

    JButton ok = new JButton("OK");
    buttons.add(ok);/*from   w  w w .  j  a v a  2 s.  c o  m*/
    ok.addActionListener(e -> {
        result = OK_OPTION;
        setVisible(false);
    });

    JButton cancel = new JButton("Cancel");
    buttons.add(cancel);
    cancel.addActionListener(e -> {
        result = CANCEL_OPTION;
        setVisible(false);
    });
    setContentPane(gui);
}