Example usage for javax.swing GroupLayout GroupLayout

List of usage examples for javax.swing GroupLayout GroupLayout

Introduction

In this page you can find the example usage for javax.swing GroupLayout GroupLayout.

Prototype

public GroupLayout(Container host) 

Source Link

Document

Creates a GroupLayout for the specified Container .

Usage

From source file:org.optaplanner.examples.cloudbalancing.swingui.CloudBalancingPanel.java

public CloudBalancingPanel() {
    cloudComputerIcon = new ImageIcon(getClass().getResource("cloudComputer.png"));
    deleteCloudComputerIcon = new ImageIcon(getClass().getResource("deleteCloudComputer.png"));
    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);/* w  ww. j  a va 2  s.  co  m*/
    JPanel headerPanel = createHeaderPanel();
    JPanel computersPanel = createComputersPanel();
    layout.setHorizontalGroup(
            layout.createParallelGroup().addComponent(headerPanel).addComponent(computersPanel));
    layout.setVerticalGroup(layout.createSequentialGroup()
            .addComponent(headerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addComponent(computersPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.PREFERRED_SIZE));
}

From source file:org.spottedplaid.ui.Mainframe.java

/**
 * Create the frame./*from w w w  . j  a  va  2 s  . c o  m*/
 *
 * @param _Sqliteops the _ sqliteops
 * @param _Crypto the _ crypto
 */
