Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

To view the source code for java.awt GridBagConstraints BOTH.

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:ElectionGUI.java

/**
 * This method is called from within the constructor to initialize the
 * form. WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */// ww  w .  jav  a 2s  . c o  m
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    plotAreaSTV = new javax.swing.JPanel();
    plotAreaGCC = new javax.swing.JPanel();
    plotAreaGM = new javax.swing.JPanel();
    plotAreaKM = new javax.swing.JPanel();
    menuPanel = new javax.swing.JPanel();
    mainTitle = new javax.swing.JLabel();
    nLabel = new javax.swing.JLabel();
    mLabel = new javax.swing.JLabel();
    kLabel = new javax.swing.JLabel();
    nTxtField = new javax.swing.JTextField();
    mTxtField = new javax.swing.JTextField();
    kTxtField = new javax.swing.JTextField();
    nClusterTitle = new javax.swing.JLabel();
    nClusterLabel = new javax.swing.JLabel();
    nClusterTxtField = new javax.swing.JTextField();
    mClusterTitle = new javax.swing.JLabel();
    mClusterLabel = new javax.swing.JLabel();
    mClusterTxtField = new javax.swing.JTextField();
    createElectionBtn = new javax.swing.JButton();
    saveElectionBtn = new javax.swing.JButton();
    loadElectionBtn = new javax.swing.JButton();
    plotResultsBtn = new javax.swing.JButton();
    xLimitLabel = new javax.swing.JLabel();
    xLimitTxtField = new javax.swing.JTextField();
    yLimitLabel = new javax.swing.JLabel();
    yLimitTxtField = new javax.swing.JTextField();
    generalPreferencesCheckBox = new javax.swing.JCheckBox();
    consistencyBtn = new javax.swing.JButton();
    plotAreaSNTV = new javax.swing.JPanel();
    plotAreaBorda = new javax.swing.JPanel();
    plotAreaBloc = new javax.swing.JPanel();
    systemPanel = new javax.swing.JPanel();
    systemPane = new javax.swing.JScrollPane();
    systemTxt = new javax.swing.JTextArea();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Committee Elections v0.9");
    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("images/elections.png")));
    setMinimumSize(new java.awt.Dimension(1280, 720));
    setResizable(false);
    java.awt.GridBagLayout layout = new java.awt.GridBagLayout();
    layout.columnWidths = new int[] { 270, 270, 270, 270 };
    layout.rowHeights = new int[] { 270, 270, 140 };
    getContentPane().setLayout(layout);

    plotAreaSTV.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaSTV.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaSTV.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaSTV.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaSTVLayout = new javax.swing.GroupLayout(plotAreaSTV);
    plotAreaSTV.setLayout(plotAreaSTVLayout);
    plotAreaSTVLayout.setHorizontalGroup(plotAreaSTVLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaSTVLayout.setVerticalGroup(plotAreaSTVLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaSTV, gridBagConstraints);

    plotAreaGCC.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaGCC.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaGCC.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaGCC.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaGCCLayout = new javax.swing.GroupLayout(plotAreaGCC);
    plotAreaGCC.setLayout(plotAreaGCCLayout);
    plotAreaGCCLayout.setHorizontalGroup(plotAreaGCCLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaGCCLayout.setVerticalGroup(plotAreaGCCLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaGCC, gridBagConstraints);

    plotAreaGM.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaGM.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaGM.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaGM.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaGMLayout = new javax.swing.GroupLayout(plotAreaGM);
    plotAreaGM.setLayout(plotAreaGMLayout);
    plotAreaGMLayout.setHorizontalGroup(plotAreaGMLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaGMLayout.setVerticalGroup(plotAreaGMLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaGM, gridBagConstraints);

    plotAreaKM.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaKM.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaKM.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaKM.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaKMLayout = new javax.swing.GroupLayout(plotAreaKM);
    plotAreaKM.setLayout(plotAreaKMLayout);
    plotAreaKMLayout.setHorizontalGroup(plotAreaKMLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaKMLayout.setVerticalGroup(plotAreaKMLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaKM, gridBagConstraints);

    menuPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    menuPanel.setMaximumSize(new java.awt.Dimension(270, 410));
    menuPanel.setMinimumSize(new java.awt.Dimension(270, 410));
    menuPanel.setPreferredSize(new java.awt.Dimension(270, 410));
    java.awt.GridBagLayout menuPanelLayout = new java.awt.GridBagLayout();
    menuPanelLayout.columnWidths = new int[] { 10, 35, 45, 45, 45, 45, 35, 10 };
    menuPanelLayout.rowHeights = new int[] { 40, 20, 20, 20, 5, 20, 20, 30, 20, 30, 20, 20, 40, 40, 10, 30 };
    menuPanel.setLayout(menuPanelLayout);

    mainTitle.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    mainTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    mainTitle.setText("Create a 2D Committee Election");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 8;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(mainTitle, gridBagConstraints);

    nLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    nLabel.setText("Number of Voters: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(nLabel, gridBagConstraints);

    mLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    mLabel.setText("Number of Candidates: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(mLabel, gridBagConstraints);

    kLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    kLabel.setText("Committee Size: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(kLabel, gridBagConstraints);

    nTxtField.setText("300");
    nTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            nTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(nTxtField, gridBagConstraints);

    mTxtField.setText("100");
    mTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            mTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(mTxtField, gridBagConstraints);

    kTxtField.setText("10");
    kTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            kTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(kTxtField, gridBagConstraints);

    nClusterTitle.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    nClusterTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    nClusterTitle.setText("Voter Distribution");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.gridwidth = 8;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(nClusterTitle, gridBagConstraints);

    nClusterLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    nClusterLabel.setText("Number of Voter Clusters: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(nClusterLabel, gridBagConstraints);

    nClusterTxtField.setText("1");
    nClusterTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            nClusterTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(nClusterTxtField, gridBagConstraints);

    mClusterTitle.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    mClusterTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    mClusterTitle.setText("Candidate Distribution");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 9;
    gridBagConstraints.gridwidth = 8;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(mClusterTitle, gridBagConstraints);

    mClusterLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    mClusterLabel.setText("Number of Candidate Clusters: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(mClusterLabel, gridBagConstraints);

    mClusterTxtField.setText("1");
    mClusterTxtField.setMaximumSize(new java.awt.Dimension(50, 20));
    mClusterTxtField.setMinimumSize(new java.awt.Dimension(50, 20));
    mClusterTxtField.setPreferredSize(new java.awt.Dimension(50, 20));
    mClusterTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            mClusterTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 10;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(mClusterTxtField, gridBagConstraints);

    createElectionBtn.setText("Create Election");
    createElectionBtn.setMaximumSize(new java.awt.Dimension(110, 23));
    createElectionBtn.setMinimumSize(new java.awt.Dimension(110, 23));
    createElectionBtn.setPreferredSize(new java.awt.Dimension(110, 23));
    createElectionBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            createElectionBtnActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 12;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(createElectionBtn, gridBagConstraints);

    saveElectionBtn.setText("Save Election");
    saveElectionBtn.setEnabled(false);
    saveElectionBtn.setMaximumSize(new java.awt.Dimension(110, 23));
    saveElectionBtn.setMinimumSize(new java.awt.Dimension(110, 23));
    saveElectionBtn.setPreferredSize(new java.awt.Dimension(110, 23));
    saveElectionBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveElectionBtnActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 12;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(saveElectionBtn, gridBagConstraints);

    loadElectionBtn.setText("Load Election");
    loadElectionBtn.setMaximumSize(new java.awt.Dimension(110, 23));
    loadElectionBtn.setMinimumSize(new java.awt.Dimension(110, 23));
    loadElectionBtn.setPreferredSize(new java.awt.Dimension(110, 23));
    loadElectionBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadElectionBtnActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 13;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(loadElectionBtn, gridBagConstraints);

    plotResultsBtn.setText("Plot Results");
    plotResultsBtn.setEnabled(false);
    plotResultsBtn.setMaximumSize(new java.awt.Dimension(110, 23));
    plotResultsBtn.setMinimumSize(new java.awt.Dimension(110, 23));
    plotResultsBtn.setPreferredSize(new java.awt.Dimension(110, 23));
    plotResultsBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            plotResultsBtnActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 13;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(plotResultsBtn, gridBagConstraints);

    xLimitLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    xLimitLabel.setText("x-Axis bound: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(xLimitLabel, gridBagConstraints);

    xLimitTxtField.setText("3");
    xLimitTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            xLimitTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(xLimitTxtField, gridBagConstraints);

    yLimitLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    yLimitLabel.setText("y-Axis bound: ");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(yLimitLabel, gridBagConstraints);

    yLimitTxtField.setText("3");
    yLimitTxtField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusGained(java.awt.event.FocusEvent evt) {
            yLimitTxtFieldFocusGained(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 5;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(yLimitTxtField, gridBagConstraints);

    generalPreferencesCheckBox.setText("General Preferences");
    generalPreferencesCheckBox.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    generalPreferencesCheckBox.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
    generalPreferencesCheckBox.setMaximumSize(new java.awt.Dimension(1203, 230));
    generalPreferencesCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            generalPreferencesCheckBoxActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 15;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(generalPreferencesCheckBox, gridBagConstraints);

    consistencyBtn.setText("Consistency Check");
    consistencyBtn.setEnabled(false);
    consistencyBtn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            consistencyBtnActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 15;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    menuPanel.add(consistencyBtn, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(menuPanel, gridBagConstraints);

    plotAreaSNTV.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaSNTV.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaSNTV.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaSNTV.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaSNTVLayout = new javax.swing.GroupLayout(plotAreaSNTV);
    plotAreaSNTV.setLayout(plotAreaSNTVLayout);
    plotAreaSNTVLayout.setHorizontalGroup(plotAreaSNTVLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaSNTVLayout.setVerticalGroup(plotAreaSNTVLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaSNTV, gridBagConstraints);

    plotAreaBorda.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaBorda.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaBorda.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaBorda.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaBordaLayout = new javax.swing.GroupLayout(plotAreaBorda);
    plotAreaBorda.setLayout(plotAreaBordaLayout);
    plotAreaBordaLayout.setHorizontalGroup(plotAreaBordaLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaBordaLayout.setVerticalGroup(plotAreaBordaLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaBorda, gridBagConstraints);

    plotAreaBloc.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    plotAreaBloc.setMaximumSize(new java.awt.Dimension(300, 300));
    plotAreaBloc.setMinimumSize(new java.awt.Dimension(300, 300));
    plotAreaBloc.setPreferredSize(new java.awt.Dimension(300, 300));

    javax.swing.GroupLayout plotAreaBlocLayout = new javax.swing.GroupLayout(plotAreaBloc);
    plotAreaBloc.setLayout(plotAreaBlocLayout);
    plotAreaBlocLayout.setHorizontalGroup(plotAreaBlocLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));
    plotAreaBlocLayout.setVerticalGroup(plotAreaBlocLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 296, Short.MAX_VALUE));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(plotAreaBloc, gridBagConstraints);

    systemPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    systemPanel.setLayout(new java.awt.BorderLayout());

    systemTxt.setEditable(false);
    systemTxt.setColumns(20);
    systemTxt.setFont(new java.awt.Font("Lucida Console", 0, 12)); // NOI18N
    systemTxt.setRows(5);
    systemPane.setViewportView(systemTxt);

    systemPanel.add(systemPane, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    getContentPane().add(systemPanel, gridBagConstraints);

    pack();
}

From source file:org.gridchem.client.gui.charts.UsageChart.java

private void init(CollaboratorBean collab) {

    removeAll();//from   w  w w  . j  a  v a  2  s . c o m

    // TODO: Add title and footer with expiration date to chart
    String title = "";
    ProjectBean project = projectCollabTable.keySet().iterator().next();
    //        
    if (CURRENT_CHARTTYPE.equals(ChartType.JOB)) {
        //          dataset = createJobDataset(project);
        dataset = new DefaultPieDataset();
    } else if (CURRENT_CHARTTYPE.equals(ChartType.PROJECT)) {
        dataset = createProjectDataset(projectCollabTable, collab);
        title = "Overall Utilization of Project " + project.getName() + " by " + collab.getFirstName() + " "
                + collab.getLastName();
        ;
    } else if (CURRENT_CHARTTYPE.equals(ChartType.RESOURCE)) {
        dataset = createResourceDataset(projectCollabTable, collab);
        title = "CCG Resource Utilization for Project " + project.getName() + " by " + collab.getFirstName()
                + " " + collab.getLastName();
        ;
    } else if (CURRENT_CHARTTYPE.equals(ChartType.USER)) {
        dataset = createUserDataset(projectCollabTable, collab);
        title = "User Utilization of Project " + project.getName() + " by " + collab.getFirstName() + " "
                + collab.getLastName();
    }

    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

    chart.addSubtitle(new TextTitle("Project " + project.getName() + " expires on " + project.getEndDate()));

    if (CURRENT_CHARTTYPE.equals(ChartType.JOB)) {
        chart.getPlot().setNoDataMessage("Comprehensive job information is not currently available.");
    }

    ((PiePlot) chart.getPlot()).setCircular(true);

    //        ((PiePlot)chart.getPlot()).setToolTipGenerator(new PieToolTipGenerator() {
    //
    //            public String generateToolTip(PieDataset ds, Comparable arg1) {
    //                // TODO Auto-generated method stub
    //                return ";
    //            }
    //            
    //        });

    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(size);

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;
    add(chartPanel, c);

    GridBagConstraints c1 = new GridBagConstraints();
    c1.weightx = 0;
    c1.weighty = 0;
    c1.gridx = 0;
    c1.gridy = 1;
    c1.fill = GridBagConstraints.BOTH;
    add(navPanel, c1);
    revalidate();
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

/**
 * Constructs the dialog itself.// w ww.j a  v  a 2s  .co  m
 */
protected void constructDialog(Container parent) {
    // Add the 
    //  [ img ] | [ license ]
    createTopOfWindow(parent);

    GridBagConstraints c = new GridBagConstraints();

    // Add a -----------
    // line below img & license
    JComponent line = new Line(ThemeFileHandler.TABLE_BACKGROUND_COLOR.getValue());
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(0, 0, 2, 0);
    parent.add(line, c);

    // Create the details panel.
    buildDetails();

    // Add the details panel.
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(4, 4, 0, 4);
    c.weighty = 1;
    c.weightx = 1;
    parent.add(DETAILS, c);

    // Add a ------------
    // line below the details.
    line = new Line(ThemeFileHandler.TABLE_BACKGROUND_COLOR.getValue());
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = GridBagConstraints.RELATIVE;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(2, 0, 2, 0);
    c.ipady = 0;
    c.weighty = 0;
    c.weightx = 0;
    parent.add(line, c);

    // Add an OK button out of the window.
    JButton button = new JButton(GUIMediator.getStringResource("GENERAL_OK_BUTTON_LABEL"));
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            LicenseWindow.this.dispose();
            LicenseWindow.this.setVisible(false);
        }
    });
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(0, 0, 4, 4);
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    parent.add(button, c);

    pack();
}

From source file:de.codesourcery.jasm16.ide.ui.views.WorkspaceExplorer.java

private JPanel createPanel() {
    treeModel = createTreeModel();//w w  w .  j  a va 2  s .  c o  m
    tree.setModel(treeModel);
    setColors(tree);
    tree.setRootVisible(false);

    //      for (int i = 0; i < tree.getRowCount(); i++) {
    //         tree.expandRow(i);
    //      }

    tree.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                final WorkspaceTreeNode selection = getSelectedNode();
                if (selection != null) {
                    deleteResource(selection);
                }
            } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                refreshWorkspace(null);
            }
        }
    });

    tree.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                final TreePath path = tree.getPathForLocation(e.getX(), e.getY());
                if (path != null) {
                    final WorkspaceTreeNode selected = (WorkspaceTreeNode) path.getLastPathComponent();
                    final IAssemblyProject project = getProject(selected);
                    try {
                        if (project != null) {
                            onTreeNodeLeftClick(project, selected);
                        } else {
                            System.err.println("Unable to locate project for " + selected);
                        }
                    } catch (IOException e1) {
                        LOG.error("mouseClicked(): Internal error", e1);
                    }
                }
            }
        }
    });

    final TreeSelectionListener selectionListener = new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {

        }
    };

    tree.getSelectionModel().addTreeSelectionListener(selectionListener);

    tree.setCellRenderer(new DefaultTreeCellRenderer() {

        public Color getTextSelectionColor() {
            return Color.GREEN;
        };

        public java.awt.Color getTextNonSelectionColor() {
            return Color.GREEN;
        };

        public Color getBackgroundSelectionColor() {
            return Color.BLACK;
        };

        public Color getBackgroundNonSelectionColor() {
            return Color.BLACK;
        };

        public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {

            java.awt.Component result = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                    row, hasFocus);

            String label = value.toString();
            Color color = getTextColor();
            if (value instanceof WorkspaceTreeNode) {
                if (value instanceof ProjectNode) {
                    final ProjectNode projectNode = (ProjectNode) value;
                    final IAssemblyProject project = projectNode.getValue();
                    label = project.getName();

                    if (project.isClosed()) {
                        color = Color.LIGHT_GRAY;
                    } else {
                        if (projectNode.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                    }
                } else if (value instanceof FileNode) {
                    FileNode fn = (FileNode) value;
                    label = fn.getValue().getName();
                    switch (fn.type) {
                    case DIRECTORY:
                        if (fn.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                        break;
                    case OBJECT_FILE:
                        label = "[O] " + label;
                        break;
                    case EXECUTABLE:
                        label = "[E] " + label;
                        break;
                    case SOURCE_CODE:
                        label = "[S] " + label;
                        if (fn.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                        break;
                    default:
                        // ok
                    }
                }
            }
            setForeground(color);
            setText(label);
            return result;
        };

    });

    setupPopupMenu();

    final JScrollPane pane = new JScrollPane(tree);
    setColors(pane);

    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());
    GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    setColors(result);
    result.add(pane, cnstrs);
    return result;
}

From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java

public void init() {
    this.addWindowListener(getWindowClosingListener());
    this.setTitle(windowTitle);
    this.setSize(windowWidth, windowHeight);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    JPanel containerPanel = new JPanel();
    getContentPane().add(containerPanel);

    /*/*from ww w.  j  av a2s  .  com*/
     * Use a BorderLayout for the main container so we can use the SOUTH
     * panel as a status bar and use the NORTH panel as a menu bar, etc.
     */
    containerPanel.setLayout(new BorderLayout());

    JPanel bottomPanel = new JPanel();
    containerPanel.add(bottomPanel, BorderLayout.SOUTH);
    bottomPanel.setLayout(new BorderLayout());

    JPanel buttonPanel = new JPanel();
    bottomPanel.add(buttonPanel, BorderLayout.CENTER);

    GridLayout gridLayout = new GridLayout(1, 2, 5, 5);
    buttonPanel.setLayout(gridLayout);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    startButton = new JButton(startButtonText);
    startButton.addActionListener(getStartButtonActionListener(false));

    buttonPanel.add(startButton);

    debugButton = new JButton(debugButtonText);
    debugButton.addActionListener(getStartButtonActionListener(true));

    buttonPanel.add(debugButton);

    continueButton = new JButton(continueButtonText);
    continueButton.addActionListener(getContinueButtonActionListener());

    buttonPanel.add(continueButton);
    continueButton.setEnabled(false);

    stopButton = new JButton(stopButtonText);
    stopButton.addActionListener(getStopButtonActionListener());

    buttonPanel.add(stopButton);
    stopButton.setEnabled(false);

    JPanel statusPanel = new JPanel();
    bottomPanel.add(statusPanel, BorderLayout.SOUTH);

    statusLabel = new JLabel(statusNotRunning);
    statusPanel.add(statusLabel);

    /*
     * Next make a grid bag for the thirteen input elements with labels on
     * the left and spinners on the right.
     */
    JPanel mainPanel = new JPanel();
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.insets = new Insets(5, 5, 5, 5);
    constraints.anchor = GridBagConstraints.WEST;
    mainPanel.setLayout(gridBagLayout);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    containerPanel.add(mainPanel, BorderLayout.CENTER);

    List<Cipher> ciphers = cipherDao.findAll();
    cipherMap = new HashMap<String, Cipher>();
    cipherComboBox = new JComboBox<String>();
    String cipherName;
    for (Cipher cipher : ciphers) {
        cipherName = cipher.getName();
        cipherMap.put(cipherName, cipher);

        cipherComboBox.addItem(cipherName);

        if (cipher.getName().equals(defaultCipher)) {
            cipherComboBox.setSelectedItem(cipherName);
        }
    }
    JLabel cipherNameLabel = new JLabel(cipherNameText);
    cipherComboBox.addActionListener(getCipherComboBoxActionListener());

    constraints.weightx = LAYOUT_LABEL_WEIGHT;
    constraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagLayout.setConstraints(cipherNameLabel, constraints);
    mainPanel.add(cipherNameLabel);
    constraints.weightx = LAYOUT_INPUT_WEIGHT;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagLayout.setConstraints(cipherComboBox, constraints);
    mainPanel.add(cipherComboBox);

    appendGenerationsSpinner(gridBagLayout, constraints, mainPanel);

    appendRunContinuouslyCheckBox(gridBagLayout, constraints, mainPanel);

    appendPopulationSpinner(gridBagLayout, constraints, mainPanel);

    appendLifespanSpinner(gridBagLayout, constraints, mainPanel);

    appendSurvivalRateSpinner(gridBagLayout, constraints, mainPanel);

    appendMutationRateSpinner(gridBagLayout, constraints, mainPanel);

    appendMaxMutationsPerIndividualSpinner(gridBagLayout, constraints, mainPanel);

    appendCrossoverRateSpinner(gridBagLayout, constraints, mainPanel);

    appendMutateDuringCrossoverCheckBox(gridBagLayout, constraints, mainPanel);

    appendFitnessEvaluatorComboBox(gridBagLayout, constraints, mainPanel);

    appendCrossoverAlgorithmComboBox(gridBagLayout, constraints, mainPanel);

    appendMutationAlgorithmComboBox(gridBagLayout, constraints, mainPanel);

    appendSelectionAlgorithmComboBox(gridBagLayout, constraints, mainPanel);

    appendSelectorComboBox(gridBagLayout, constraints, mainPanel);

    appendCompareToKnownSolutionCheckBox(gridBagLayout, constraints, mainPanel);

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            setVisible(true);
            toFront();
        }
    });
}

