Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints() 

Source Link

Document

Creates a GridBagConstraint object with all of its fields set to their default value.

Usage

From source file:com.intel.stl.ui.monitor.view.PSPortsDetailsPanel.java

protected JPanel createDeviceTypePanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);/*  w w  w. ja va 2  s .  c  o  m*/
    panel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    panel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.insets = new Insets(8, 2, 2, 2);
    gc.weighty = 0;
    gc.weightx = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.gridheight = 1;
    deviceTypeChartPanel = new ChartPanel(null);
    deviceTypeChartPanel.setPreferredSize(new Dimension(80, 60));
    panel.add(deviceTypeChartPanel, gc);

    typeNumberLabels = new JLabel[nodeTypes.length];
    typeNameLabels = new JLabel[nodeTypes.length];
    gc.fill = GridBagConstraints.BOTH;
    gc.insets = new Insets(2, 2, 2, 2);
    for (int i = 0; i < nodeTypes.length; i++) {
        gc.weightx = 1;
        gc.gridwidth = 1;
        typeNumberLabels[i] = createNumberLabel();
        panel.add(typeNumberLabels[i], gc);

        gc.weightx = 0;
        gc.gridwidth = GridBagConstraints.REMAINDER;
        typeNameLabels[i] = createNameLabel(nodeTypes[i].getName());
        panel.add(typeNameLabels[i], gc);
    }

    return panel;
}

From source file:SplineAnim.java

private void createControlPanel(Panel p) {

    GridBagLayout gl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();

    p.setLayout(gl);/*from   w  w w .  j  a va2 s  .co  m*/
    gbc.weightx = 100;
    gbc.weighty = 100;
    gbc.fill = GridBagConstraints.BOTH;

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    interpLabel = new Label("Interpolation Type", Label.LEFT);
    p.add(interpLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    interpChoice = new Choice();
    interpChoice.add("Spline");
    interpChoice.add("Linear");
    p.add(interpChoice, gbc);
    interpChoice.addItemListener(this);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    speedSlider = new Scrollbar(Scrollbar.HORIZONTAL, 2, 1, 0, 11);
    speedSlider.setUnitIncrement(1);
    p.add(speedSlider, gbc);
    speedSlider.addAdjustmentListener(this);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    speedLabel = new Label(" - Animation Speed +", Label.CENTER);
    p.add(speedLabel, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    animateButton = new Button("Stop Animation");
    p.add(animateButton, gbc);
    animateButton.addActionListener(this);

}

From source file:com.wet.wired.jsr.recorder.JRecorder.java

private void showWindow() {
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            closeRecorder();//from w w  w.ja  v  a  2s.c  o  m
            System.exit(0);
        }
    });

    setTitle("TestingOwl Recorder");
    setIconImage(owl.getWelcomeIcon().getImage());
    getContentPane().removeAll();

    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    this.getContentPane().setLayout(gbl);

    control = new JButton("Start Recording");
    control.setActionCommand("start");
    control.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    this.getContentPane().add(control, gbc);

    decorator.getButtonsAndSoundLevel(this.getContentPane(), gbc);

    player = new JButton("to Player");
    player.setActionCommand("player");
    player.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 5;
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    this.getContentPane().add(player, gbc);

    text = new JLabel("Ready to record");
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 1;
    gbc.weighty = 0;
    gbc.gridwidth = 5;
    this.getContentPane().add(text, gbc);

    getContentPane().doLayout();

    this.pack();
    this.setAlwaysOnTop(true);
    this.setVisible(true);

}

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

protected void createValid() {
    GridBagConstraints c = new GridBagConstraints();
    JComponent label = new JLabel(getDetailsString());
    Font f = label.getFont();//from  w ww.ja v  a  2 s  .c  o m
    label.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    DETAILS.add(label, c);

    JTextArea text = newTextArea(LICENSE.getLicenseDescription(URN));
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.gridheight = 2;
    c.weighty = 1;
    c.weightx = .7;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    DETAILS.add(text, c);

    if (LICENSE.getLicenseDeed(URN) != null) {
        label = new URLLabel(LICENSE.getLicenseDeed(URN), getDeedString());
    } else {
        label = new JLabel();
        label.setVisible(false);
    }
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.weighty = 0;
    c.weightx = .3;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(0, 0, 3, 0);
    DETAILS.add(label, c);

    label = new URLLabel(LICENSE.getLicenseURI(), getVerificationString());
    DETAILS.add(label, c);
}

From source file:com._17od.upm.gui.AccountDialog.java