public Mainframe(SQliteOps _Sqliteops, Crypto _Crypto) {

    l_sqliteops = _Sqliteops;
    l_crypto = _Crypto;

    setTitle("The Password Saver - Management");
    setResizable(false);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 982, 656);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    menuBar.add(mnFile);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });

    mnFile.add(mntmExit);

    JMenu mnTools = new JMenu("Tools");
    menuBar.add(mnTools);

    JMenuItem mntmChgpwd = new JMenuItem("Change Passphrase");
    mntmChgpwd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Changepwd changePwd = new Changepwd(l_crypto, l_sqliteops);
            changePwd.setVisible(true);
        }
    });

    mnTools.add(mntmChgpwd);

    JMenuItem mntmExpirationReport = new JMenuItem("Expiration Report");
    mntmExpirationReport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DbRecord dbRecExp = new DbRecord();
            dbRecExp.setType(Pwdtypes.S_EXP_RPT);
            ArrayList<String> arrData = l_sqliteops.getRecords(dbRecExp);
            String[] sRecord = new String[3];
            String sData = "";
            int iElement = 0;

            /// Cycle through the data, output to text file, and open in WordPad
            if (arrData != null && arrData.size() > 0) {
                try {
                    String sFilename = "ExpirationReport.txt";
                    File fileExpRpt = new File(sFilename);

                    BufferedWriter buffWriter = new BufferedWriter(new FileWriter(fileExpRpt));
                    buffWriter.write("URL/Application                Challenge            Expiration");
                    buffWriter.write("\n");
                    buffWriter.write("--------------------------------------------------------------");
                    buffWriter.write("\n");
                    for (int iCount = 0; iCount < arrData.size(); iCount++) {
                        sData = arrData.get(iCount);
                        System.out.println("DEBUG->sData [" + sData + "]");
                        StringTokenizer st = new StringTokenizer(sData, "|");
                        iElement = 0;
                        while (st.hasMoreTokens()) {
                            sRecord[iElement] = st.nextToken();
                            iElement++;
                        }

                        /// Define the padding for the output
                        int iPadValue1 = 35 - sRecord[0].length();
                        if (iPadValue1 < 0) {
                            iPadValue1 = 2;
                        }

                        int iPadValue2 = 55 - (35 + sRecord[1].length());
                        if (iPadValue2 < 0) {
                            iPadValue2 = 2;
                        }

                        iPadValue1 += sRecord[1].length();
                        iPadValue2 += sRecord[2].length();

                        buffWriter.write(sRecord[0] + StringUtils.leftPad(sRecord[1], iPadValue1)
                                + StringUtils.leftPad(sRecord[2], iPadValue2) + "\n");
                        buffWriter.write("\n");
                    }
                    buffWriter.close();

                    /// Opens WordPad on Windows systems.  This could be changed to use a property in order to work on a linux/unix/apple system
                    ProcessBuilder pb = new ProcessBuilder("write.exe", sFilename);
                    pb.start();
                } catch (IOException ie) {
                    System.out.println("Expiration Report IO Exception [" + ie.getMessage() + "]");
                    ie.printStackTrace();
                }

            } else {
                JOptionPane.showMessageDialog(null, "No expiring records found");
            }
        }
    });
    mnTools.add(mntmExpirationReport);

    JMenuItem mntmViewLogs = new JMenuItem("View Logs");
    mntmViewLogs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DbRecord dbRecLogs = new DbRecord();
            dbRecLogs.setType(Pwdtypes.S_LOG_TYPE);
            ArrayList<String> arrData = l_sqliteops.getRecords(dbRecLogs);
            String[] sRecord = new String[3];
            String sData = "";
            String sTitle = "Display Data Changes";
            String sDisplay = "Date                  Log Message";
            sDisplay += "\n";
            int iElement = 0;

            /// Cycle through the data, output to text file, and open in WordPad
            if (arrData != null) {
                for (int iCount = 0; iCount < arrData.size(); iCount++) {
                    sData = arrData.get(iCount);
                    System.out.println("DEBUG->sData [" + sData + "]");
                    StringTokenizer st = new StringTokenizer(sData, "|");
                    iElement = 0;
                    while (st.hasMoreTokens()) {
                        sRecord[iElement] = st.nextToken();
                        iElement++;
                    }
                    sDisplay += sRecord[2] + ":" + sRecord[1];
                    sDisplay += "\n";
                }

                if (arrData.size() > 0) {
                    JOptionPane.showMessageDialog(null, sDisplay, sTitle, JOptionPane.INFORMATION_MESSAGE);
                }

            }
        }
    });

    mnTools.add(mntmViewLogs);

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);

    JLabel lblThePasswordSaver = new JLabel("The Password Saver - Manage Passwords");
    lblThePasswordSaver.setFont(new Font("Arial", Font.BOLD, 16));
    lblThePasswordSaver.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel lblUrlapplication = new JLabel("URL/Application");

    jtxtApp = new JTextField();
    jtxtApp.setColumns(10);

    JLabel lblDescription = new JLabel("Description");

    jtxtDesc = new JTextField();
    jtxtDesc.setColumns(10);

    /// Button - Add button for clients/apps
    JButton btnAdd = new JButton("Add");
    btnAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (FormValidation.verifyAppData(jtxtApp.getText().toString(), jtxtDesc.getText().toString()) < 0) {
                JOptionPane.showMessageDialog(null, "URL/Application and Description are required");
            } else {
                dbRec = new DbRecord();
                dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
                dbRec.setClientName(jtxtApp.getText().toString());
                dbRec.setClientDesc(jtxtDesc.getText().toString());
                int l_iClientId = l_sqliteops.insertRecord(dbRec);
                if (l_iClientId <= 0) {
                    JOptionPane.showMessageDialog(null, "Insert record failed [" + dbRec.getResult() + "]");
                } else {
                    dbRec.setClientId(l_iClientId);
                    addToTable();
                }
            }
        }
    });

    /// Buttons - Replace button for clients/apps
    btnReplace = new JButton("Replace");
    btnReplace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (iClientId <= 0) {
                JOptionPane.showMessageDialog(null, "Update record warning: Please select record to continue");
                return;
            }
            dbRec = new DbRecord();
            dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
            dbRec.setClientId(iClientId);
            dbRec.setClientName(jtxtApp.getText().toString());
            dbRec.setClientDesc(jtxtDesc.getText().toString());
            if (l_sqliteops.updateRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null, "Update record failed [" + dbRec.getResult() + "]");
            } else {
                int iRow = jtabApps.getSelectedRow();
                jtabApps.setValueAt(jtxtApp.getText().toString(), iRow, 1);
                jtabApps.setValueAt(jtxtDesc.getText().toString(), iRow, 2);

                clearFields();
            }
        }
    });

    btnReplace.setEnabled(false);

    /// Button - Delete button for clients/apps
    btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (iClientId <= 0) {
                JOptionPane.showMessageDialog(null,
                        "Delete record failed: Please select a record then click Delete");
                return;
            }
            dbRec = new DbRecord();
            dbRec.setType("clients");
            dbRec.setClientId(iClientId);
            dbRec.setDelCreds(0);

            if (chkDelAssoc.isSelected()) {
                dbRec.setDelCreds(1);
            }

            if (l_sqliteops.deleteRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null, "Delete record failed [" + dbRec.getResult() + "]");
            } else {
                DefaultTableModel jtabModel = (DefaultTableModel) jtabApps.getModel();
                jtabModel.removeRow(jtabApps.getSelectedRow());
                if (chkDelAssoc.isSelected()) {
                    DefaultTableModel model = (DefaultTableModel) jtabCreds.getModel();
                    model.setRowCount(0);
                }
                clearFields();
            }
        }
    });
    btnDelete.setEnabled(false);

    /// Buttons - Search button for clients/apps
    btnSearch = new JButton("Search");
    btnSearch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dbRec = new DbRecord();
            dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
            dbRec.setClientName(jtxtApp.getText().toString());
            dbRec.setClientDesc(jtxtDesc.getText().toString());
            loadTable(dbRec);
        }
    });

    btnClear = new JButton("Clear");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            clearFields();
        }
    });

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    /// Begin section for credentials challenges/responses - text fields and buttons
    JLabel lblChallenge = new JLabel("Challenge");

    JLabel lblResponse = new JLabel("Response");

    jtxtChlng = new JTextField();
    jtxtChlng.setColumns(10);

    jtxtRsp = new JTextField();
    jtxtRsp.setColumns(10);

    /// Buttons - Add button for credentials
    btnCredAdd = new JButton("Add");
    btnCredAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (FormValidation.verifyCredData(jtxtChlng.getText().toString(),
                    jtxtRsp.getText().toString()) < 0) {
                JOptionPane.showMessageDialog(null, "Challenge and Response are required");
            } else {
                dbRec = new DbRecord();
                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setClientId(iClientId);
                dbRec.setChallenge(jtxtChlng.getText().toString());
                dbRec.setResponse(l_crypto.encrypt(jtxtRsp.getText().toString()));
                dbRec.setTrack(jcbTrack.getSelectedItem().toString());

                /// Set the modify date if the track days are > 0
                if (!jcbTrack.getSelectedItem().toString().equals("0")) {
                    Calendar calNow = Calendar.getInstance();
                    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
                    int iDaysToAdd = Integer.parseInt(jcbTrack.getSelectedItem().toString());

                    calNow.add(Calendar.DATE, iDaysToAdd);
                    String sValue = sdf.format(calNow.getTime());
                    dbRec.setModifyDate(sValue);
                }

                int l_iClientId = l_sqliteops.insertRecord(dbRec);
                if (l_iClientId <= 0) {
                    JOptionPane.showMessageDialog(null, "Insert record failed [" + dbRec.getResult() + "]");
                } else {
                    dbRec.setCredId(l_iClientId);
                    addToCredsTable();
                }
            }
        }
    });

    /// Button - Replace button for credentials
    btnCredReplace = new JButton("Replace");
    btnCredReplace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DbRecord dbRecLog = new DbRecord();
            int iDaysToAdd = 0;
            Calendar calNow = Calendar.getInstance();
            SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy");

            String sCurDate = sdf1.format(calNow.getTime());
            String sValue = sDateModified;
            String sLogMsg = "";
            StringBuilder sbLogMsg = new StringBuilder(sLogMsg);

            if (dbRec.getType().equals(Pwdtypes.S_CREDS_TYPE) && (dbRec.getCredId() > 0)) {
                dbRec.setClientId(iClientId);
                dbRec.setCredId(iCredId);
                dbRec.setChallenge(jtxtChlng.getText().toString());
                dbRec.setResponse(l_crypto.encrypt(jtxtRsp.getText().toString()));
                dbRec.setTrack(jcbTrack.getSelectedItem().toString());

                /** Check for changes and insert log if necessary */
                if (!sChallenge.equals(jtxtChlng.getText())) {
                    sbLogMsg.append("Application [" + jtxtApp.getText() + "], Challenge modified, old ["
                            + sChallenge + "], new [" + jtxtChlng.getText() + "]");
                }

                if (!sResponse.equals(jtxtRsp.getText())) {
                    if (sbLogMsg.toString().length() > 0) {
                        sbLogMsg.append(",");
                    } else {
                        sbLogMsg.append("Application [" + jtxtApp.getText() + "],");
                    }
                    sbLogMsg.append("Response modified, old [" + sResponse + "]");
                }

                if (sbLogMsg.toString().length() > 0) {
                    dbRecLog.setType(Pwdtypes.S_LOG_TYPE);
                    dbRecLog.setLog(sbLogMsg.toString());
                    dbRecLog.setModifyDate(sCurDate);
                    if (l_sqliteops.insertRecord(dbRecLog) < 0) {
                        JOptionPane.showMessageDialog(null,
                                "Insert log record failed [" + dbRecLog.getResult() + "]");
                    }
                }

                if (!jcbTrack.getSelectedItem().toString().equals("0")) {
                    iDaysToAdd = Integer.parseInt(jcbTrack.getSelectedItem().toString());

                    calNow.add(Calendar.DATE, iDaysToAdd);
                    sValue = sdf1.format(calNow.getTime());

                    System.out.println("DEBUG->Date (sValue) [" + sValue + "]");
                    dbRec.setModifyDate(sValue);
                }
                /// Update the record
                if (l_sqliteops.updateRecord(dbRec) < 0) {
                    JOptionPane.showMessageDialog(null, "Update record failed [" + dbRec.getResult() + "]");
                } else {
                    int iRow = jtabCreds.getSelectedRow();
                    jtabCreds.setValueAt(jtxtChlng.getText().toString(), iRow, 1);
                    jtabCreds.setValueAt(l_crypto.encrypt(jtxtRsp.getText().toString()), iRow, 2);
                    jtabCreds.setValueAt(jcbTrack.getSelectedItem().toString(), iRow, 3);
                    jtabCreds.setValueAt(sValue, iRow, 4);

                    jtabCreds.setValueAt(sValue, iRow, 4);
                    clearCredsFields();
                    enableCredsButtons();
                }
            }
        }
    });

    /// Button - Delete button for credentials
    btnCredDelete = new JButton("Delete");
    btnCredDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dbRec.setType(Pwdtypes.S_CREDS_TYPE);
            dbRec.setCredId(iCredId);
            dbRec.setChallenge(jtxtChlng.getText().toString());
            dbRec.setResponse(jtxtRsp.getText().toString());
            if (l_sqliteops.deleteRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null,
                        "Delete credential record failed [" + dbRec.getResult() + "]");
            } else {
                DefaultTableModel jtabModel = (DefaultTableModel) jtabCreds.getModel();
                jtabModel.removeRow(jtabCreds.getSelectedRow());
                clearCredsFields();
                enableCredsButtons();
            }
        }
    });

    /// Button - Clear button for credentials
    btnCredClear = new JButton("Clear");
    btnCredClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            clearCredsFields();
            enableCredsButtons();
        }
    });

    /// End section for credentials challenges/responses - text fields and buttons

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    btnShowAssoc = new JButton("Display Associated Challenges/Responses in new window");

    /// Display the challenges/responses associated to the application in a popup window. 
    /// This is to make it easier to view when all of the values are needed
    btnShowAssoc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String sTitle = "Credentials for: " + jtxtApp.getText();
            String sDisplay = "";

            sDisplay += "\n";
            DefaultTableModel jTmpModel = (DefaultTableModel) jtabCreds.getModel();
            for (int i = 0; i < jTmpModel.getRowCount(); i++) {
                sDisplay += "Q. " + jTmpModel.getValueAt(i, 1).toString() + "  A. "
                        + l_crypto.decrypt(jTmpModel.getValueAt(i, 2).toString()) + "\n";
            }

            JOptionPane.showMessageDialog(null, sDisplay, sTitle, JOptionPane.INFORMATION_MESSAGE);
        }
    });

    JLabel lblTrackUpdates = new JLabel("Exp Days");

    /// Values for expiration days are hardcoded, may want to move to a table for metadata
    jcbTrack.addItem("0");
    jcbTrack.addItem("30");
    jcbTrack.addItem("45");
    jcbTrack.addItem("60");
    jcbTrack.addItem("90");
    jcbTrack.addItem("180");
    jcbTrack.addItem("365");
    jcbTrack.setSelectedItem("0");

    btnEdit = new JButton("Edit");
    btnEdit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            jtxtChlng.setEnabled(true);
            jtxtRsp.setEnabled(true);
            jcbTrack.setEnabled(true);
            btnCredReplace.setEnabled(true);
            btnCredAdd.setEnabled(true);
        }
    });
    btnEdit.setEnabled(false);

    GroupLayout gl_contentPane = new GroupLayout(contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                    .createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(207)
                            .addComponent(lblThePasswordSaver))
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(23).addGroup(gl_contentPane
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPane.createSequentialGroup().addComponent(btnAdd)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnReplace)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnDelete)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnSearch)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnClear))
                            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                                    .createParallelGroup(Alignment.LEADING)
                                    .addGroup(gl_contentPane.createSequentialGroup()
                                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(lblUrlapplication)
                                                    .addComponent(lblDescription))
                                            .addPreferredGap(ComponentPlacement.RELATED)
                                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(jtxtApp, GroupLayout.PREFERRED_SIZE, 154,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jtxtDesc, GroupLayout.PREFERRED_SIZE, 260,
                                                            GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 355,
                                            GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                                            .addComponent(btnShowAssoc)
                                            .addGroup(gl_contentPane.createSequentialGroup()
                                                    .addGroup(gl_contentPane
                                                            .createParallelGroup(Alignment.TRAILING)
                                                            .addComponent(lblResponse)
                                                            .addComponent(lblChallenge))
                                                    .addGap(18)
                                                    .addGroup(gl_contentPane
                                                            .createParallelGroup(Alignment.LEADING)
                                                            .addGroup(gl_contentPane.createSequentialGroup()
                                                                    .addComponent(jtxtRsp, 272, 272, 272)
                                                                    .addGap(26).addComponent(lblTrackUpdates)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(jcbTrack,
                                                                            GroupLayout.PREFERRED_SIZE, 55,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jtxtChlng, GroupLayout.PREFERRED_SIZE,
                                                                    440, GroupLayout.PREFERRED_SIZE)))
                                            .addGroup(gl_contentPane
                                                    .createParallelGroup(Alignment.LEADING, false)
                                                    .addGroup(gl_contentPane.createSequentialGroup()
                                                            .addComponent(btnCredAdd,
                                                                    GroupLayout.PREFERRED_SIZE, 78,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(ComponentPlacement.RELATED)
                                                            .addComponent(btnCredReplace)
                                                            .addPreferredGap(ComponentPlacement.RELATED)
                                                            .addComponent(btnCredDelete,
                                                                    GroupLayout.PREFERRED_SIZE, 75,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(ComponentPlacement.UNRELATED)
                                                            .addComponent(btnCredClear)
                                                            .addPreferredGap(ComponentPlacement.RELATED,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(btnEdit))
                                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))))))
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(36).addComponent(chkDelAssoc)))
                    .addContainerGap(57, Short.MAX_VALUE)));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup().addContainerGap().addComponent(lblThePasswordSaver)
                    .addGap(45)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                                    .createParallelGroup(Alignment.BASELINE).addComponent(lblUrlapplication)
                                    .addComponent(jtxtApp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblChallenge)).addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(lblDescription)
                                            .addComponent(jtxtDesc, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblResponse)))
                            .addGroup(gl_contentPane.createSequentialGroup()
                                    .addComponent(jtxtChlng, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(jtxtRsp, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblTrackUpdates)
                                            .addComponent(jcbTrack, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                    .addGap(18)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(btnAdd)
                            .addComponent(btnReplace).addComponent(btnDelete).addComponent(btnSearch)
                            .addComponent(btnClear).addComponent(btnCredAdd).addComponent(btnCredReplace)
                            .addComponent(btnCredDelete).addComponent(btnCredClear).addComponent(btnEdit))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 208,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 109,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_contentPane.createSequentialGroup().addGap(120)
                                    .addComponent(btnShowAssoc)))
                    .addGap(18).addComponent(chkDelAssoc).addContainerGap(170, Short.MAX_VALUE)));

    /// JTable - Credentials table setup/definition - BEGIN
    jtabCreds = new JTable();
    jtabCreds.setModel(new DefaultTableModel(new Object[][] {},
            new String[] { "ID", "Challenge", "Response", "Exp Days", "Expiration Date" }) {
        Class[] columnTypes = new Class[] { Integer.class, String.class, String.class, String.class,
                String.class };

        public Class getColumnClass(int columnIndex) {
            return columnTypes[columnIndex];
        }
    });
    jtabCreds.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    scrollPane_1.setViewportView(jtabCreds);
    /// JTable - Credentials table setup/definition - END

    jtabApps = new JTable();
    scrollPane.setViewportView(jtabApps);

    jtabApps.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jtabApps.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    jtabApps.setModel(
            new DefaultTableModel(new Object[][] {}, new String[] { "ID", "URL/Application", "Description" }) {
                Class[] columnTypes = new Class[] { Integer.class, String.class, String.class };

                public Class getColumnClass(int columnIndex) {
                    return columnTypes[columnIndex];
                }

                @Override
                public boolean isCellEditable(int row, int column) {
                    //all cells false
                    return false;
                }
            });
    jtabApps.getColumnModel().getColumn(1).setMinWidth(55);
    jtabApps.getColumnModel().getColumn(2).setMinWidth(55);
    contentPane.setLayout(gl_contentPane);
    contentPane.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[] { jtxtChlng,
            lblThePasswordSaver, jtxtApp, jtxtDesc, btnAdd, btnReplace, btnDelete, btnSearch, btnClear, jtxtRsp,
            btnCredAdd, btnCredReplace, btnCredDelete, btnCredClear, scrollPane, jtabApps, lblUrlapplication,
            lblDescription, chkDelAssoc, lblChallenge, lblResponse, scrollPane_1, jtabCreds }));
    setFocusTraversalPolicy(new FocusTraversalOnArray(
            new Component[] { menuBar, jtxtApp, jtxtDesc, btnAdd, btnReplace, btnDelete, btnSearch, btnClear,
                    jtxtChlng, jtxtRsp, btnCredAdd, btnCredReplace, btnCredDelete, btnCredClear, contentPane,
                    mnFile, mntmExit, lblThePasswordSaver, scrollPane, jtabApps, lblUrlapplication,
                    lblDescription, chkDelAssoc, lblChallenge, lblResponse, scrollPane_1, jtabCreds }));

    /// Initial data load
    dbRec = new DbRecord();
    dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
    dbRec.setClientName("");
    dbRec.setClientDesc("");
    loadTable(dbRec);
    disableCredsButtons();

    ListSelectionModel rowSM = jtabApps.getSelectionModel();

    //Listener for client row change;
    rowSM.addListSelectionListener(new ListSelectionListener() {

        /// Fill the form values when a row is selected in the JTable
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsmData = (ListSelectionModel) e.getSource();
            if (!lsmData.isSelectionEmpty()) {
                int iRow = lsmData.getMinSelectionIndex();
                iClientId = Integer.parseInt(jtabApps.getValueAt(iRow, 0).toString());
                jtxtApp.setText(jtabApps.getValueAt(iRow, 1).toString());
                jtxtDesc.setText(jtabApps.getValueAt(iRow, 2).toString());

                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setClientId(iClientId);
                loadTable(dbRec);
                enableButtons();
                clearCredsFields();
                enableCredsButtons();
            }
        }
    });

    ListSelectionModel rowCred = jtabCreds.getSelectionModel();

    //Listener for credential row change;
    rowCred.addListSelectionListener(new ListSelectionListener() {

        /// Fill the form values when a row is selected in the JTable
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsmData = (ListSelectionModel) e.getSource();
            if (!lsmData.isSelectionEmpty()) {
                int iRow = lsmData.getMinSelectionIndex();
                iCredId = Integer.parseInt(jtabCreds.getValueAt(iRow, 0).toString());
                jtxtChlng.setText(jtabCreds.getValueAt(iRow, 1).toString());
                jtxtRsp.setText(l_crypto.decrypt(jtabCreds.getValueAt(iRow, 2).toString()));
                jcbTrack.setSelectedItem(jtabCreds.getValueAt(iRow, 3).toString());
                if (null == jtabCreds.getValueAt(iRow, 4)) {
                    sDateModified = "";
                } else {
                    sDateModified = jtabCreds.getValueAt(iRow, 4).toString();
                }
                sChallenge = jtxtChlng.getText();
                sResponse = jtxtRsp.getText();
                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setCredId(iClientId);
                jtxtChlng.setEnabled(false);
                jtxtRsp.setEnabled(false);
                jcbTrack.setEnabled(false);
                btnEdit.setEnabled(true);
                btnCredDelete.setEnabled(true);
                btnCredClear.setEnabled(true);
            }
        }
    });

}