From source file:org.executequery.gui.browser.ConnectionPanel.java

private void init() {

    // ---------------------------------
    // create the basic props panel

    // initialise the fields
    nameField = createTextField();//from   ww w .  ja  v  a 2  s .c om
    passwordField = createPasswordField();
    hostField = createTextField();
    portField = createNumberTextField();
    sourceField = createMatchedWidthTextField();
    userField = createTextField();
    urlField = createMatchedWidthTextField();

    nameField.addFocusListener(new ConnectionNameFieldListener(this));

    savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword");
    encryptPwdCheck = ActionUtilities.createCheckBox("Encrypt Password", "setEncryptPassword");

    savePwdCheck.addActionListener(this);
    encryptPwdCheck.addActionListener(this);

    // retrieve the drivers
    buildDriversList();

    // ---------------------------------
    // add the basic connection fields

    TextFieldPanel mainPanel = new TextFieldPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(10, 10, 10, 10);
    gbc.gridy = 0;
    gbc.gridx = 0;

    statusLabel = new DefaultFieldLabel();
    addLabelFieldPair(mainPanel, "Status:", statusLabel, "Current connection status", gbc);

    gbc.insets.bottom = 5;
    addLabelFieldPair(mainPanel, "Connection Name:", nameField, "A friendly name for this connection", gbc);

    addLabelFieldPair(mainPanel, "User Name:", userField, "Login user name", gbc);

    addLabelFieldPair(mainPanel, "Password:", passwordField, "Login password", gbc);

    JButton showPassword = new LinkButton("Show Password");
    showPassword.setActionCommand("showPassword");
    showPassword.addActionListener(this);

    JPanel passwordOptionsPanel = new JPanel(new GridBagLayout());
    addComponents(passwordOptionsPanel,
            new ComponentToolTipPair[] {
                    new ComponentToolTipPair(savePwdCheck,
                            "Store the password with the connection information"),
                    new ComponentToolTipPair(encryptPwdCheck, "Encrypt the password when saving"),
                    new ComponentToolTipPair(showPassword, "Show the password in plain text") });

    gbc.gridy++;
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(passwordOptionsPanel, gbc);

    addLabelFieldPair(mainPanel, "Host Name:", hostField, "Server host name or IP address", gbc);

    addLabelFieldPair(mainPanel, "Port:", portField, "Database port number", gbc);

    addLabelFieldPair(mainPanel, "Data Source:", sourceField, "Data source name", gbc);

    addLabelFieldPair(mainPanel, "JDBC URL:", urlField, "The full JDBC URL for this connection (optional)",
            gbc);

    addDriverFields(mainPanel, gbc);

    connectButton = createButton("Connect", CONNECT_ACTION_COMMAND, 'T');
    disconnectButton = createButton("Disconnect", "disconnect", 'D');

    JPanel buttons = new JPanel(new GridBagLayout());
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.insets.top = 5;
    gbc.insets.left = 0;
    gbc.insets.right = 10;
    gbc.gridwidth = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.NORTHEAST;
    gbc.fill = GridBagConstraints.NONE;
    buttons.add(connectButton, gbc);
    gbc.gridx++;
    gbc.weightx = 0;
    buttons.add(disconnectButton, gbc);

    gbc.insets.right = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    mainPanel.add(buttons, gbc);

    // ---------------------------------
    // create the advanced panel

    model = new JdbcPropertiesTableModel();
    JTable table = new DefaultTable(model);
    table.getTableHeader().setReorderingAllowed(false);

    TableColumnModel tcm = table.getColumnModel();

    TableColumn column = tcm.getColumn(2);
    column.setCellRenderer(new DeleteButtonRenderer());
    column.setCellEditor(new DeleteButtonEditor(table, new JCheckBox()));
    column.setMaxWidth(24);
    column.setMinWidth(24);

    JScrollPane scroller = new JScrollPane(table);

    // advanced jdbc properties
    JPanel advPropsPanel = new JPanel(new GridBagLayout());
    advPropsPanel.setBorder(BorderFactory.createTitledBorder("JDBC Properties"));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.insets.right = 10;
    gbc.weighty = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    advPropsPanel.add(new DefaultFieldLabel("Enter any key/value pair properties for this connection"), gbc);
    gbc.gridy++;
    advPropsPanel.add(
            new DefaultFieldLabel("Refer to the relevant JDBC driver documentation for possible entries"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    advPropsPanel.add(scroller, gbc);

    // transaction isolation
    txApplyButton = WidgetFactory.createInlineFieldButton("Apply", "transactionLevelChanged");
    txApplyButton.setToolTipText("Apply this level to all open connections of this type");
    txApplyButton.setEnabled(false);
    txApplyButton.addActionListener(this);

    // add a dummy select value to the tx levels
    String[] txLevels = new String[Constants.TRANSACTION_LEVELS.length + 1];
    txLevels[0] = "Database Default";
    for (int i = 1; i < txLevels.length; i++) {
        txLevels[i] = Constants.TRANSACTION_LEVELS[i - 1];
    }
    txCombo = WidgetFactory.createComboBox(txLevels);

    JPanel advTxPanel = new JPanel(new GridBagLayout());
    advTxPanel.setBorder(BorderFactory.createTitledBorder("Transaction Isolation"));
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.insets.right = 10;
    gbc.insets.bottom = 5;
    gbc.weighty = 0;
    gbc.weightx = 1.0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    advTxPanel.add(new DefaultFieldLabel("Default transaction isolation level for this connection"), gbc);
    gbc.gridy++;
    gbc.insets.bottom = 10;
    advTxPanel.add(
            new DefaultFieldLabel(
                    "Note: the selected isolation level " + "will apply to ALL open connections of this type."),
            gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.insets.top = 0;
    gbc.insets.left = 10;
    gbc.weightx = 0;
    advTxPanel.add(new DefaultFieldLabel("Isolation Level:"), gbc);
    gbc.gridx = 1;
    gbc.insets.left = 5;
    gbc.weightx = 1.0;
    gbc.insets.right = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    advTxPanel.add(txCombo, gbc);
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.left = 0;
    gbc.insets.right = 10;
    advTxPanel.add(txApplyButton, gbc);

    JPanel advancedPanel = new JPanel(new BorderLayout());
    advancedPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    advancedPanel.add(advPropsPanel, BorderLayout.CENTER);
    advancedPanel.add(advTxPanel, BorderLayout.SOUTH);

    JScrollPane scrollPane = new JScrollPane(mainPanel);
    scrollPane.setBorder(null);

    sshTunnelConnectionPanel = new SSHTunnelConnectionPanel();

    tabPane = new JTabbedPane(JTabbedPane.BOTTOM);
    tabPane.addTab("Basic", scrollPane);
    tabPane.addTab("Advanced", advancedPanel);
    tabPane.addTab("SSH Tunnel", sshTunnelConnectionPanel);

    tabPane.addChangeListener(this);

    add(tabPane, BorderLayout.CENTER);

    EventMediator.registerListener(this);
}

From source file:org.jets3t.gui.UserInputFields.java

/**
 * Builds a user input panel matching the fields specified in the uploader.properties file.
 *
 * @param fieldsPanel/*w w  w  .  j  av  a2  s .  c  o m*/
 * the panel component to add prompt and user input components to.
 * @param uploaderProperties
 * properties specific to the Uploader application that includes the field.* settings
 * necessary to build the User Inputs screen.
 *
 * @return
 * true if there is at least one valid user input field, false otherwise.
 */
public boolean buildFieldsPanel(JPanel fieldsPanel, Jets3tProperties uploaderProperties) {
    int fieldIndex = 0;

    for (int fieldNo = 0; fieldNo < 100; fieldNo++) {
        String fieldName = uploaderProperties.getStringProperty("field." + fieldNo + ".name", null);
        String fieldType = uploaderProperties.getStringProperty("field." + fieldNo + ".type", null);
        String fieldPrompt = uploaderProperties.getStringProperty("field." + fieldNo + ".prompt", null);
        String fieldOptions = uploaderProperties.getStringProperty("field." + fieldNo + ".options", null);
        String fieldDefault = uploaderProperties.getStringProperty("field." + fieldNo + ".default", null);

        if (fieldName == null) {
            log.debug("No field with index number " + fieldNo);
            continue;
        } else {
            if (fieldType == null || fieldPrompt == null) {
                log.warn("Field '" + fieldName + "' missing .type or .prompt properties");
                continue;
            }

            if ("message".equals(fieldType)) {
                JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName);
                label.setText(fieldPrompt);
                label.setHyperlinkeActivatedListener(hyperlinkListener);
                fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
            } else if ("radio".equals(fieldType)) {
                if (fieldOptions == null) {
                    log.warn(
                            "Radio button field '" + fieldName + "' is missing the required .options property");
                    continue;
                }

                JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName);
                label.setText(fieldPrompt);
                label.setHyperlinkeActivatedListener(hyperlinkListener);
                fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

                JPanel optionsPanel = skinsFactory.createSkinnedJPanel("OptionsPanel");
                optionsPanel.setLayout(new GridBagLayout());
                int columnOffset = 0;
                ButtonGroup buttonGroup = new ButtonGroup();
                StringTokenizer st = new StringTokenizer(fieldOptions, ",");
                while (st.hasMoreTokens()) {
                    String option = st.nextToken();
                    JRadioButton radioButton = skinsFactory.createSkinnedJRadioButton(fieldName);
                    radioButton.setText(option);
                    buttonGroup.add(radioButton);

                    if (fieldDefault != null && fieldDefault.equals(option)) {
                        // This option is the default one.
                        radioButton.setSelected(true);
                    } else if (buttonGroup.getButtonCount() == 1) {
                        // Make first button the default.
                        radioButton.setSelected(true);
                    }

                    optionsPanel.add(radioButton, new GridBagConstraints(columnOffset++, 0, 1, 1, 0, 0,
                            GridBagConstraints.WEST, GridBagConstraints.NONE, insetsDefault, 0, 0));
                }
                fieldsPanel.add(optionsPanel, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0,
                        GridBagConstraints.WEST, GridBagConstraints.NONE, insetsNone, 0, 0));

                userInputComponentsMap.put(fieldName, buttonGroup);
            } else if ("selection".equals(fieldType)) {
                if (fieldOptions == null) {
                    log.warn(
                            "Radio button field '" + fieldName + "' is missing the required .options property");
                    continue;
                }

                JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName);
                label.setText(fieldPrompt);
                label.setHyperlinkeActivatedListener(hyperlinkListener);
                fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

                JComboBox comboBox = skinsFactory.createSkinnedJComboBox(fieldName);
                StringTokenizer st = new StringTokenizer(fieldOptions, ",");
                while (st.hasMoreTokens()) {
                    String option = st.nextToken();
                    comboBox.addItem(option);
                }

                if (fieldDefault != null) {
                    comboBox.setSelectedItem(fieldDefault);
                }

                fieldsPanel.add(comboBox, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

                userInputComponentsMap.put(fieldName, comboBox);
            } else if ("text".equals(fieldType)) {
                JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName);
                label.setText(fieldPrompt);
                label.setHyperlinkeActivatedListener(hyperlinkListener);
                fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
                JTextField textField = skinsFactory.createSkinnedJTextField(fieldName);
                if (fieldDefault != null) {
                    textField.setText(fieldDefault);
                }

                fieldsPanel.add(textField, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

                userInputComponentsMap.put(fieldName, textField);
            } else if ("password".equals(fieldType)) {
                JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName);
                label.setText(fieldPrompt);
                label.setHyperlinkeActivatedListener(hyperlinkListener);
                fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 1, 1, 0, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
                JPasswordField passwordField = skinsFactory.createSkinnedJPasswordField(fieldName);
                if (fieldDefault != null) {
                    passwordField.setText(fieldDefault);
                }

                fieldsPanel.add(passwordField, new GridBagConstraints(0, fieldIndex++, 1, 1, 1, 0,
                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

                userInputComponentsMap.put(fieldName, passwordField);
            } else if (fieldType.equals("textarea")) {
                JHtmlLabel label = skinsFactory.createSkinnedJHtmlLabel(fieldName);
                label.setText(fieldPrompt);
                label.setHyperlinkeActivatedListener(hyperlinkListener);
                fieldsPanel.add(label, new GridBagConstraints(0, fieldIndex++, 2, 1, 0, 0,
                        GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
                JTextArea textArea = skinsFactory.createSkinnedJTextArea(fieldName);
                textArea.setLineWrap(true);
                if (fieldDefault != null) {
                    textArea.setText(fieldDefault);
                }

                JScrollPane scrollPane = skinsFactory.createSkinnedJScrollPane(fieldName);
                scrollPane.setViewportView(textArea);
                fieldsPanel.add(scrollPane, new GridBagConstraints(0, fieldIndex++, 2, 1, 1, 1,
                        GridBagConstraints.WEST, GridBagConstraints.BOTH, insetsDefault, 0, 0));

                userInputComponentsMap.put(fieldName, textArea);
            } else {
                log.warn("Unrecognised .type setting for field '" + fieldName + "'");
            }
        }
    }

    return isUserInputFieldsAvailable();
}

From source file:MainProgram.MainProgram.java

private void initComponents() throws InterruptedException {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    welcomeMessage = new JLabel();
    welcomeMessage2 = new JLabel();
    pennIDLabel = new JLabel();
    pennIDTextField = new JTextField();
    pennPassLabel = new JLabel();
    pennPassField = new JPasswordField();
    emailLabel = new JLabel();
    emailTextField = new JTextField();
    emailDomainLabel = new JLabel();
    emailPassLabel = new JLabel();
    emailPassField = new JPasswordField();
    semesterLabel = new JLabel();
    semesterComboBox = new JComboBox(semestersString);
    credentials = new JLabel();
    dropLabel = new JLabel();
    dropCheckBox = new JCheckBox();
    button = new JButton();
    stopWatchLabel = new JLabel();
    checkMail = false;//from w  ww .  j  av  a  2  s.  c  o  m
    testConnection = false;

    mailCheckTimeInitializer();
    StopWatchInitializer();
    try {
        setUIFont(new javax.swing.plaf.FontUIResource("Segoe UI", Font.ROMAN_BASELINE, 12));
    } catch (Exception e) {
        e.printStackTrace(MainProgram.errorLog);
    }

    String lcOSName = System.getProperty("os.name").toLowerCase();
    boolean IS_MAC = lcOSName.startsWith("mac os x");
    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 81, 5, 119, 5, 0, 0 };
    if (!IS_MAC) {
        ((GridBagLayout) getLayout()).rowHeights = new int[] { 17, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0, 0,
                0 };
    }
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.fill = GridBagConstraints.HORIZONTAL;

    //---- welcomeMessage ----
    welcomeMessage.setText("Course Registration");
    welcomeMessage.setHorizontalAlignment(SwingConstants.CENTER);
    add(welcomeMessage, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- welcomeMessage2 ----
    welcomeMessage2.setText("for Penn State (BETA)");
    welcomeMessage2.setHorizontalAlignment(SwingConstants.CENTER);
    add(welcomeMessage2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennIDLabel ----
    pennIDLabel.setText("Penn State ID: ");
    pennIDLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(pennIDLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennIDTextField ----
    pennIDTextField.setText("xxx123");
    add(pennIDTextField, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- pennPassLabel ----
    pennPassLabel.setText("Penn State Password: ");
    pennPassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(pennPassLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(pennPassField, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailLabel ----
    emailLabel.setText("Email: ");
    emailLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(emailLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailTextField ----
    emailTextField.setText("myEmail");
    add(emailTextField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailDomainLabel ----
    emailDomainLabel.setText("@mail.com");
    add(emailDomainLabel, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    //---- emailPassLabel ----
    emailPassLabel.setText("Email Password: ");
    emailPassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(emailPassLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(emailPassField, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    //---- Semester label ----
    semesterLabel.setText("Semester/Drop Option: ");
    semesterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    add(semesterLabel, new GridBagConstraints(0, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- Semester ComboBox ----
    add(semesterComboBox, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- Drop CheckBox ----
    add(dropCheckBox, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //---- button ----
    button.setText("Start");
    add(button, new GridBagConstraints(1, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    //---- stopWatchLabel ----
    stopWatchLabel.setText("  " + stopWatchSplitting[0]);
    stopWatchLabel.setHorizontalAlignment(SwingConstants.LEFT);
    add(stopWatchLabel, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    //---- label11 ----
    credentials.setText(" Created by Daniyar Yeralin");
    credentials.setForeground(Color.gray);
    credentials.setHorizontalAlignment(SwingConstants.RIGHT);
    credentials.setFont(new Font("Cambria", Font.ITALIC, 12));
    add(credentials, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    /*button.registerKeyboardAction(button.getActionForKeyStroke(
     KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, false)),
     KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false),
     JComponent.WHEN_FOCUSED);
            
     button.registerKeyboardAction(button.getActionForKeyStroke(
     KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)),
     KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true),
     JComponent.WHEN_FOCUSED);*/
    StartButtonHandler buttonListener = new StartButtonHandler();
    button.addActionListener(buttonListener);

}

From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java

private JPanel getFilterAndTagPanel() {
    pnlFilters = new JPanel();
    pnlFilters.setVisible(false);/*from www .j  av a  2 s.c om*/
    pnlFilters.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    pnlFilters.add(
            new JLabel(I18N.getString("orbisgis.org.orbisgis.core.ui.plugins.views.geocatalog.openFilter")), c);
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.5;
    c.weighty = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    pnlFilters.add(getFilterPanel(), c);
    c.gridx = 1;
    pnlFilters.add(getTagPanel(), c);

    return pnlFilters;
}

From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java

public static JScrollPane buildPanelWithChartForEachAttribute(final Instances dataSet, final int dateIdx) {
    final JXPanel jxpm = new JXPanel();
    jxpm.setLayout(new GridBagLayout());
    jxpm.setScrollableHeightHint(ScrollableSizeHint.VERTICAL_STRETCH);
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;/*from  w w  w .j  a  va2  s  . co  m*/
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets = new Insets(10, 10, 10, 10);
    final int numAttributes = dataSet.numAttributes();
    for (int i = 0; i < numAttributes; i++) {
        final Attribute attr = dataSet.attribute(i);
        System.out.println("Build chart panel for '" + attr.name() + "' time serie ...");
        if (attr.isNominal()) {
            jxpm.add(buildChartPanelForNominalAttribute(dataSet, attr, dateIdx), gbc);
            gbc.gridy++;
        } else if (attr.isNumeric() && !attr.isDate()) {
            try {
                final Instances filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSet,
                        new int[] { attr.index(), dateIdx });
                jxpm.add(buildChartPanelForAllAttributes(filteredDs, false, 1, null), gbc);
                gbc.gridy++;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return new JScrollPane(jxpm, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}