Example usage for java.awt GridLayout GridLayout

List of usage examples for java.awt GridLayout GridLayout

Introduction

In this page you can find the example usage for java.awt GridLayout GridLayout.

Prototype

public GridLayout(int rows, int cols, int hgap, int vgap) 

Source Link

Document

Creates a grid layout with the specified number of rows and columns.

Usage

From source file:Main.java

public void makeUI() {
    String[] zones = { "Asia/Tokyo", "Asia/Hong_Kong", "Asia/Calcutta", "Europe/Paris", "Europe/London",
            "America/New_York", "America/Los_Angeles" };
    JLabel[] labels = new JLabel[zones.length];
    SimpleDateFormat[] formats = new SimpleDateFormat[zones.length];
    JFrame frame = new JFrame();

    Calendar cal = Calendar.getInstance();
    Date date = cal.getTime();//from  w  ww  .  j  a  va2 s. c o  m
    SpinnerDateModel model = new SpinnerDateModel();
    model.setValue(date);
    JSpinner spinner = new JSpinner(model);
    spinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            Date date = (Date) ((JSpinner) e.getSource()).getValue();
            for (int i = 0; i < labels.length; i++) {
                labels[i].setText(formats[i].format(date));
            }
        }
    });
    SimpleDateFormat format = ((JSpinner.DateEditor) spinner.getEditor()).getFormat();
    format.setTimeZone(TimeZone.getTimeZone(zones[0]));
    format.applyPattern("yyyy-MM-dd HH:mm:ss");
    JPanel 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].setTimeZone(TimeZone.getTimeZone(zones[i]));
        JLabel label = new JLabel(zones[i]);
        labels[i] = new JLabel(formats[i].format(date));
        panel.add(label);
        panel.add(labels[i]);
    }
    frame.setLayout(new BorderLayout());
    frame.add(spinner, BorderLayout.NORTH);
    frame.add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:jamel.gui.JamelWindow.java

/**
 * Returns the industry panel./*w  w  w .j  ava2 s  .c  o  m*/
 * @return the industry panel.
 */
private static Component getIndustryPanel() {
    final JPanel panel = new JPanel(new GridLayout(3, 3, 10, 10));
    panel.add(new BankruptcyRate());
    panel.add(new CapacityUtilization());
    panel.add(new Markup());
    panel.add(new InventoryLevel());
    panel.add(new RelativePrices());
    panel.add(new VacancyRates());
    panel.add(new Firms());
    panel.add(new Profits());
    panel.add(new Workers());
    //panel.add(new ProfitsRatio());
    //panel.add(new ChartPanel(null));
    //panel.add(new MarkupTarget());
    return panel;
}

From source file:ExposedInt.java

public void init() {

    Panel buttonPanel = new PanelWithInsets(0, 0, 0, 0);
    buttonPanel.setLayout(new GridLayout(3, 2, 5, 5));
    buttonPanel.add(new GrayButton(ExposedIntStringTable.increment));
    buttonPanel.add(new GrayButton(ExposedIntStringTable.decrement));
    buttonPanel.add(minimumButton);/*from  w  w  w . j  a  v a 2s  .c o  m*/
    buttonPanel.add(maximumButton);
    buttonPanel.add(zeroButton);
    buttonPanel.add(new GrayButton(ExposedIntStringTable.negate));
    zeroButton.disable();

    binaryField = new Label("00000000000000000000000000000000");
    hexField = new Label("00000000");
    decimalField = new Label("0");

    Font fieldFont = new Font("TimesRoman", Font.PLAIN, 12);
    binaryField.setFont(fieldFont);
    hexField.setFont(fieldFont);
    decimalField.setFont(fieldFont);

    Panel numberPanel = new Panel();
    numberPanel.setBackground(Color.white);
    numberPanel.setLayout(new GridLayout(3, 1));
    Panel binaryPanel = new Panel();
    binaryPanel.setLayout(new BorderLayout());
    binaryPanel.add("Center", binaryField);
    numberPanel.add(binaryPanel);

    Panel hexPanel = new Panel();
    hexPanel.setLayout(new BorderLayout());
    hexPanel.add("Center", hexField);
    numberPanel.add(hexPanel);
    numberPanel.add(decimalField);

    Panel labelPanel = new Panel();
    labelPanel.setBackground(Color.white);
    labelPanel.setLayout(new GridLayout(3, 1));
    Label label = new Label(ExposedIntStringTable.binary, Label.CENTER);
    Font labelFont = new Font("Helvetica", Font.ITALIC, 11);
    label.setFont(labelFont);
    labelPanel.add(label);
    label = new Label(ExposedIntStringTable.hex, Label.CENTER);
    label.setFont(labelFont);
    labelPanel.add(label);
    label = new Label(ExposedIntStringTable.decimal, Label.CENTER);
    label.setFont(labelFont);
    labelPanel.add(label);

    Panel dataPanel = new Panel();
    dataPanel.setLayout(new BorderLayout());
    dataPanel.add("West", labelPanel);
    dataPanel.add("Center", numberPanel);

    ColoredLabel title = new ColoredLabel(ExposedIntStringTable.title, Label.CENTER, Color.yellow);
    title.setFont(new Font("Helvetica", Font.BOLD, 12));

    setBackground(Color.red);
    setLayout(new BorderLayout(5, 5));
    add("North", title);
    add("West", buttonPanel);
    add("Center", dataPanel);
}