From source file:org.tellervo.desktop.io.ExportUI.java

/** This method is called from within the constructor to
 * initialize the form./*www  .ja v  a 2  s. c  o  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    panelOptions = new javax.swing.JPanel();
    lblExportFormat = new javax.swing.JLabel();
    txtOutput = new javax.swing.JTextField();
    btnBrowse = new javax.swing.JButton();
    cboExportFormat = new javax.swing.JComboBox();
    lblOutput = new javax.swing.JLabel();
    cboWhat = new javax.swing.JComboBox();
    lblWhat = new javax.swing.JLabel();
    cboGrouping = new javax.swing.JComboBox();
    lblGrouping = new javax.swing.JLabel();
    panelSpacer = new javax.swing.JPanel();
    lblEncoding = new javax.swing.JLabel();
    cboEncoding = new javax.swing.JComboBox();
    panelBottom = new javax.swing.JPanel();
    btnCancel = new javax.swing.JButton();
    btnOK = new javax.swing.JButton();
    btnHelp = new javax.swing.JButton();
    panelIcon = new javax.swing.JPanel();
    lblIcon = new javax.swing.JLabel();
    panelPadding = new javax.swing.JPanel();
    separator = new javax.swing.JSeparator();

    setMinimumSize(new java.awt.Dimension(400, 200));

    lblExportFormat.setText("Export format:");

    btnBrowse.setText("Browse");

    lblOutput.setText("Output folder:");

    lblWhat.setText("What to export:");

    lblGrouping.setText("Grouping:");

    panelSpacer.setPreferredSize(new java.awt.Dimension(100, 0));

    GroupLayout panelSpacerLayout = new GroupLayout(panelSpacer);
    panelSpacer.setLayout(panelSpacerLayout);
    panelSpacerLayout.setHorizontalGroup(panelSpacerLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGap(0, 318, Short.MAX_VALUE));
    panelSpacerLayout.setVerticalGroup(
            panelSpacerLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));

    lblEncoding.setText("Encoding:");

    cboEncoding.setModel(new javax.swing.DefaultComboBoxModel(
            new String[] { "Automatic", "UTF-8", "UTF-16", "Latin 1", "Mac Roman" }));

    GroupLayout panelOptionsLayout = new GroupLayout(panelOptions);
    panelOptions.setLayout(panelOptionsLayout);
    panelOptionsLayout.setHorizontalGroup(panelOptionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(panelOptionsLayout.createSequentialGroup().addContainerGap().addGroup(panelOptionsLayout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(panelSpacer, GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
                    .addGroup(panelOptionsLayout.createSequentialGroup()
                            .addGroup(panelOptionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addGroup(panelOptionsLayout
                                            .createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                            .addComponent(lblOutput, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(lblExportFormat, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(lblGrouping, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(lblWhat, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(lblEncoding))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(panelOptionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                    .addGroup(GroupLayout.Alignment.TRAILING,
                                            panelOptionsLayout.createSequentialGroup()
                                                    .addComponent(txtOutput, GroupLayout.DEFAULT_SIZE, 121,
                                                            Short.MAX_VALUE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(btnBrowse))
                                    .addComponent(cboExportFormat, 0, 215, Short.MAX_VALUE)
                                    .addComponent(cboGrouping, 0, 215, Short.MAX_VALUE)
                                    .addComponent(cboWhat, 0, 215, Short.MAX_VALUE)
                                    .addComponent(cboEncoding, 0, 215, Short.MAX_VALUE))))));
    panelOptionsLayout.setVerticalGroup(panelOptionsLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(panelOptionsLayout.createSequentialGroup().addContainerGap()
                    .addGroup(panelOptionsLayout.createParallelGroup().addComponent(lblWhat)
                            .addComponent(cboWhat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panelOptionsLayout.createParallelGroup().addComponent(lblGrouping)
                            .addComponent(cboGrouping, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panelOptionsLayout.createParallelGroup().addComponent(lblExportFormat)
                            .addComponent(cboExportFormat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panelOptionsLayout.createParallelGroup().addComponent(lblEncoding)
                            .addComponent(cboEncoding, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panelOptionsLayout.createParallelGroup().addComponent(lblOutput)
                            .addComponent(btnBrowse).addComponent(txtOutput, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(panelSpacer,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));

    btnCancel.setText("Cancel");
    btnCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCancelActionPerformed(evt);
        }
    });

    btnOK.setText("OK");

    btnHelp.setText("Help");

    GroupLayout panelBottomLayout = new GroupLayout(panelBottom);
    panelBottom.setLayout(panelBottomLayout);
    panelBottomLayout.setHorizontalGroup(panelBottomLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(panelBottomLayout.createSequentialGroup().addContainerGap().addComponent(btnHelp)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 240, Short.MAX_VALUE)
                    .addComponent(btnCancel).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(btnOK).addContainerGap()));
    panelBottomLayout.setVerticalGroup(panelBottomLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(panelBottomLayout
                    .createSequentialGroup().addContainerGap().addGroup(panelBottomLayout.createParallelGroup()
                            .addComponent(btnOK).addComponent(btnCancel).addComponent(btnHelp))
                    .addContainerGap()));

    lblIcon.setMaximumSize(new java.awt.Dimension(128, 128));
    lblIcon.setMinimumSize(new java.awt.Dimension(128, 128));

    GroupLayout panelIconLayout = new GroupLayout(panelIcon);
    panelIcon.setLayout(panelIconLayout);
    panelIconLayout.setHorizontalGroup(panelIconLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(panelIconLayout.createSequentialGroup().addContainerGap()
                    .addComponent(lblIcon, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    panelIconLayout.setVerticalGroup(panelIconLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(panelIconLayout.createSequentialGroup().addContainerGap()
                    .addComponent(lblIcon, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));

    GroupLayout panelPaddingLayout = new GroupLayout(panelPadding);
    panelPadding.setLayout(panelPaddingLayout);
    panelPaddingLayout.setHorizontalGroup(panelPaddingLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGap(0, 482, Short.MAX_VALUE));
    panelPaddingLayout.setVerticalGroup(panelPaddingLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE));

    separator.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    separator.setMaximumSize(new java.awt.Dimension(32767, 2));
    separator.setMinimumSize(new java.awt.Dimension(0, 2));
    separator.setPreferredSize(new java.awt.Dimension(50, 2));

    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(panelBottom, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                            .addComponent(panelPadding, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(panelIcon, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18).addComponent(panelOptions, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(separator, GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addGap(6, 6, 6).addComponent(panelIcon,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addComponent(panelOptions, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(panelPadding, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(separator, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addGap(12, 12, 12).addComponent(panelBottom, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addContainerGap()));
}

From source file:org.zaproxy.zap.extension.dynssl.DynamicSSLPanel.java

/**
 * Create the panel.//w  ww.j  a  v a2 s  . c  o  m
 */