public AccountDialog(AccountInformation account, JFrame parentWindow, boolean readOnly,
        ArrayList existingAccounts) {
    super(parentWindow, true);

    boolean addingAccount = false;

    //Request focus on Account JDialog when mouse clicked
    this.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 1) {
                requestFocus();//from w w w.ja v  a  2s.  c  o  m

            }
        }
    });

    // Set the title based on weather we've been opened in readonly mode and
    // weather the
    // Account passed in is empty or not
    String title = null;
    if (readOnly) {
        title = Translator.translate("viewAccount");
    } else if (!readOnly && account.getAccountName().trim().equals("")) {
        title = Translator.translate("addAccount");
        addingAccount = true;
    } else {
        title = Translator.translate("editAccount");
    }
    setTitle(title);

    this.pAccount = account;
    this.existingAccounts = existingAccounts;
    this.parentWindow = parentWindow;

    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    Container container = getContentPane();

    // The AccountName Row
    JLabel accountLabel = new JLabel(Translator.translate("account"));
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(accountLabel, c);

    // This panel will hold the Account field and the copy and paste
    // buttons.
    JPanel accountPanel = new JPanel(new GridBagLayout());

    accountName = new JTextField(new String(pAccount.getAccountName()), 20);
    if (readOnly) {
        accountName.setEditable(false);
    }
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    accountPanel.add(accountName, c);
    accountName.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            accountName.selectAll();
        }
    });

    JButton acctCopyButton = new JButton();
    acctCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    acctCopyButton.setToolTipText("Copy");
    acctCopyButton.setEnabled(true);
    acctCopyButton.setMargin(new Insets(0, 0, 0, 0));
    acctCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(accountName);
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    accountPanel.add(acctCopyButton, c);

    JButton acctPasteButton = new JButton();
    acctPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    acctPasteButton.setToolTipText("Paste");
    acctPasteButton.setEnabled(!readOnly);
    acctPasteButton.setMargin(new Insets(0, 0, 0, 0));
    acctPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(accountName);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    accountPanel.add(acctPasteButton, c);

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(accountPanel, c);

    // Userid Row
    JLabel useridLabel = new JLabel(Translator.translate("userid"));
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(useridLabel, c);

    // This panel will hold the User ID field and the copy and paste
    // buttons.
    JPanel idPanel = new JPanel(new GridBagLayout());

    userId = new JTextField(new String(pAccount.getUserId()), 20);
    if (readOnly) {
        userId.setEditable(false);
    }
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    idPanel.add(userId, c);
    userId.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            userId.selectAll();
        }
    });

    JButton idCopyButton = new JButton();
    idCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    idCopyButton.setToolTipText("Copy");
    idCopyButton.setEnabled(true);
    idCopyButton.setMargin(new Insets(0, 0, 0, 0));
    idCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(userId);
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    idPanel.add(idCopyButton, c);

    JButton idPasteButton = new JButton();
    idPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    idPasteButton.setToolTipText("Paste");
    idPasteButton.setEnabled(!readOnly);
    idPasteButton.setMargin(new Insets(0, 0, 0, 0));
    idPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(userId);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    idPanel.add(idPasteButton, c);

    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(idPanel, c);

    // Password Row
    JLabel passwordLabel = new JLabel(Translator.translate("password"));
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(15, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(passwordLabel, c);

    // This panel will hold the password, generate password button, copy and
    // paste buttons, and hide password checkbox
    JPanel passwordPanel = new JPanel(new GridBagLayout());

    password = new JPasswordField(new String(pAccount.getPassword()), 20);
    // allow CTRL-C on the password field
    password.putClientProperty("JPasswordField.cutCopyAllowed", Boolean.TRUE);
    password.setEditable(!readOnly);
    password.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            password.selectAll();
        }
    });
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(password, c);

    JButton generateRandomPasswordButton = new JButton(Translator.translate("generate"));
    if (readOnly) {
        generateRandomPasswordButton.setEnabled(false);
    }
    generateRandomPasswordButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionevent) {
            // Get the user's preference about including or not Escape
            // Characters to generated passwords
            Boolean includeEscapeChars = new Boolean(
                    Preferences.get(Preferences.ApplicationOptions.INCLUDE_ESCAPE_CHARACTERS, "true"));
            int pwLength = Preferences.getInt(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, 8);
            String Password;

            if ((includeEscapeChars.booleanValue()) && (pwLength > 3)) {
                // Verify that the generated password satisfies the criteria
                // for strong passwords(including Escape Characters)
                do {
                    Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue());
                } while (!(CheckPassStrong(Password, includeEscapeChars.booleanValue())));

            } else if (!(includeEscapeChars.booleanValue()) && (pwLength > 2)) {
                // Verify that the generated password satisfies the criteria
                // for strong passwords(excluding Escape Characters)
                do {
                    Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue());
                } while (!(CheckPassStrong(Password, includeEscapeChars.booleanValue())));

            } else {
                // Else a weak password of 3 or less chars will be produced
                Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue());
            }
            password.setText(Password);
        }
    });
    if (addingAccount) {
        generateRandomPasswordButton.doClick();
    }
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(generateRandomPasswordButton, c);

    JButton pwCopyButton = new JButton();
    pwCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    pwCopyButton.setToolTipText("Copy");
    pwCopyButton.setEnabled(true);
    pwCopyButton.setMargin(new Insets(0, 0, 0, 0));
    pwCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(password);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(pwCopyButton, c);

    JButton pwPasteButton = new JButton();
    pwPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    pwPasteButton.setToolTipText("Paste");
    pwPasteButton.setEnabled(!readOnly);
    pwPasteButton.setMargin(new Insets(0, 0, 0, 0));
    pwPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(password);
        }
    });
    c.gridx = 3;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(pwPasteButton, c);

    JCheckBox hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true);
    defaultEchoChar = password.getEchoChar();
    hidePasswordCheckbox.setMargin(new Insets(5, 0, 5, 0));
    hidePasswordCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                password.setEchoChar(defaultEchoChar);
            } else {
                password.setEchoChar((char) 0);
            }
        }
    });

    Boolean hideAccountPassword = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true"));
    hidePasswordCheckbox.setSelected(hideAccountPassword.booleanValue());

    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(hidePasswordCheckbox, c);

    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(passwordPanel, c);

    // URL Row
    JLabel urlLabel = new JLabel(Translator.translate("url"));
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(urlLabel, c);

    // This panel will hold the URL field and the copy and paste buttons.
    JPanel urlPanel = new JPanel(new GridBagLayout());

    url = new JTextField(new String(pAccount.getUrl()), 20);
    if (readOnly) {
        url.setEditable(false);
    }
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    urlPanel.add(url, c);
    url.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            url.selectAll();
        }
    });

    final JButton urlLaunchButton = new JButton();
    urlLaunchButton.setIcon(Util.loadImage("launch-url-sm.png"));
    urlLaunchButton.setToolTipText("Launch URL");
    urlLaunchButton.setEnabled(true);
    urlLaunchButton.setMargin(new Insets(0, 0, 0, 0));
    urlLaunchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            String urlText = url.getText();

            // Check if the selected url is null or emty and inform the user
            // via JoptioPane message
            if ((urlText == null) || (urlText.length() == 0)) {
                JOptionPane.showMessageDialog(urlLaunchButton.getParent(),
                        Translator.translate("EmptyUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);
                // Check if the selected url is a valid formated url(via
                // urlIsValid() method) and inform the user via JoptioPane
                // message
            } else if (!(urlIsValid(urlText))) {
                JOptionPane.showMessageDialog(urlLaunchButton.getParent(),
                        Translator.translate("InvalidUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);
                // Call the method LaunchSelectedURL() using the selected
                // url as input
            } else {
                LaunchSelectedURL(urlText);
            }
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    urlPanel.add(urlLaunchButton, c);

    JButton urlCopyButton = new JButton();
    urlCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    urlCopyButton.setToolTipText("Copy");
    urlCopyButton.setEnabled(true);
    urlCopyButton.setMargin(new Insets(0, 0, 0, 0));
    urlCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(url);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    urlPanel.add(urlCopyButton, c);

    JButton urlPasteButton = new JButton();
    urlPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    urlPasteButton.setToolTipText("Paste");
    urlPasteButton.setEnabled(!readOnly);
    urlPasteButton.setMargin(new Insets(0, 0, 0, 0));
    urlPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(url);
        }
    });
    c.gridx = 3;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    urlPanel.add(urlPasteButton, c);

    c.gridx = 1;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(urlPanel, c);

    // Notes Row
    JLabel notesLabel = new JLabel(Translator.translate("notes"));
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(notesLabel, c);

    // This panel will hold the Notes text area and the copy and paste
    // buttons.
    JPanel notesPanel = new JPanel(new GridBagLayout());

    notes = new JTextArea(new String(pAccount.getNotes()), 10, 20);
    if (readOnly) {
        notes.setEditable(false);
    }
    notes.setLineWrap(true); // Enable line wrapping.
    notes.setWrapStyleWord(true); // Line wrap at whitespace.
    JScrollPane notesScrollPane = new JScrollPane(notes);
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.BOTH;
    notesPanel.add(notesScrollPane, c);

    JButton notesCopyButton = new JButton();
    notesCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    notesCopyButton.setToolTipText("Copy");
    notesCopyButton.setEnabled(true);
    notesCopyButton.setMargin(new Insets(0, 0, 0, 0));
    notesCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextArea(notes);
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    notesPanel.add(notesCopyButton, c);

    JButton notesPasteButton = new JButton();
    notesPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    notesPasteButton.setToolTipText("Paste");
    notesPasteButton.setEnabled(!readOnly);
    notesPasteButton.setMargin(new Insets(0, 0, 0, 0));
    notesPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextArea(notes);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    notesPanel.add(notesPasteButton, c);

    c.gridx = 1;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(notesPanel, c);

    // Seperator Row
    JSeparator sep = new JSeparator();
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.PAGE_END;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(sep, c);

    // Button Row
    JPanel buttonPanel = new JPanel();
    JButton okButton = new JButton(Translator.translate("ok"));
    // Link Enter key to okButton
    getRootPane().setDefaultButton(okButton);
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okButtonAction();
        }
    });
    buttonPanel.add(okButton);
    if (!readOnly) {
        JButton cancelButton = new JButton(Translator.translate("cancel"));
        cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                closeButtonAction();
            }
        });
        buttonPanel.add(cancelButton);
    }
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.PAGE_END;
    c.insets = new Insets(5, 0, 5, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.NONE;
    container.add(buttonPanel, c);
}

From source file:au.org.ala.delta.intkey.ui.FindInTaxaDialog.java