From source file:com.eviware.soapui.support.editor.inspectors.auth.ExpirationTimeChooser.java

ExpirationTimeChooser(OAuth2Profile profile) {
    this.profile = profile;
    setLayout(new BorderLayout(0, 0));
    initializeRadioButtons();//from   w  w  w  .ja v  a2 s  .  co  m
    JPanel timeSelectionPanel = createTimeSelectionPanel();
    JPanel northPanel = new JPanel(new GridLayout(3, 1, 0, 0));
    northPanel.add(serverExpirationTimeOption);
    northPanel.add(manualExpirationTimeOption);
    northPanel.add(timeSelectionPanel);
    add(northPanel, BorderLayout.NORTH);

    JPanel centerPanel = new JPanel(new BorderLayout(0, 0));
    JLabel label = new JLabel(
            "<html>Here you can set an expiry time if the OAuth 2 server doesn't,<br/>so that the token retrieval can be automated.</html>");
    label.setForeground(new Color(143, 143, 143));
    centerPanel.add(label, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);

    //      JLabel helpLink = UISupport.createLabelLink( "http://www.soapui.org", "Learn how to use the token expiration time " );
    //      add( helpLink, BorderLayout.SOUTH );
}

From source file:org.cytoscape.dyn.internal.graphMetrics.SaveChartDialog.java

public SaveChartDialog(JFrame frame, JFreeChart chart) {
    super(frame, "Save Chart to File", false);
    this.chart = chart;
    JPanel sizePanel = new JPanel(new GridLayout(2, 3, 4, 4));
    sizePanel.setBorder(BorderFactory.createTitledBorder("Image Size"));

    // Add a spinner for choosing width
    sizePanel.add(new JLabel("Width:", SwingConstants.RIGHT));
    int width = ChartPanel.DEFAULT_WIDTH;
    int minWidth = ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH;
    int maxWidth = ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH;
    SpinnerModel widthSettings = new SpinnerNumberModel(width, minWidth, maxWidth, 1);
    sizePanel.add(widthSpinner = new JSpinner(widthSettings));
    sizePanel.add(new JLabel("pixels"));

    // Add a spinner for choosing height
    sizePanel.add(new JLabel("Height:", SwingConstants.RIGHT));
    int height = ChartPanel.DEFAULT_HEIGHT;
    int minHeight = ChartPanel.DEFAULT_MINIMUM_DRAW_HEIGHT;
    int maxHeight = ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT;
    SpinnerModel heightSettings = new SpinnerNumberModel(height, minHeight, maxHeight, 1);
    sizePanel.add(heightSpinner = new JSpinner(heightSettings));
    sizePanel.add(new JLabel("pixels"));

    JPanel buttonsPanel = new JPanel(new GridLayout(1, 2, 4, 0));
    saveChartButton = new JButton("Save");
    saveChartButton.setMaximumSize(new Dimension(Short.MAX_VALUE, saveChartButton.getHeight()));
    saveChartButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.setMaximumSize(new Dimension(Short.MAX_VALUE, cancelButton.getHeight()));
    cancelButton.addActionListener(this);
    buttonsPanel.add(saveChartButton);//from ww w. j  a v a  2 s. c  o  m
    buttonsPanel.add(cancelButton);
    Box buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(Box.createHorizontalGlue());
    buttonsBox.add(buttonsPanel);
    buttonsBox.add(Box.createHorizontalGlue());

    Container contentPane = getContentPane();
    contentPane.add(sizePanel, BorderLayout.NORTH);
    contentPane.add(Box.createVerticalStrut(3));
    contentPane.add(buttonsBox, BorderLayout.PAGE_END);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    getRootPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
    pack();
    setModal(true);
    setResizable(false);
    setLocationRelativeTo(frame);

}

From source file:org.ash.history.TopActivityDetail.java

/**
 * Instantiates a new main frame./*from  w ww.java  2  s .co m*/
 * 
 */
public TopActivityDetail(JFrame mainFrame, ASHDatabaseH databaseHistory) {

    this.mainFrame = mainFrame;
    this.setLayout(new GridLayout(1, 1, 1, 1));
    this.mainPanel.setLayout(new BorderLayout());
    this.mainPanel.setVisible(true);

    this.databaseHistory = databaseHistory;

    this.add(this.mainPanel);
}

From source file:org.apache.commons.httpclient.contrib.proxy.PluginProxyTestApplet.java