public DynamicSSLPanel(ExtensionDynSSL extension) {
    super();
    this.extension = extension;

    setName(Constant.messages.getString("dynssl.options.name"));
    setLayout(new BorderLayout(0, 0));

    final JPanel panel = new JPanel();
    panel.setBorder(new EmptyBorder(2, 2, 2, 2));
    add(panel);

    final JLabel lbl_Cert = new JLabel(Constant.messages.getString("dynssl.label.rootca"));

    txt_PubCert = new ZapTextArea();
    txt_PubCert.setFont(FontUtils.getFont("Monospaced"));
    txt_PubCert.setEditable(false);
    txt_PubCert.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            checkAndEnableButtons();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            checkAndEnableButtons();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            checkAndEnableButtons();
        }

        private void checkAndEnableButtons() {
            checkAndEnableViewButton();
            checkAndEnableSaveButton();
        }
    });

    final JScrollPane pubCertScrollPane = new JScrollPane(txt_PubCert);

    final JButton bt_generate = new JButton(Constant.messages.getString("dynssl.button.generate"));
    bt_generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doGenerate();
        }
    });
    bt_generate.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/041.png")));

    bt_save = new JButton(Constant.messages.getString("menu.file.save"));
    checkAndEnableSaveButton();
    bt_save.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSave();
        }
    });
    bt_save.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/096.png")));

    bt_view = new JButton(Constant.messages.getString("menu.view"));
    checkAndEnableViewButton();
    bt_view.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doView();
        }
    });
    bt_view.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/049.png")));

    final JButton bt_import = new JButton(Constant.messages.getString("dynssl.button.import"));
    bt_import.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doImport();
        }
    });
    bt_import.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/047.png")));

    final GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel
            .createSequentialGroup().addContainerGap()
            .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false).addGroup(gl_panel
                    .createSequentialGroup()
                    .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
                            .addComponent(lbl_Cert, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
                            .addGroup(gl_panel.createSequentialGroup()
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(bt_generate)))
                    .addGap(6))
                    .addGroup(gl_panel.createSequentialGroup().addComponent(bt_import)
                            .addPreferredGap(ComponentPlacement.RELATED)))
            .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panel.createSequentialGroup().addComponent(bt_view)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(bt_save))
                    .addComponent(pubCertScrollPane, GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE))
            .addContainerGap()));
    gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel
            .createSequentialGroup().addGap(10)
            .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
                    .addGroup(gl_panel.createSequentialGroup().addComponent(lbl_Cert).addGap(10)
                            .addComponent(bt_generate, GroupLayout.PREFERRED_SIZE, 25,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(bt_import,
                                    GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
                    .addComponent(pubCertScrollPane, GroupLayout.PREFERRED_SIZE, 400,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
                    .addComponent(bt_save, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
                    .addComponent(bt_view, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
            .addGap(0, 29, Short.MAX_VALUE)));
    panel.setLayout(gl_panel);
}

From source file:org.zaproxy.zap.extension.fuzz.impl.ProcessorsMessageLocationDialog.java

@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

    GroupLayout layout = new GroupLayout(fieldsPanel);
    fieldsPanel.setLayout(layout);/*from  w w  w.j av  a  2s  .  co  m*/
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    JLabel locationLabel = new JLabel(Constant.messages
            .getString("fuzz.fuzzer.dialog.messagelocations.dialog.processors.location.label"));
    messageLocationLabel = new JLabel();
    JLabel valueLabel = new JLabel(
            Constant.messages.getString("fuzz.fuzzer.dialog.messagelocations.dialog.processors.value.label"));
    messageLocationValueLabel = new JLabel();
    JLabel payloadsLabel = new JLabel(Constant.messages
            .getString("fuzz.fuzzer.dialog.messagelocations.dialog.processors.processors.label"));

    layout.setHorizontalGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(locationLabel)
                    .addComponent(messageLocationLabel))
            .addGroup(layout.createSequentialGroup().addComponent(valueLabel)
                    .addComponent(messageLocationValueLabel))
            .addComponent(payloadsLabel).addComponent(processorsTablePanel));

    layout.setVerticalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(locationLabel)
                    .addComponent(messageLocationLabel))
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(valueLabel)
                    .addComponent(messageLocationValueLabel))
            .addComponent(payloadsLabel).addComponent(processorsTablePanel));

    return fieldsPanel;
}