public FindInTaxaDialog(Intkey intkeyApp) {
    super(intkeyApp.getMainFrame(), false);
    setResizable(false);// w  ww  .  j  a  v a  2  s  .c  o  m

    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(FindInTaxaDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(this);

    _intkeyApp = intkeyApp;

    _numMatchedTaxa = 0;
    _currentMatchedTaxon = -1;

    _findAction = actionMap.get("findTaxa");
    _nextAction = actionMap.get("nextFoundTaxon");

    this.setTitle(windowTitle);

    getContentPane().setLayout(new BorderLayout(0, 0));

    _pnlMain = new JPanel();
    _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20));
    getContentPane().add(_pnlMain, BorderLayout.CENTER);
    _pnlMain.setLayout(new BorderLayout(0, 0));

    _pnlMainTop = new JPanel();
    _pnlMain.add(_pnlMainTop, BorderLayout.NORTH);
    _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS));

    _lblEnterSearchString = new JLabel(enterSearchStringCaption);
    _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0));
    _lblEnterSearchString.setHorizontalAlignment(SwingConstants.LEFT);
    _lblEnterSearchString.setVerticalAlignment(SwingConstants.TOP);
    _lblEnterSearchString.setAlignmentY(Component.TOP_ALIGNMENT);
    _pnlMainTop.add(_lblEnterSearchString);

    _textField = new JTextField();
    _textField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            reset();
        }

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

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

    _pnlMainTop.add(_textField);
    _textField.setColumns(10);

    _pnlMainMiddle = new JPanel();
    _pnlMainMiddle.setBorder(new EmptyBorder(10, 0, 0, 0));
    _pnlMain.add(_pnlMainMiddle, BorderLayout.CENTER);
    _pnlMainMiddle.setLayout(new BoxLayout(_pnlMainMiddle, BoxLayout.Y_AXIS));

    _rdbtnSelectOne = new JRadioButton(selectOneCaption);
    _rdbtnSelectOne.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });
    _pnlMainMiddle.add(_rdbtnSelectOne);

    _rdbtnSelectAll = new JRadioButton(selectAllCaption);
    _rdbtnSelectAll.setSelected(true);
    _rdbtnSelectAll.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });
    _pnlMainMiddle.add(_rdbtnSelectAll);

    ButtonGroup radioButtonGroup = new ButtonGroup();
    radioButtonGroup.add(_rdbtnSelectOne);
    radioButtonGroup.add(_rdbtnSelectAll);

    _pnlMainBottom = new JPanel();
    _pnlMain.add(_pnlMainBottom, BorderLayout.SOUTH);
    _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS));

    _chckbxSearchSynonyms = new JCheckBox(searchSynonymsCaption);
    _chckbxSearchSynonyms.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });

    _pnlMainBottom.add(_chckbxSearchSynonyms);

    _chckbxSearchEliminatedTaxa = new JCheckBox(searchEliminatedTaxaCaption);
    _chckbxSearchEliminatedTaxa.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });

    _pnlMainBottom.add(_chckbxSearchEliminatedTaxa);

    _pnlButtons = new JPanel();
    _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10));
    getContentPane().add(_pnlButtons, BorderLayout.EAST);
    _pnlButtons.setLayout(new BorderLayout(0, 0));

    _pnlInnerButtons = new JPanel();
    _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH);
    GridBagLayout gbl_pnlInnerButtons = new GridBagLayout();
    gbl_pnlInnerButtons.columnWidths = new int[] { 0, 0 };
    gbl_pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    _pnlInnerButtons.setLayout(gbl_pnlInnerButtons);

    _btnFindNext = new JButton();
    _btnFindNext.setAction(_findAction);
    GridBagConstraints gbc_btnFind = new GridBagConstraints();
    gbc_btnFind.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnFind.insets = new Insets(0, 0, 5, 0);
    gbc_btnFind.gridx = 0;
    gbc_btnFind.gridy = 0;
    _pnlInnerButtons.add(_btnFindNext, gbc_btnFind);

    _btnPrevious = new JButton();
    _btnPrevious.setAction(actionMap.get("previousFoundTaxon"));
    _btnPrevious.setEnabled(false);
    GridBagConstraints gbc_btnPrevious = new GridBagConstraints();
    gbc_btnPrevious.insets = new Insets(0, 0, 5, 0);
    gbc_btnPrevious.gridx = 0;
    gbc_btnPrevious.gridy = 1;
    _pnlInnerButtons.add(_btnPrevious, gbc_btnPrevious);

    _btnDone = new JButton();
    _btnDone.setAction(actionMap.get("findTaxaDone"));
    GridBagConstraints gbc_btnDone = new GridBagConstraints();
    gbc_btnDone.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnDone.gridx = 0;
    gbc_btnDone.gridy = 2;
    _pnlInnerButtons.add(_btnDone, gbc_btnDone);

    this.pack();
    this.setLocationRelativeTo(_intkeyApp.getMainFrame());
}

From source file:edu.harvard.mcz.imagecapture.VerbatimClassifyDialog.java