@Override
public void init() {
    Container content = getContentPane();
    content.setLayout(new BorderLayout());

    // Proxy info table
    grid = getPanel(new GridLayout(2, 3, 2, 2));
    grid.add(getHeaderLabel("URL"));
    grid.add(getHeaderLabel("Proxy Host"));
    grid.add(getHeaderLabel("Proxy Port"));
    grid.add(urlTextField);//  w ww  .j  a va2s. c o m
    hostLabel = getLabel("");
    portLabel = getLabel("");
    grid.add(hostLabel);
    grid.add(portLabel);
    grid.validate();
    content.add(grid, BorderLayout.CENTER);

    // Button panel - SOUTH
    JPanel buttonPanel = getPanel(new FlowLayout());
    JButton button = new JButton("Detect Proxy");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    detectProxy();
                }
            });
        }
    });
    buttonPanel.add(button);
    content.add(buttonPanel, BorderLayout.SOUTH);

    // version panel - NORTH
    JPanel versionPanel = getPanel(new FlowLayout());
    String javaVersion = System.getProperty("java.runtime.version");
    JLabel versionLabel = getLabel("Java Version: " + javaVersion);
    versionPanel.add(versionLabel);
    content.add(versionPanel, BorderLayout.NORTH);
    validate();

    super.setSize(400, 100);
}

From source file:com.stefanbrenner.droplet.ui.AddDeviceDialog.java

public AddDeviceDialog(final JFrame frame, final IDropletContext dropletContext) {
    super(frame, dropletContext, Messages.getString("AddDeviceDialog.title")); //$NON-NLS-1$

    droplet = dropletContext.getDroplet();

    JPanel panel = new JPanel();

    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    panel.setLayout(new GridLayout(1, 0, 7, 7));

    btnValve = new JButton(Messages.getString("AddDeviceDialog.valve")); //$NON-NLS-1$
    btnValve.addActionListener(this);
    panel.add(btnValve);/*from   www .  j  a v  a2s. co  m*/
    btnFlash = new JButton(Messages.getString("AddDeviceDialog.flash")); //$NON-NLS-1$
    btnFlash.addActionListener(this);
    panel.add(btnFlash);
    btnCamera = new JButton(Messages.getString("AddDeviceDialog.camera")); //$NON-NLS-1$
    btnCamera.addActionListener(this);
    panel.add(btnCamera);
    btnButton = new JButton(Messages.getString("AddDeviceDialog.button")); //$NON-NLS-1$
    btnButton.addActionListener(this);
    panel.add(btnButton);
    btnClose = new JButton(Messages.getString("AddDeviceDialog.close")); //$NON-NLS-1$
    btnClose.addActionListener(this);
    panel.add(btnClose);

    add(panel);

    setAlwaysOnTop(true);
    setResizable(false);
    pack();
    setLocationRelativeTo(frame);

    droplet.addPropertyChangeListener(IDroplet.ASSOCIATION_DEVICES, new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            updateComponents();
        }
    });
    updateComponents();

}

From source file:jamel.gui.JamelWindow.java

/**
 * Returns the labor panel./* ww w .j a  v  a2s  .c o m*/
 * @return the labor panel.
 */
private static Component getLaborPanel() {
    final JPanel panel = new JPanel(new GridLayout(3, 3, 10, 10));
    panel.add(new LaborMarket());
    panel.add(new UnemploymentRate());
    panel.add(new BeveridgeCurve());
    panel.add(new JobVacancies());
    //panel.add(new UnemploymentTypes());
    panel.add(new UnemploymentDuration());
    panel.add(new JobSeekers());
    panel.add(new Unemployment());
    panel.add(new VacancyRate());
    panel.add(new ChartPanel(null));
    return panel;
}

From source file:gtu.xml.work.CacDBUI4Janna.java

private void initGUI() {
    try {/*from w  w  w  .jav a 2  s.  c  om*/
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                GridLayout jPanel1Layout = new GridLayout(10, 2, 5, 5);
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("\u8cc7\u6599\u8868\u540d\u7a31");
                }
                {
                    ComboBoxModel tableNameComboModel = new DefaultComboBoxModel(
                            new String[] { "cac_fcase", "cac_ecase", "cac_fcase_count" });
                    tableNameCombo = new JComboBox();
                    jPanel1.add(tableNameCombo);
                    tableNameCombo.setModel(tableNameComboModel);
                }
                {
                    jLabel2 = new JLabel();
                    jPanel1.add(jLabel2);
                    jLabel2.setText("xml\u6a94\u6848\u4f86\u6e90");
                }
                {
                    srcFileText = new JTextField();
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(srcFileText, false);
                    jPanel1.add(srcFileText);
                }
                {
                    jLabel3 = new JLabel();
                    jPanel1.add(jLabel3);
                    jLabel3.setText("\u7522\u751fsql\u6a94\u540d");
                }
                {
                    destFileNameText = new JTextField();
                    jPanel1.add(destFileNameText);
                }
                {
                    jLabel4 = new JLabel();
                    jPanel1.add(jLabel4);
                    jLabel4.setText("dmv\u6b04\u4f4d\u503c");
                }
                {
                    dmvText = new JTextField();
                    jPanel1.add(dmvText);
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u57f7\u884c");
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnActionPerformed(evt);
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(541, 361);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}