From source file:richtercloud.document.scanner.gui.DocumentScanner.java

private void onDeviceSet() {
    assert this.device != null;
    this.scannerLabel.setText(this.device.toString());
    GroupLayout layout = new GroupLayout(this.statusBar);
    GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
    hGroup.addGroup(layout.createParallelGroup().addComponent(this.scannerLabel));
    layout.setHorizontalGroup(hGroup);//from  ww  w  .j a  v  a  2  s .c om
    GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(this.scannerLabel));
    layout.setVerticalGroup(vGroup);
    this.statusBar.setLayout(layout);
    this.pack();
    this.invalidate();
}

From source file:richtercloud.document.scanner.gui.DocumentScanner.java

private void onDeviceUnset() {
    assert this.device == null;
    GroupLayout layout = new GroupLayout(this.statusBar);
    GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
    hGroup.addGroup(layout.createParallelGroup().addComponent(this.scannerLabel)
            .addComponent(this.selectScannerButton));
    layout.setHorizontalGroup(hGroup);// ww  w  . j a  va  2s.  c o  m
    GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    vGroup.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(this.scannerLabel)
            .addComponent(this.selectScannerButton));
    layout.setVerticalGroup(vGroup);
    this.statusBar.setLayout(layout);
    this.pack();
    this.invalidate();
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private void buildUI() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    setModalityType(ModalityType.MODELESS);

    if (!ShutdownAlert.canShutdown()) {
        // disable the computer shutdown checkbox if we can't shutdown
        shutdownWhenDoneCB.setEnabled(false);
    }/*w  w  w. ja  v a2  s  . co m*/

    addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
            sceneMan.interrupt();
            RenderControls.this.dispose();
        }

        @Override
        public void windowClosed(WindowEvent e) {
            // halt rendering
            renderMan.interrupt();

            // dispose of the 3D view
            view.setVisible(false);
            view.dispose();
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }
    });

    updateTitle();

    addTab("General", Icon.wrench, buildGeneralPane());
    addTab("Lighting", Icon.light, buildLightingPane());
    addTab("Sky", Icon.sky, buildSkyPane());
    addTab("Water", Icon.water, buildWaterPane());
    addTab("Camera", Icon.camera, buildCameraPane());
    addTab("Post-processing", Icon.gear, buildPostProcessingPane());
    addTab("Advanced", Icon.advanced, buildAdvancedPane());
    addTab("Help", Icon.question, buildHelpPane());

    JLabel sppTargetLbl = new JLabel("SPP Target: ");
    sppTargetLbl.setToolTipText("The render will be paused at this SPP count");

    JButton setDefaultBtn = new JButton("Make Default");
    setDefaultBtn.setToolTipText("Make the current SPP target the default");
    setDefaultBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PersistentSettings.setSppTargetDefault(renderMan.scene().getTargetSPP());
        }
    });

    targetSPP.update();

    JLabel renderLbl = new JLabel("Render: ");

    setViewVisible(false);
    showPreviewBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (view.isViewVisible()) {
                view.hideView();
            } else {
                showPreviewWindow();
            }
        }
    });

    startRenderBtn.setText("START");
    startRenderBtn.setIcon(Icon.play.imageIcon());
    startRenderBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            switch (renderMan.scene().getRenderState()) {
            case PAUSED:
                renderMan.scene().resumeRender();
                break;
            case PREVIEW:
                renderMan.scene().startRender();
                break;
            case RENDERING:
                renderMan.scene().pauseRender();
                break;
            }
            stopRenderBtn.setEnabled(true);
        }
    });

    stopRenderBtn.setText("RESET");
    stopRenderBtn.setIcon(Icon.stop.imageIcon());
    stopRenderBtn.setToolTipText("<html>Warning: this will discard the "
            + "current rendered image!<br>Make sure to save your image " + "before stopping the renderer!");
    stopRenderBtn.setEnabled(false);
    stopRenderBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            renderMan.scene().haltRender();
        }
    });

    saveFrameBtn.setText("Save Current Frame");
    saveFrameBtn.addActionListener(saveFrameListener);

    sppLbl.setToolTipText("SPP = Samples Per Pixel, SPS = Samples Per Second");

    setRenderTime(0);
    setSamplesPerSecond(0);
    setSPP(0);
    setProgress("Progress:", 0, 0, 1);

    progressLbl.setText("Progress:");

    etaLbl.setText("ETA:");

    sceneNameLbl.setText("Scene name: ");
    sceneNameField.setColumns(15);
    AbstractDocument document = (AbstractDocument) sceneNameField.getDocument();
    document.setDocumentFilter(new SceneNameFilter());
    document.addDocumentListener(sceneNameListener);
    sceneNameField.addActionListener(sceneNameActionListener);
    updateSceneNameField();

    saveSceneBtn.setText("Save");
    saveSceneBtn.setIcon(Icon.disk.imageIcon());
    saveSceneBtn.addActionListener(saveSceneListener);

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(sceneNameLbl).addComponent(sceneNameField)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(saveSceneBtn))
            .addComponent(tabbedPane)
            .addGroup(layout.createSequentialGroup().addGroup(targetSPP.horizontalGroup(layout))
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(setDefaultBtn))
            .addGroup(layout.createSequentialGroup().addComponent(renderLbl)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(startRenderBtn)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(stopRenderBtn))
            .addGroup(
                    layout.createSequentialGroup().addComponent(saveFrameBtn)
                            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(showPreviewBtn))
            .addGroup(
                    layout.createSequentialGroup().addComponent(renderTimeLbl)
                            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(sppLbl))
            .addGroup(
                    layout.createSequentialGroup().addComponent(progressLbl)
                            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(etaLbl))
            .addComponent(progressBar)).addContainerGap());
    layout.setVerticalGroup(
            layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(sceneNameLbl)
                            .addComponent(sceneNameField).addComponent(saveSceneBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(tabbedPane)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                            .addGroup(targetSPP.verticalGroup(layout)).addComponent(setDefaultBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(renderLbl)
                            .addComponent(startRenderBtn).addComponent(stopRenderBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup().addComponent(saveFrameBtn)
                            .addComponent(showPreviewBtn))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup().addComponent(renderTimeLbl).addComponent(sppLbl))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup().addComponent(progressLbl).addComponent(etaLbl))
                    .addComponent(progressBar).addContainerGap());
    final JScrollPane scrollPane = new JScrollPane(panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    setContentPane(scrollPane);

    scrollPane.getViewport().addChangeListener(new ChangeListener() {
        private boolean resized = false;

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!resized && scrollPane.getVerticalScrollBar().isVisible()) {
                Dimension vsbPrefSize = new JScrollPane().getVerticalScrollBar().getPreferredSize();
                Dimension size = getSize();
                setSize(size.width + vsbPrefSize.width, size.height);
                resized = true;
            }
        }
    });

    pack();

    setLocationRelativeTo(chunky.getFrame());

    setVisible(true);
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildAdvancedPane() {
    rayDepth.update();//  w w w.j av a 2s  . c  o m

    JSeparator sep1 = new JSeparator();
    JSeparator sep2 = new JSeparator();

    numThreads.update();

    cpuLoad.update();

    mergeDumpBtn.setToolTipText("Merge an existing render dump with the current render");
    mergeDumpBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            CenteredFileDialog fileDialog = new CenteredFileDialog(null, "Select Render Dump", FileDialog.LOAD);
            fileDialog.setFilenameFilter(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                    return name.toLowerCase().endsWith(".dump");
                }
            });
            fileDialog.setDirectory(PersistentSettings.getSceneDirectory().getAbsolutePath());
            fileDialog.setVisible(true);
            File selectedFile = fileDialog.getSelectedFile();
            if (selectedFile != null) {
                sceneMan.mergeRenderDump(selectedFile);
            }
        }
    });

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup().addGroup(numThreads.horizontalGroup(layout))
                    .addGroup(cpuLoad.horizontalGroup(layout)).addComponent(sep1)
                    .addGroup(rayDepth.horizontalGroup(layout)).addComponent(sep2).addComponent(mergeDumpBtn)
                    .addComponent(shutdownWhenDoneCB))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(numThreads.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cpuLoad.verticalGroup(layout)).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(sep1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED).addGroup(rayDepth.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(sep2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(mergeDumpBtn)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(shutdownWhenDoneCB).addContainerGap());
    return panel;
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildWaterPane() {

    JButton storeDefaultsBtn = new JButton("Store as defaults");
    storeDefaultsBtn.setToolTipText("Store the current water settings as new defaults");
    storeDefaultsBtn.addActionListener(new ActionListener() {
        @Override//from   www  . j  a  v  a2s  . c  o m
        public void actionPerformed(ActionEvent e) {
            PersistentSettings.setStillWater(renderMan.scene().stillWaterEnabled());
            PersistentSettings.setWaterOpacity(renderMan.scene().getWaterOpacity());
            PersistentSettings.setWaterVisibility(renderMan.scene().getWaterVisibility());
            PersistentSettings.setWaterHeight(renderMan.scene().getWaterHeight());
            boolean useCustomWaterColor = renderMan.scene().getUseCustomWaterColor();
            PersistentSettings.setUseCustomWaterColor(useCustomWaterColor);
            if (useCustomWaterColor) {
                Vector3d color = renderMan.scene().getWaterColor();
                PersistentSettings.setWaterColorRed(color.x);
                PersistentSettings.setWaterColorGreen(color.y);
                PersistentSettings.setWaterColorBlue(color.z);
            }
        }
    });

    stillWaterCB.setText("still water");
    stillWaterCB.addActionListener(stillWaterListener);
    updateStillWater();

    waterVisibility.update();
    waterOpacity.update();

    JLabel waterWorldLbl = new JLabel(
            "Note: All chunks will be reloaded after changing the water world options!");
    JLabel waterHeightLbl = new JLabel("Water height: ");
    waterHeightField.setColumns(5);
    waterHeightField.setText("" + World.SEA_LEVEL);
    waterHeightField.setEnabled(renderMan.scene().getWaterHeight() != 0);
    waterHeightField.addActionListener(waterHeightListener);

    applyWaterHeightBtn.setToolTipText("Use this water height");
    applyWaterHeightBtn.addActionListener(waterHeightListener);

    waterWorldCB.setText("Water World Mode");
    waterWorldCB.addActionListener(waterWorldListener);
    updateWaterHeight();

    waterColorCB.addActionListener(customWaterColorListener);
    updateWaterColor();

    waterColorBtn.setIcon(Icon.colors.imageIcon());
    waterColorBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ColorPicker picker = new ColorPicker(waterColorBtn, renderMan.scene().getWaterColor());
            picker.addColorListener(new ColorListener() {
                @Override
                public void onColorPicked(Vector3d color) {
                    renderMan.scene().setWaterColor(color);
                }
            });
        }
    });

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup().addComponent(stillWaterCB).addGroup(waterVisibility.horizontalGroup(layout))
            .addGroup(waterOpacity.horizontalGroup(layout)).addComponent(waterWorldLbl)
            .addComponent(waterWorldCB)
            .addGroup(layout.createSequentialGroup().addComponent(waterHeightLbl)
                    .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addComponent(waterHeightField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(applyWaterHeightBtn))
            .addGroup(layout.createSequentialGroup().addComponent(waterColorCB)
                    .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addComponent(waterColorBtn))
            .addGroup(layout.createSequentialGroup()
                    .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
                    .addComponent(storeDefaultsBtn)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap().addComponent(stillWaterCB)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(waterVisibility.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(waterOpacity.verticalGroup(layout))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(waterWorldLbl)
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(waterWorldCB)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(waterHeightLbl)
                    .addComponent(waterHeightField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(applyWaterHeightBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup().addComponent(waterColorCB).addComponent(waterColorBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addPreferredGap(ComponentPlacement.UNRELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(storeDefaultsBtn).addContainerGap());
    return panel;
}