protected void init() {
    setTitle("Interpret verbatim data into fields.");
    setBounds(100, 100, 1203, 899);//from  ww w.j a  v a  2s  . c om
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
    {
        JPanel panelVerbatimValues = new JPanel();
        contentPanel.add(panelVerbatimValues);
        GridBagLayout gbl_panelVerbatimValues = new GridBagLayout();
        gbl_panelVerbatimValues.columnWidths = new int[] { 70, 0, 0, 0, 35, 0, 58, 0, 0, 0 };
        gbl_panelVerbatimValues.rowHeights = new int[] { 15, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                83, 0 };
        gbl_panelVerbatimValues.columnWeights = new double[] { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0,
                1.0 };
        gbl_panelVerbatimValues.rowWeights = new double[] { 1.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.0, 0.0, 1.0, Double.MIN_VALUE };
        panelVerbatimValues.setLayout(gbl_panelVerbatimValues);
        {
            lblCount = new JLabel("New label");
            GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
            gbc_lblNewLabel.gridwidth = 2;
            gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel.anchor = GridBagConstraints.SOUTHWEST;
            gbc_lblNewLabel.gridx = 0;
            gbc_lblNewLabel.gridy = 0;
            panelVerbatimValues.add(lblCount, gbc_lblNewLabel);
        }

        JButton buttonFillFromLast = new JButton("Fill From Last");
        GridBagConstraints gbc_buttonFillFromLast = new GridBagConstraints();
        gbc_buttonFillFromLast.anchor = GridBagConstraints.SOUTH;
        gbc_buttonFillFromLast.insets = new Insets(0, 0, 5, 5);
        gbc_buttonFillFromLast.gridx = 3;
        gbc_buttonFillFromLast.gridy = 0;
        panelVerbatimValues.add(buttonFillFromLast, gbc_buttonFillFromLast);
        {
            JLabel lblNewLabel_1 = new JLabel("Field values to apply to all records.");
            GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
            gbc_lblNewLabel_1.anchor = GridBagConstraints.SOUTHEAST;
            gbc_lblNewLabel_1.gridwidth = 4;
            gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel_1.gridx = 4;
            gbc_lblNewLabel_1.gridy = 0;
            panelVerbatimValues.add(lblNewLabel_1, gbc_lblNewLabel_1);
        }
        {
            JLabel lblNewLabel_2 = new JLabel("Verbatim Locality");
            GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
            gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
            gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
            gbc_lblNewLabel_2.gridx = 0;
            gbc_lblNewLabel_2.gridy = 1;
            panelVerbatimValues.add(lblNewLabel_2, gbc_lblNewLabel_2);
        }
        {
            textFieldVerbLocality = new JTextArea();
            textFieldVerbLocality.setEditable(false);
            textFieldVerbLocality.setRows(5);
            GridBagConstraints gbc_textField = new GridBagConstraints();
            gbc_textField.gridheight = 3;
            gbc_textField.insets = new Insets(0, 0, 5, 5);
            gbc_textField.fill = GridBagConstraints.BOTH;
            gbc_textField.gridx = 1;
            gbc_textField.gridy = 1;
            panelVerbatimValues.add(textFieldVerbLocality, gbc_textField);
            textFieldVerbLocality.setColumns(30);
        }

        JLabel lblNewLabel = new JLabel("HigherGeography");
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel.gridx = 3;
        gbc_lblNewLabel.gridy = 1;
        panelVerbatimValues.add(lblNewLabel, gbc_lblNewLabel);

        GridBagConstraints gbc_textFieldHigherGeography = new GridBagConstraints();
        gbc_textFieldHigherGeography.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldHigherGeography.gridwidth = 5;
        gbc_textFieldHigherGeography.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldHigherGeography.gridx = 4;
        gbc_textFieldHigherGeography.gridy = 1;
        panelVerbatimValues.add(getComboBoxHighGeog(), gbc_textFieldHigherGeography);

        JButton btnCopyLocality = new JButton(">");
        btnCopyLocality.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (textFieldSpecificLocality.getText().isEmpty()) {
                    textFieldSpecificLocality.setText(textFieldVerbLocality.getText().replace("\n", "").trim());
                }
            }
        });
        GridBagConstraints gbc_btnCopyLocality = new GridBagConstraints();
        gbc_btnCopyLocality.insets = new Insets(0, 0, 5, 5);
        gbc_btnCopyLocality.gridx = 2;
        gbc_btnCopyLocality.gridy = 2;
        panelVerbatimValues.add(btnCopyLocality, gbc_btnCopyLocality);

        JLabel lblSpecificLocality = new JLabel("Specific Locality");
        GridBagConstraints gbc_lblSpecificLocality = new GridBagConstraints();
        gbc_lblSpecificLocality.anchor = GridBagConstraints.EAST;
        gbc_lblSpecificLocality.insets = new Insets(0, 0, 5, 5);
        gbc_lblSpecificLocality.gridx = 3;
        gbc_lblSpecificLocality.gridy = 2;
        panelVerbatimValues.add(lblSpecificLocality, gbc_lblSpecificLocality);

        JLabel lblElevation = new JLabel("Elevation");
        GridBagConstraints gbc_lblElevation = new GridBagConstraints();
        gbc_lblElevation.anchor = GridBagConstraints.EAST;
        gbc_lblElevation.insets = new Insets(0, 0, 5, 5);
        gbc_lblElevation.gridx = 3;
        gbc_lblElevation.gridy = 3;
        panelVerbatimValues.add(lblElevation, gbc_lblElevation);

        textFieldMinElevation = new JTextField();
        textFieldMinElevation.setMinimumSize(new Dimension(60, 19));
        GridBagConstraints gbc_textFieldMinElevation = new GridBagConstraints();
        gbc_textFieldMinElevation.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldMinElevation.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldMinElevation.gridx = 4;
        gbc_textFieldMinElevation.gridy = 3;
        panelVerbatimValues.add(textFieldMinElevation, gbc_textFieldMinElevation);
        textFieldMinElevation.setColumns(4);

        JLabel lblTo = new JLabel("to");
        GridBagConstraints gbc_lblTo = new GridBagConstraints();
        gbc_lblTo.anchor = GridBagConstraints.EAST;
        gbc_lblTo.insets = new Insets(0, 0, 5, 5);
        gbc_lblTo.gridx = 5;
        gbc_lblTo.gridy = 3;
        panelVerbatimValues.add(lblTo, gbc_lblTo);

        textFieldMaxElevation = new JTextField();
        textFieldMaxElevation.setMinimumSize(new Dimension(60, 19));
        GridBagConstraints gbc_textFieldMaxElevation = new GridBagConstraints();
        gbc_textFieldMaxElevation.anchor = GridBagConstraints.WEST;
        gbc_textFieldMaxElevation.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldMaxElevation.gridx = 6;
        gbc_textFieldMaxElevation.gridy = 3;
        panelVerbatimValues.add(textFieldMaxElevation, gbc_textFieldMaxElevation);
        textFieldMaxElevation.setColumns(5);

        comboBoxElevUnits = new JComboBox();
        GridBagConstraints gbc_comboBoxElevUnits = new GridBagConstraints();
        gbc_comboBoxElevUnits.insets = new Insets(0, 0, 5, 5);
        gbc_comboBoxElevUnits.fill = GridBagConstraints.HORIZONTAL;
        gbc_comboBoxElevUnits.gridx = 7;
        gbc_comboBoxElevUnits.gridy = 3;
        panelVerbatimValues.add(comboBoxElevUnits, gbc_comboBoxElevUnits);
        {
            JLabel lblVerbatimdate = new JLabel("VerbatimDate");
            GridBagConstraints gbc_lblVerbatimdate = new GridBagConstraints();
            gbc_lblVerbatimdate.anchor = GridBagConstraints.EAST;
            gbc_lblVerbatimdate.insets = new Insets(0, 0, 5, 5);
            gbc_lblVerbatimdate.gridx = 0;
            gbc_lblVerbatimdate.gridy = 4;
            panelVerbatimValues.add(lblVerbatimdate, gbc_lblVerbatimdate);
        }

        textFieldVerbDate = new JTextField();
        GridBagConstraints gbc_textFieldVerbDate = new GridBagConstraints();
        gbc_textFieldVerbDate.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbDate.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbDate.gridx = 1;
        gbc_textFieldVerbDate.gridy = 4;
        panelVerbatimValues.add(textFieldVerbDate, gbc_textFieldVerbDate);
        textFieldVerbDate.setColumns(30);

        JButton btnCopyDate = new JButton(">");
        btnCopyDate.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (textFieldISODate.getText().isEmpty()) {
                    Map<String, String> extractResult = DateUtils
                            .extractDateFromVerbatim(textFieldVerbDate.getText().trim());
                    if (extractResult.containsKey("result")) {
                        textFieldISODate.setText(extractResult.get("result"));
                    }
                    if (extractResult.containsKey("resultState")) {
                        // TODO: Report suspect etc
                    }
                }
            }
        });
        GridBagConstraints gbc_btnCopyDate = new GridBagConstraints();
        gbc_btnCopyDate.insets = new Insets(0, 0, 5, 5);
        gbc_btnCopyDate.gridx = 2;
        gbc_btnCopyDate.gridy = 4;
        panelVerbatimValues.add(btnCopyDate, gbc_btnCopyDate);

        JLabel lblNewLabel_3 = new JLabel("ISO Date");
        GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
        gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_3.gridx = 3;
        gbc_lblNewLabel_3.gridy = 4;
        panelVerbatimValues.add(lblNewLabel_3, gbc_lblNewLabel_3);

        textFieldISODate = new JTextField();
        textFieldISODate.setInputVerifier(
                MetadataRetriever.getInputVerifier(Specimen.class, "ISODate", textFieldISODate));
        textFieldISODate.setToolTipText(MetadataRetriever.getFieldHelp(Specimen.class, "ISODate"));
        GridBagConstraints gbc_textFieldISODate = new GridBagConstraints();
        gbc_textFieldISODate.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldISODate.gridwidth = 5;
        gbc_textFieldISODate.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldISODate.gridx = 4;
        gbc_textFieldISODate.gridy = 4;
        panelVerbatimValues.add(textFieldISODate, gbc_textFieldISODate);
        textFieldISODate.setColumns(10);

        textFieldSpecificLocality = new JTextField();
        GridBagConstraints gbc_textFieldSpecificLocality = new GridBagConstraints();
        gbc_textFieldSpecificLocality.gridwidth = 5;
        gbc_textFieldSpecificLocality.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldSpecificLocality.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldSpecificLocality.gridx = 4;
        gbc_textFieldSpecificLocality.gridy = 2;
        panelVerbatimValues.add(textFieldSpecificLocality, gbc_textFieldSpecificLocality);
        textFieldSpecificLocality.setColumns(25);
        {
            JLabel lblVerbatimCollector = new JLabel("Verbatim Collector");
            GridBagConstraints gbc_lblVerbatimCollector = new GridBagConstraints();
            gbc_lblVerbatimCollector.anchor = GridBagConstraints.EAST;
            gbc_lblVerbatimCollector.insets = new Insets(0, 0, 5, 5);
            gbc_lblVerbatimCollector.gridx = 0;
            gbc_lblVerbatimCollector.gridy = 6;
            panelVerbatimValues.add(lblVerbatimCollector, gbc_lblVerbatimCollector);
        }

        textFieldVerbCollector = new JTextArea();
        textFieldVerbCollector.setEditable(false);
        textFieldVerbCollector.setRows(3);
        GridBagConstraints gbc_textFieldVerbCollector = new GridBagConstraints();
        gbc_textFieldVerbCollector.gridheight = 2;
        gbc_textFieldVerbCollector.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbCollector.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbCollector.gridx = 1;
        gbc_textFieldVerbCollector.gridy = 6;
        panelVerbatimValues.add(textFieldVerbCollector, gbc_textFieldVerbCollector);
        textFieldVerbCollector.setColumns(30);

        JLabel lblCollectors = new JLabel("Collector(s)");
        GridBagConstraints gbc_lblCollectors = new GridBagConstraints();
        gbc_lblCollectors.anchor = GridBagConstraints.EAST;
        gbc_lblCollectors.insets = new Insets(0, 0, 5, 5);
        gbc_lblCollectors.gridx = 3;
        gbc_lblCollectors.gridy = 6;
        panelVerbatimValues.add(lblCollectors, gbc_lblCollectors);

        JButton btnAddCollector = new JButton("+");
        btnAddCollector.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                ((CollectorTableModel) jTableCollectors.getModel()).addCollector(new Collector(null, ""));
            }
        });
        GridBagConstraints gbc_btnAddCollector = new GridBagConstraints();
        gbc_btnAddCollector.anchor = GridBagConstraints.EAST;
        gbc_btnAddCollector.insets = new Insets(0, 0, 5, 5);
        gbc_btnAddCollector.gridx = 3;
        gbc_btnAddCollector.gridy = 7;
        panelVerbatimValues.add(btnAddCollector, gbc_btnAddCollector);

        GridBagConstraints gbc_collectorTable = new GridBagConstraints();
        gbc_collectorTable.insets = new Insets(0, 0, 5, 5);
        gbc_collectorTable.fill = GridBagConstraints.BOTH;
        gbc_collectorTable.gridx = 4;
        gbc_collectorTable.gridy = 6;
        gbc_collectorTable.gridheight = 2;
        gbc_collectorTable.gridwidth = 5;
        panelVerbatimValues.add(getJScrollPaneCollectors(), gbc_collectorTable);

        JLabel lblVerbatimCollection = new JLabel("Verbatim Collection");
        GridBagConstraints gbc_lblVerbatimCollection = new GridBagConstraints();
        gbc_lblVerbatimCollection.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimCollection.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimCollection.gridx = 0;
        gbc_lblVerbatimCollection.gridy = 8;
        panelVerbatimValues.add(lblVerbatimCollection, gbc_lblVerbatimCollection);

        textFieldVerbCollection = new JTextArea();
        textFieldVerbCollection.setEditable(false);
        textFieldVerbCollection.setRows(3);
        GridBagConstraints gbc_textFieldVerbCollection = new GridBagConstraints();
        gbc_textFieldVerbCollection.gridheight = 2;
        gbc_textFieldVerbCollection.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbCollection.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbCollection.gridx = 1;
        gbc_textFieldVerbCollection.gridy = 8;
        panelVerbatimValues.add(textFieldVerbCollection, gbc_textFieldVerbCollection);
        textFieldVerbCollection.setColumns(30);

        JLabel lblCollection = new JLabel("Collection");
        GridBagConstraints gbc_lblCollection = new GridBagConstraints();
        gbc_lblCollection.anchor = GridBagConstraints.EAST;
        gbc_lblCollection.insets = new Insets(0, 0, 5, 5);
        gbc_lblCollection.gridx = 3;
        gbc_lblCollection.gridy = 8;
        panelVerbatimValues.add(lblCollection, gbc_lblCollection);

        GridBagConstraints gbc_textFieldCollection = new GridBagConstraints();
        gbc_textFieldCollection.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldCollection.gridwidth = 5;
        gbc_textFieldCollection.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldCollection.gridx = 4;
        gbc_textFieldCollection.gridy = 8;
        panelVerbatimValues.add(getJComboBoxCollection(), gbc_textFieldCollection);

        JLabel lblVerbatimNumbers = new JLabel("Verbatim Numbers");
        GridBagConstraints gbc_lblVerbatimNumbers = new GridBagConstraints();
        gbc_lblVerbatimNumbers.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimNumbers.gridx = 0;
        gbc_lblVerbatimNumbers.gridy = 10;
        panelVerbatimValues.add(lblVerbatimNumbers, gbc_lblVerbatimNumbers);

        textFieldVerbNumbers = new JTextArea();
        textFieldVerbNumbers.setRows(3);
        textFieldVerbNumbers.setEditable(false);
        GridBagConstraints gbc_textFieldVerbNumbers = new GridBagConstraints();
        gbc_textFieldVerbNumbers.gridheight = 2;
        gbc_textFieldVerbNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbNumbers.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbNumbers.gridx = 1;
        gbc_textFieldVerbNumbers.gridy = 10;
        panelVerbatimValues.add(textFieldVerbNumbers, gbc_textFieldVerbNumbers);
        textFieldVerbNumbers.setColumns(30);

        JLabel lblNumbers = new JLabel("Numbers");
        GridBagConstraints gbc_lblNumbers = new GridBagConstraints();
        gbc_lblNumbers.anchor = GridBagConstraints.EAST;
        gbc_lblNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_lblNumbers.gridx = 3;
        gbc_lblNumbers.gridy = 10;
        panelVerbatimValues.add(lblNumbers, gbc_lblNumbers);

        JButton btnAddNumber = new JButton("+");
        btnAddNumber.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                ((NumberTableModel) jTableNumbers.getModel())
                        .addNumber(new edu.harvard.mcz.imagecapture.data.Number(null, "", ""));
            }
        });
        GridBagConstraints gbc_btnAddNumber = new GridBagConstraints();
        gbc_btnAddNumber.anchor = GridBagConstraints.EAST;
        gbc_btnAddNumber.insets = new Insets(0, 0, 5, 5);
        gbc_btnAddNumber.gridx = 3;
        gbc_btnAddNumber.gridy = 11;
        panelVerbatimValues.add(btnAddNumber, gbc_btnAddNumber);

        GridBagConstraints gbc_numberTable = new GridBagConstraints();
        gbc_numberTable.insets = new Insets(0, 0, 5, 5);
        gbc_numberTable.fill = GridBagConstraints.BOTH;
        gbc_numberTable.gridx = 4;
        gbc_numberTable.gridy = 10;
        gbc_numberTable.gridheight = 2;
        gbc_numberTable.gridwidth = 5;
        panelVerbatimValues.add(this.getJScrollPaneNumbers(), gbc_numberTable);

        JLabel lblVerbatimOtherText = new JLabel("Verbatim Other Text");
        GridBagConstraints gbc_lblVerbatimOtherText = new GridBagConstraints();
        gbc_lblVerbatimOtherText.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimOtherText.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimOtherText.gridx = 0;
        gbc_lblVerbatimOtherText.gridy = 12;
        panelVerbatimValues.add(lblVerbatimOtherText, gbc_lblVerbatimOtherText);

        textFieldVerbUnclassifiedText = new JTextArea();
        textFieldVerbUnclassifiedText.setEditable(false);
        textFieldVerbUnclassifiedText.setRows(5);
        GridBagConstraints gbc_textFieldVerbUnclassifiedText = new GridBagConstraints();
        gbc_textFieldVerbUnclassifiedText.gridheight = 3;
        gbc_textFieldVerbUnclassifiedText.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbUnclassifiedText.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbUnclassifiedText.gridx = 1;
        gbc_textFieldVerbUnclassifiedText.gridy = 12;
        panelVerbatimValues.add(textFieldVerbUnclassifiedText, gbc_textFieldVerbUnclassifiedText);
        textFieldVerbUnclassifiedText.setColumns(30);

        JLabel lblHabitat = new JLabel("Habitat");
        GridBagConstraints gbc_lblHabitat = new GridBagConstraints();
        gbc_lblHabitat.anchor = GridBagConstraints.EAST;
        gbc_lblHabitat.insets = new Insets(0, 0, 5, 5);
        gbc_lblHabitat.gridx = 3;
        gbc_lblHabitat.gridy = 12;
        panelVerbatimValues.add(lblHabitat, gbc_lblHabitat);

        textFieldHabitat = new JTextField();
        GridBagConstraints gbc_textFieldHabitat = new GridBagConstraints();
        gbc_textFieldHabitat.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldHabitat.gridwidth = 4;
        gbc_textFieldHabitat.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldHabitat.gridx = 4;
        gbc_textFieldHabitat.gridy = 12;
        panelVerbatimValues.add(textFieldHabitat, gbc_textFieldHabitat);
        textFieldHabitat.setColumns(10);

        JLabel lblMicrohabitat = new JLabel("Microhabitat");
        GridBagConstraints gbc_lblMicrohabitat = new GridBagConstraints();
        gbc_lblMicrohabitat.anchor = GridBagConstraints.EAST;
        gbc_lblMicrohabitat.insets = new Insets(0, 0, 5, 5);
        gbc_lblMicrohabitat.gridx = 3;
        gbc_lblMicrohabitat.gridy = 13;
        panelVerbatimValues.add(lblMicrohabitat, gbc_lblMicrohabitat);

        textFieldMicrohabitat = new JTextField();
        GridBagConstraints gbc_textFieldMicrohabitat = new GridBagConstraints();
        gbc_textFieldMicrohabitat.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldMicrohabitat.gridwidth = 4;
        gbc_textFieldMicrohabitat.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldMicrohabitat.gridx = 4;
        gbc_textFieldMicrohabitat.gridy = 13;
        panelVerbatimValues.add(textFieldMicrohabitat, gbc_textFieldMicrohabitat);
        textFieldMicrohabitat.setColumns(10);

        JLabel lblNewLabel_4 = new JLabel("Workflow Status");
        GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
        gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_4.gridx = 3;
        gbc_lblNewLabel_4.gridy = 15;
        panelVerbatimValues.add(lblNewLabel_4, gbc_lblNewLabel_4);

        comboBoxWorkflowStatus = new JComboBox(WorkFlowStatus.getVerbatimClassifiedWorkFlowStatusValues());
        comboBoxWorkflowStatus.setSelectedItem(WorkFlowStatus.STAGE_CLASSIFIED);
        GridBagConstraints gbc_comboBoxWorkflowStatus = new GridBagConstraints();
        gbc_comboBoxWorkflowStatus.gridwidth = 4;
        gbc_comboBoxWorkflowStatus.fill = GridBagConstraints.HORIZONTAL;
        gbc_comboBoxWorkflowStatus.insets = new Insets(0, 0, 5, 5);
        gbc_comboBoxWorkflowStatus.gridx = 4;
        gbc_comboBoxWorkflowStatus.gridy = 15;
        panelVerbatimValues.add(comboBoxWorkflowStatus, gbc_comboBoxWorkflowStatus);

        JButton btnApplyToAll = new JButton("Apply To All Records");
        GridBagConstraints gbc_btnApplyToAll = new GridBagConstraints();
        gbc_btnApplyToAll.gridwidth = 4;
        gbc_btnApplyToAll.insets = new Insets(0, 0, 5, 5);
        gbc_btnApplyToAll.gridx = 4;
        gbc_btnApplyToAll.gridy = 16;
        panelVerbatimValues.add(btnApplyToAll, gbc_btnApplyToAll);
        btnApplyToAll.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveChanges();
            }
        });
    }
    {
        JPanel panelRelatedData = new JPanel();
        contentPanel.add(panelRelatedData);
        GridBagLayout gbl_panelRelatedData = new GridBagLayout();
        gbl_panelRelatedData.maximumLayoutSize(panelRelatedData);
        gbl_panelRelatedData.columnWidths = new int[] { 20, 33, 1, 0 };
        gbl_panelRelatedData.rowHeights = new int[] { 25, 0 };
        gbl_panelRelatedData.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
        gbl_panelRelatedData.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
        panelRelatedData.setLayout(gbl_panelRelatedData);
        {
            JLabel lblTaxa = new JLabel("Taxa");
            GridBagConstraints gbc_lblTaxa = new GridBagConstraints();
            gbc_lblTaxa.anchor = GridBagConstraints.NORTHEAST;
            gbc_lblTaxa.insets = new Insets(0, 0, 0, 5);
            gbc_lblTaxa.gridx = 0;
            gbc_lblTaxa.gridy = 0;
            panelRelatedData.add(lblTaxa, gbc_lblTaxa);
        }

        JScrollPane scrollPane = new JScrollPane();
        // scrollPane.setPreferredSize(new Dimension(1000,100));
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.anchor = GridBagConstraints.NORTH;
        gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 1;
        gbc_scrollPane.gridy = 0;
        panelRelatedData.add(scrollPane, gbc_scrollPane);

        tableTaxa = new JTable();
        SpecimenLifeCycle sls = new SpecimenLifeCycle();
        tableTaxa.setModel(new CountValueTableModel(sls.findTaxaFromVerbatim(this.verbatimData),
                "Current Idenfifications for these verbatim values."));
        scrollPane.setViewportView(tableTaxa);
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton cancelButton = new JButton("Close");
            cancelButton.setActionCommand("Close");
            cancelButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java

private Component createImportExportButtons() {
    JPanel p = new JPanel(new GridBagLayout());
    p.setOpaque(false);//  w w  w .j a  va  2s  . c om

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);

    GridBagLayoutManager.addComponent(p, createImportButton(), c, 0, 0, 1, 1, 0.5, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    GridBagLayoutManager.addComponent(p, createExportButton(), c, 1, 0, 1, 1, 0.5, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    return p;
}

From source file:edu.harvard.mcz.imagecapture.VerbatimCaptureDialog.java

protected void init() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setTitle("Transcribe Verbatim Data");
    setMinimumSize(new Dimension(1020, 640));
    setBounds(100, 100, 1020, 640);/*from  w w w .  j a va 2  s  .com*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
        JPanel panel = new JPanel();
        contentPanel.add(panel, BorderLayout.NORTH);
        panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

        JLabel lblVerbatimDataFor = new JLabel("Verbatim Data for:");
        panel.add(lblVerbatimDataFor);
        lblBarcode = new JLabel("Barcode");
        panel.add(lblBarcode);
        lblCurrentid = new JLabel("CurrentID");
        panel.add(lblCurrentid);
    }
    {
        JPanel panel = new JPanel();
        contentPanel.add(panel, BorderLayout.WEST);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] { 0, 0, 0, 0 };
        gbl_panel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        gbl_panel.columnWeights = new double[] { 0.0, 1.0, 1.0, Double.MIN_VALUE };
        gbl_panel.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, 1.0,
                Double.MIN_VALUE };
        panel.setLayout(gbl_panel);

        JLabel lblNewLabel = new JLabel("Locality");
        GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
        gbc_lblNewLabel.anchor = GridBagConstraints.NORTHEAST;
        gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel.gridx = 0;
        gbc_lblNewLabel.gridy = 0;
        panel.add(lblNewLabel, gbc_lblNewLabel);

        textFieldVerbLocality = new JTextArea();
        textFieldVerbLocality.setRows(3);
        GridBagConstraints gbc_textFieldVerbLocality = new GridBagConstraints();
        gbc_textFieldVerbLocality.gridheight = 2;
        gbc_textFieldVerbLocality.gridwidth = 2;
        gbc_textFieldVerbLocality.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbLocality.fill = GridBagConstraints.BOTH;
        gbc_textFieldVerbLocality.gridx = 1;
        gbc_textFieldVerbLocality.gridy = 0;
        panel.add(textFieldVerbLocality, gbc_textFieldVerbLocality);
        textFieldVerbLocality.setColumns(10);

        JLabel lblVerbatimDate = new JLabel("Date");
        GridBagConstraints gbc_lblVerbatimDate = new GridBagConstraints();
        gbc_lblVerbatimDate.anchor = GridBagConstraints.EAST;
        gbc_lblVerbatimDate.insets = new Insets(0, 0, 5, 5);
        gbc_lblVerbatimDate.gridx = 0;
        gbc_lblVerbatimDate.gridy = 2;
        panel.add(lblVerbatimDate, gbc_lblVerbatimDate);

        textFieldVerbDate = new JTextField();
        GridBagConstraints gbc_textFieldVerbDate = new GridBagConstraints();
        gbc_textFieldVerbDate.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbDate.gridwidth = 2;
        gbc_textFieldVerbDate.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbDate.gridx = 1;
        gbc_textFieldVerbDate.gridy = 2;
        panel.add(textFieldVerbDate, gbc_textFieldVerbDate);
        textFieldVerbDate.setColumns(10);

        JLabel lblCollector = new JLabel("Collector");
        GridBagConstraints gbc_lblCollector = new GridBagConstraints();
        gbc_lblCollector.anchor = GridBagConstraints.EAST;
        gbc_lblCollector.insets = new Insets(0, 0, 5, 5);
        gbc_lblCollector.gridx = 0;
        gbc_lblCollector.gridy = 3;
        panel.add(lblCollector, gbc_lblCollector);

        textFieldVerbCollector = new JTextField();
        GridBagConstraints gbc_textFieldVerbCollector = new GridBagConstraints();
        gbc_textFieldVerbCollector.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbCollector.gridwidth = 2;
        gbc_textFieldVerbCollector.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbCollector.gridx = 1;
        gbc_textFieldVerbCollector.gridy = 3;
        panel.add(textFieldVerbCollector, gbc_textFieldVerbCollector);
        textFieldVerbCollector.setColumns(10);

        JLabel lblNewLabel_1 = new JLabel("Collection");
        GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
        gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_1.gridx = 0;
        gbc_lblNewLabel_1.gridy = 4;
        panel.add(lblNewLabel_1, gbc_lblNewLabel_1);

        textFieldVerbCollection = new JTextField();
        GridBagConstraints gbc_textFieldVerbCollection = new GridBagConstraints();
        gbc_textFieldVerbCollection.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbCollection.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbCollection.gridx = 2;
        gbc_textFieldVerbCollection.gridy = 4;
        panel.add(textFieldVerbCollection, gbc_textFieldVerbCollection);
        textFieldVerbCollection.setColumns(10);

        JLabel lblNumbers = new JLabel("Numbers");
        GridBagConstraints gbc_lblNumbers = new GridBagConstraints();
        gbc_lblNumbers.anchor = GridBagConstraints.EAST;
        gbc_lblNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_lblNumbers.gridx = 0;
        gbc_lblNumbers.gridy = 5;
        panel.add(lblNumbers, gbc_lblNumbers);

        textFieldVerbNumbers = new JTextField();
        GridBagConstraints gbc_textFieldVerbNumbers = new GridBagConstraints();
        gbc_textFieldVerbNumbers.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbNumbers.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbNumbers.gridx = 2;
        gbc_textFieldVerbNumbers.gridy = 5;
        panel.add(textFieldVerbNumbers, gbc_textFieldVerbNumbers);
        textFieldVerbNumbers.setColumns(10);

        JLabel lblNewLabel_2 = new JLabel("Other Text");
        GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
        gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
        gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
        gbc_lblNewLabel_2.gridx = 0;
        gbc_lblNewLabel_2.gridy = 6;
        panel.add(lblNewLabel_2, gbc_lblNewLabel_2);

        textFieldVerbUnclassifiedText = new JTextArea();
        textFieldVerbUnclassifiedText.setRows(3);
        GridBagConstraints gbc_textFieldVerbUnclassifiedText = new GridBagConstraints();
        gbc_textFieldVerbUnclassifiedText.gridheight = 2;
        gbc_textFieldVerbUnclassifiedText.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldVerbUnclassifiedText.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldVerbUnclassifiedText.gridx = 2;
        gbc_textFieldVerbUnclassifiedText.gridy = 6;
        panel.add(textFieldVerbUnclassifiedText, gbc_textFieldVerbUnclassifiedText);
        textFieldVerbUnclassifiedText.setColumns(10);

        JLabel lblQuestions = new JLabel("Questions");
        GridBagConstraints gbc_lblQuestions = new GridBagConstraints();
        gbc_lblQuestions.anchor = GridBagConstraints.EAST;
        gbc_lblQuestions.insets = new Insets(0, 0, 5, 5);
        gbc_lblQuestions.gridx = 0;
        gbc_lblQuestions.gridy = 8;
        panel.add(lblQuestions, gbc_lblQuestions);

        textFieldQuestions = new JTextField();
        GridBagConstraints gbc_textFieldQuestions = new GridBagConstraints();
        gbc_textFieldQuestions.insets = new Insets(0, 0, 5, 5);
        gbc_textFieldQuestions.fill = GridBagConstraints.HORIZONTAL;
        gbc_textFieldQuestions.gridx = 2;
        gbc_textFieldQuestions.gridy = 8;
        panel.add(textFieldQuestions, gbc_textFieldQuestions);
        textFieldQuestions.setColumns(30);

        JLabel lblWorkflowStatus = new JLabel("Workflow Status");
        GridBagConstraints gbc_lblWorkflowStatus = new GridBagConstraints();
        gbc_lblWorkflowStatus.anchor = GridBagConstraints.EAST;
        gbc_lblWorkflowStatus.insets = new Insets(0, 0, 5, 5);
        gbc_lblWorkflowStatus.gridx = 0;
        gbc_lblWorkflowStatus.gridy = 9;
        panel.add(lblWorkflowStatus, gbc_lblWorkflowStatus);

        comboBoxWorkflowStatus = new JComboBox<String>(WorkFlowStatus.getVerbatimWorkFlowStatusValues());
        GridBagConstraints gbc_comboBoxWorkflowStatus = new GridBagConstraints();
        gbc_comboBoxWorkflowStatus.insets = new Insets(0, 0, 5, 0);
        gbc_comboBoxWorkflowStatus.gridwidth = 2;
        gbc_comboBoxWorkflowStatus.fill = GridBagConstraints.HORIZONTAL;
        gbc_comboBoxWorkflowStatus.gridx = 2;
        gbc_comboBoxWorkflowStatus.gridy = 9;
        panel.add(comboBoxWorkflowStatus, gbc_comboBoxWorkflowStatus);

        JPanel panel_1 = new JPanel();
        GridBagConstraints gbc_panel_1 = new GridBagConstraints();
        gbc_panel_1.gridwidth = 2;
        gbc_panel_1.insets = new Insets(0, 0, 0, 5);
        gbc_panel_1.fill = GridBagConstraints.BOTH;
        gbc_panel_1.gridx = 2;
        gbc_panel_1.gridy = 11;
        panel.add(panel_1, gbc_panel_1);
        GridBagLayout gbl_panel_1 = new GridBagLayout();
        gbl_panel_1.columnWidths = new int[] { 150, 143, 0 };
        gbl_panel_1.rowHeights = new int[] { 25, 0, 0, 0, 0 };
        gbl_panel_1.columnWeights = new double[] { 0.0, 0.0, 0.0 };
        gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
        panel_1.setLayout(gbl_panel_1);

        JButton btnPartiallyIllegible = new JButton("Partially Illegible");
        btnPartiallyIllegible.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                appendToQuestions(Verbatim.PARTLY_ILLEGIBLE);

            }
        });
        GridBagConstraints gbc_btnPartiallyIllegible = new GridBagConstraints();
        gbc_btnPartiallyIllegible.fill = GridBagConstraints.HORIZONTAL;
        gbc_btnPartiallyIllegible.anchor = GridBagConstraints.NORTH;
        gbc_btnPartiallyIllegible.insets = new Insets(0, 0, 5, 5);
        gbc_btnPartiallyIllegible.gridx = 0;
        gbc_btnPartiallyIllegible.gridy = 0;
        panel_1.add(btnPartiallyIllegible, gbc_btnPartiallyIllegible);

        JButton btnNewButton = new JButton("No Locality Data");
        btnNewButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                textFieldVerbLocality.setText(Verbatim.NO_LOCALITY_DATA);
            }
        });
        GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
        gbc_btnNewButton.anchor = GridBagConstraints.NORTHWEST;
        gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
        gbc_btnNewButton.gridx = 1;
        gbc_btnNewButton.gridy = 0;
        panel_1.add(btnNewButton, gbc_btnNewButton);
        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            }
        });

        JButton btnNewButton_1 = new JButton("Entirely Illegible");
        btnNewButton_1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                appendToQuestions(Verbatim.ENTIRELY_ILLEGIBLE);
            }
        });
        GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
        gbc_btnNewButton_1.fill = GridBagConstraints.HORIZONTAL;
        gbc_btnNewButton_1.anchor = GridBagConstraints.NORTH;
        gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 5);
        gbc_btnNewButton_1.gridx = 0;
        gbc_btnNewButton_1.gridy = 1;
        panel_1.add(btnNewButton_1, gbc_btnNewButton_1);

        JButton btnNoDateData = new JButton("No Date Data");
        btnNoDateData.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                textFieldVerbDate.setText("[No date data]");
            }
        });
        GridBagConstraints gbc_btnNoDateData = new GridBagConstraints();
        gbc_btnNoDateData.fill = GridBagConstraints.HORIZONTAL;
        gbc_btnNoDateData.insets = new Insets(0, 0, 5, 5);
        gbc_btnNoDateData.gridx = 1;
        gbc_btnNoDateData.gridy = 1;
        panel_1.add(btnNoDateData, gbc_btnNoDateData);

        JButton btnLabelTruncatedIn = new JButton("Label Truncated in Image");
        btnLabelTruncatedIn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                appendToQuestions(Verbatim.TRUNCATED_BY_IMAGE);
            }
        });
        GridBagConstraints gbc_btnLabelTruncatedIn = new GridBagConstraints();
        gbc_btnLabelTruncatedIn.insets = new Insets(0, 0, 5, 5);
        gbc_btnLabelTruncatedIn.anchor = GridBagConstraints.NORTHWEST;
        gbc_btnLabelTruncatedIn.gridx = 0;
        gbc_btnLabelTruncatedIn.gridy = 2;
        panel_1.add(btnLabelTruncatedIn, gbc_btnLabelTruncatedIn);

        JButton btnNoCollectorData = new JButton("No Collector Data");
        btnNoCollectorData.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                textFieldVerbCollector.setText("[No collector data]");
            }
        });
        GridBagConstraints gbc_btnNoCollectorData = new GridBagConstraints();
        gbc_btnNoCollectorData.insets = new Insets(0, 0, 5, 5);
        gbc_btnNoCollectorData.gridx = 1;
        gbc_btnNoCollectorData.gridy = 2;
        panel_1.add(btnNoCollectorData, gbc_btnNoCollectorData);

        JButton btnNoPinLabels = new JButton("No Pin Labels");
        btnNoPinLabels.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                appendToQuestions(Verbatim.NO_PIN_LABELS);
            }
        });
        GridBagConstraints gbc_btnNoPinLabels = new GridBagConstraints();
        gbc_btnNoPinLabels.insets = new Insets(0, 0, 0, 5);
        gbc_btnNoPinLabels.gridx = 0;
        gbc_btnNoPinLabels.gridy = 3;
        panel_1.add(btnNoPinLabels, gbc_btnNoPinLabels);
    }
    {
        JPanel panel = new JPanel();
        contentPanel.add(panel, BorderLayout.CENTER);
        panel.setLayout(new BorderLayout(0, 0));

        panel.add(getImagePanePinLabels());
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);

        btnPrevious = new JButton("Previous");
        btnPrevious.setEnabled(false);
        if (specimenControler != null && specimenControler.isInTable()) {
            btnPrevious.setEnabled(true);
        }
        btnPrevious.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                save();
                if (specimenControler.previousSpecimenInTable()) {
                    specimen = specimenControler.getSpecimen();
                    setValues();
                }
            }
        });
        buttonPane.add(btnPrevious);

        btnNext = new JButton("Next");
        btnNext.setEnabled(false);
        if (specimenControler != null && specimenControler.isInTable()) {
            btnNext.setEnabled(true);
        }
        btnNext.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                save();
                if (specimenControler.nextSpecimenInTable()) {
                    specimen = specimenControler.getSpecimen();
                    setValues();
                }
            }
        });
        buttonPane.add(btnNext);
        {
            JButton okButton = new JButton("OK");
            okButton.setActionCommand("OK");
            okButton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    if (save()) {
                        setVisible(false);
                    }
                }

            });
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.setActionCommand("Cancel");
            cancelButton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    setVisible(false);
                }

            });
            buttonPane.add(cancelButton);
        }
    }
}

From source file:ViewDB.java

 /**
 * Constructs the data panel./* w ww .jav  a2 s.c o m*/
 * @param rs the result set whose contents this panel displays
 */
public DataPanel(RowSet rs) throws SQLException
{
   fields = new ArrayList<JTextField>();
   setLayout(new GridBagLayout());
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.gridwidth = 1;
   gbc.gridheight = 1;

   ResultSetMetaData rsmd = rs.getMetaData();
   for (int i = 1; i <= rsmd.getColumnCount(); i++)
   {
      gbc.gridy = i - 1;

      String columnName = rsmd.getColumnLabel(i);
      gbc.gridx = 0;
      gbc.anchor = GridBagConstraints.EAST;
      add(new JLabel(columnName), gbc);

      int columnWidth = rsmd.getColumnDisplaySize(i);
      JTextField tb = new JTextField(columnWidth);
      if (!rsmd.getColumnClassName(i).equals("java.lang.String"))
         tb.setEditable(false);
               
      fields.add(tb);

      gbc.gridx = 1;
      gbc.anchor = GridBagConstraints.WEST;
      add(tb, gbc);
   }
}