Example usage for java.awt GridBagConstraints CENTER

List of usage examples for java.awt GridBagConstraints CENTER

Introduction

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

Prototype

int CENTER

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

Click Source Link

Document

Put the component in the center of its display area.

Usage

From source file:gov.loc.repository.bagger.ui.NewBagFrame.java

private void layoutBagVersionSelection(JPanel contentPane, int row) {
    //contents//w ww . j  a  v  a2s.  co  m
    // Bag version dropdown list
    JLabel bagVersionLabel = new JLabel(bagView.getPropertyMessage("bag.label.version"));
    bagVersionLabel.setToolTipText(bagView.getPropertyMessage("bag.versionlist.help"));
    ArrayList<String> versionModel = new ArrayList<String>();
    Version[] vals = Version.values();
    for (int i = 0; i < vals.length; i++) {
        versionModel.add(vals[i].versionString);
    }

    bagVersionList = new JComboBox(versionModel.toArray());
    bagVersionList.setName(bagView.getPropertyMessage("bag.label.versionlist"));
    bagVersionList.setSelectedItem(Version.V0_96.versionString);
    bagVersionList.setToolTipText(bagView.getPropertyMessage("bag.versionlist.help"));

    GridBagConstraints glbc = null;

    JLabel spacerLabel = new JLabel();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    contentPane.add(bagVersionLabel, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPane.add(bagVersionList, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPane.add(spacerLabel, glbc);
}

From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.ConfigurationDialog.java

ConfigurationDialog(final Component owner, final UploaderGuiController controller,
        final GiftCloudPropertiesFromApplication giftCloudProperties, final ProjectListModel projectListModel,
        final ResourceBundle resourceBundle, final GiftCloudDialogs giftCloudDialogs,
        final GiftCloudReporter reporter) {
    this.controller = controller;
    this.giftCloudProperties = giftCloudProperties;
    this.projectListModel = projectListModel;
    this.resourceBundle = resourceBundle;
    this.giftCloudDialogs = giftCloudDialogs;
    this.reporter = reporter;
    temporaryDropDownListModel = new TemporaryProjectListModel(projectListModel,
            giftCloudProperties.getLastProject());
    componentToCenterDialogOver = owner;

    dialog = new JDialog();
    dialog.setModal(true);/* www.  ja v  a 2 s.  co m*/
    dialog.setResizable(false);

    // Call custom dialog close code when the close button is clicked
    dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            closeDialog();
        }
    });

    dialog.setLocationRelativeTo(componentToCenterDialogOver); // without this, appears at TLHC rather then center of parent or screen
    dialog.setTitle(resourceBundle.getString("configurationDialogTitle"));

    final GridBagConstraints sectionTitleConstraints = new GridBagConstraints();
    sectionTitleConstraints.gridx = 0;
    sectionTitleConstraints.gridy = 1;
    sectionTitleConstraints.gridwidth = 2;
    sectionTitleConstraints.weightx = 1;
    sectionTitleConstraints.weighty = 1;
    sectionTitleConstraints.anchor = GridBagConstraints.CENTER;
    sectionTitleConstraints.fill = GridBagConstraints.HORIZONTAL;

    final GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.gridx = 0;
    labelConstraints.gridy = 0;
    labelConstraints.gridwidth = 1;
    labelConstraints.weightx = 1;
    labelConstraints.weighty = 1;
    labelConstraints.anchor = GridBagConstraints.LINE_START;
    labelConstraints.fill = GridBagConstraints.NONE;

    final GridBagConstraints inputConstraints = new GridBagConstraints();
    inputConstraints.gridx = 1;
    inputConstraints.gridy = 0;
    inputConstraints.gridwidth = 1;
    inputConstraints.weightx = 1;
    inputConstraints.weighty = 1;
    inputConstraints.anchor = GridBagConstraints.LINE_END;
    inputConstraints.fill = GridBagConstraints.HORIZONTAL;

    GridBagConstraints separatorConstraint = new GridBagConstraints();
    separatorConstraint.weightx = 1.0;
    separatorConstraint.fill = GridBagConstraints.HORIZONTAL;
    separatorConstraint.gridwidth = GridBagConstraints.REMAINDER;

    // The panel containing the GIFT-Cloud server configuration
    final JPanel giftCloudServerPanel = new JPanel();
    {
        GridBagLayout projectUploadlayout = new GridBagLayout();
        giftCloudServerPanel.setLayout(projectUploadlayout);
        JLabel serverPanelLabel = new JLabel(resourceBundle.getString("configPanelServerConfig"),
                SwingConstants.CENTER);
        giftCloudServerPanel.add(serverPanelLabel, sectionTitleConstraints);

        // GIFT-Cloud server URL
        {
            labelConstraints.gridwidth = 1;
            labelConstraints.gridy = 2;
            final JLabel giftCloudServerLabel = new JLabel(resourceBundle.getString("giftCloudServerText"),
                    SwingConstants.RIGHT);
            giftCloudServerLabel.setToolTipText(resourceBundle.getString("giftCloudServerTextToolTipText"));
            giftCloudServerPanel.add(giftCloudServerLabel, labelConstraints);

            giftCloudServerText = new AutoFocusTextField(giftCloudProperties.getGiftCloudUrl().orElse(""),
                    textFieldLengthForGiftCloudServerUrl);
            inputConstraints.gridy = 2;
            giftCloudServerPanel.add(giftCloudServerText, inputConstraints);
        }

        // GIFT-Cloud username
        {
            labelConstraints.gridy = 3;
            final JLabel giftCloudUserNameLabel = new JLabel(resourceBundle.getString("giftCloudUsername"),
                    SwingConstants.RIGHT);
            giftCloudUserNameLabel.setToolTipText(resourceBundle.getString("giftCloudUsernameToolTipText"));
            giftCloudServerPanel.add(giftCloudUserNameLabel, labelConstraints);

            final Optional<String> serverUrl = giftCloudProperties.getLastUserName();
            final String initialServerText = serverUrl.isPresent() ? serverUrl.get() : "";
            giftCloudUsernameText = new AutoFocusTextField(initialServerText);
            inputConstraints.gridy = 3;
            giftCloudServerPanel.add(giftCloudUsernameText, inputConstraints);
        }

        // GIFT-Cloud password
        {
            labelConstraints.gridy = 4;
            final JLabel giftCloudPasswordLabel = new JLabel(resourceBundle.getString("giftCloudPassword"),
                    SwingConstants.RIGHT);
            giftCloudPasswordLabel.setToolTipText(resourceBundle.getString("giftCloudPasswordToolTipText"));
            giftCloudServerPanel.add(giftCloudPasswordLabel, labelConstraints);

            final Optional<char[]> password = giftCloudProperties.getLastPassword();
            final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray();
            giftCloudPasswordText = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field
            inputConstraints.gridy = 4;
            giftCloudServerPanel.add(giftCloudPasswordText, inputConstraints);
        }

        // Project list
        {
            labelConstraints.gridy = 5;
            JLabel projectListLabel = new JLabel(resourceBundle.getString("giftCloudProjectLabelText"),
                    SwingConstants.RIGHT);
            giftCloudServerPanel.add(projectListLabel, labelConstraints);

            inputConstraints.gridy = 5;
            projectList = new BackwardsCompatibleComboBox();
            projectList.setEditable(false);
            projectList.setToolTipText(resourceBundle.getString("giftCloudProjectTooltip"));
            giftCloudServerPanel.add(projectList, inputConstraints);

            labelConstraints.gridx = 1;
            projectListWaitingLabel = new JLabel(resourceBundle.getString("giftCloudProjectWaitingLabelText"),
                    SwingConstants.RIGHT);
            giftCloudServerPanel.add(projectListWaitingLabel, labelConstraints);
            labelConstraints.gridx = 0;
        }

        // Subject prefix
        {
            labelConstraints.gridy = 6;
            JLabel subjectPrefixLabel = new JLabel(resourceBundle.getString("configPanelListenerSubjectPrefix"),
                    SwingConstants.RIGHT);
            subjectPrefixLabel
                    .setToolTipText(resourceBundle.getString("configPanelListenerSubjectPrefixTooltip"));
            giftCloudServerPanel.add(subjectPrefixLabel, labelConstraints);

            inputConstraints.gridy = 6;
            final Optional<String> subjectPrefixText = giftCloudProperties.getSubjectPrefix();
            subjectPrefixField = new AutoFocusTextField(subjectPrefixText.orElse(""));
            giftCloudServerPanel.add(subjectPrefixField, inputConstraints);
        }
    }

    // Local Dicom node configuration
    final JPanel listenerPanel = new JPanel();
    {
        GridBagLayout listenerPanellayout = new GridBagLayout();
        listenerPanel.setLayout(listenerPanellayout);
        JSeparator separator = new JSeparator();
        listenerPanel.add(separator, separatorConstraint);

        JLabel listenerPanelLabel = new JLabel(resourceBundle.getString("configPanelListenerConfig"),
                SwingConstants.CENTER);
        listenerPanel.add(listenerPanelLabel, sectionTitleConstraints);

        {
            labelConstraints.gridy = 2;
            JLabel listeningAETitleJLabel = new JLabel(resourceBundle.getString("configPanelListenerAe"),
                    SwingConstants.RIGHT);
            listeningAETitleJLabel.setToolTipText(resourceBundle.getString("configPanelListenerAeToolTip"));
            listenerPanellayout.setConstraints(listeningAETitleJLabel, labelConstraints);
            listenerPanel.add(listeningAETitleJLabel);

            inputConstraints.gridy = 2;
            final String listeningAETitleInitialText = giftCloudProperties.getListenerAETitle();
            listeningAETitleField = new AutoFocusTextField(listeningAETitleInitialText);
            listenerPanellayout.setConstraints(listeningAETitleField, inputConstraints);
            listenerPanel.add(listeningAETitleField);
        }
        {
            labelConstraints.gridy = 3;
            JLabel listeningPortJLabel = new JLabel(resourceBundle.getString("configPanelListenerPort"),
                    SwingConstants.RIGHT);
            listeningPortJLabel.setToolTipText(resourceBundle.getString("configPanelListenerPortToolTip"));
            listenerPanellayout.setConstraints(listeningPortJLabel, labelConstraints);
            listenerPanel.add(listeningPortJLabel);

            inputConstraints.gridy = 3;
            final int port = giftCloudProperties.getListeningPort();
            final String portValue = Integer.toString(port);
            listeningPortField = new AutoFocusTextField(portValue);
            listenerPanellayout.setConstraints(listeningPortField, inputConstraints);
            listenerPanel.add(listeningPortField);
        }
        {
            labelConstraints.gridy = 4;
            JLabel patientListExportFolderLabel = new JLabel(
                    resourceBundle.getString("configPanelListenerPatientListExportFolder"),
                    SwingConstants.RIGHT);
            patientListExportFolderLabel.setToolTipText(
                    resourceBundle.getString("configPanelListenerPatientListExportFolderTooltip"));
            listenerPanellayout.setConstraints(patientListExportFolderLabel, labelConstraints);
            listenerPanel.add(patientListExportFolderLabel);

            inputConstraints.gridy = 4;
            final Optional<String> patientListExportFolder = giftCloudProperties.getPatientListExportFolder();
            patientListExportFolderField = new AutoFocusTextField(patientListExportFolder.orElse(""));
            listenerPanellayout.setConstraints(patientListExportFolderField, inputConstraints);
            listenerPanel.add(patientListExportFolderField);
        }

        // Patient list spreadsheet password
        {
            labelConstraints.gridy = 5;
            final JLabel patientListSpreadsheetPasswordLabel = new JLabel(
                    resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPassword"),
                    SwingConstants.RIGHT);
            patientListSpreadsheetPasswordLabel.setToolTipText(
                    resourceBundle.getString("configPanelListenerPatientListSpreadhsheetPasswordTooltip"));
            listenerPanel.add(patientListSpreadsheetPasswordLabel, labelConstraints);

            final Optional<char[]> password = giftCloudProperties.getPatientListPassword();
            final char[] initialPassword = password.isPresent() ? password.get() : "".toCharArray();
            patientListSpreadsheetPasswordField = new JPasswordField(new String(initialPassword), 16); // Shouldn't create a String but there's no other way to initialize the password field
            inputConstraints.gridy = 5;
            listenerPanel.add(patientListSpreadsheetPasswordField, inputConstraints);
        }
    }

    // Remote PACS configuration
    final JPanel remoteAEPanel = new JPanel();

    {
        GridBagLayout pacsPanellayout = new GridBagLayout();
        remoteAEPanel.setLayout(pacsPanellayout);

        JSeparator separator = new JSeparator();
        remoteAEPanel.add(separator, separatorConstraint);

        JLabel remotePanelLabel = new JLabel(resourceBundle.getString("pacsPanelListenerConfig"),
                SwingConstants.CENTER);
        remoteAEPanel.add(remotePanelLabel, sectionTitleConstraints);

        {
            labelConstraints.gridy = 2;
            JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsAeTitle"),
                    SwingConstants.RIGHT);
            remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsAeTitleTooltip"));
            remoteAEPanel.add(remoteAeTitleLabel, labelConstraints);

            final Optional<String> pacsAeTitle = giftCloudProperties.getPacsAeTitle();
            remoteAETitleField = new AutoFocusTextField(pacsAeTitle.isPresent() ? pacsAeTitle.get() : "");
            inputConstraints.gridy = 2;
            remoteAEPanel.add(remoteAETitleField, inputConstraints);
        }

        {
            labelConstraints.gridy = 3;
            JLabel remoteAeHostLabel = new JLabel(resourceBundle.getString("configPanelPacsHostname"),
                    SwingConstants.RIGHT);
            remoteAeHostLabel.setToolTipText(resourceBundle.getString("configPanelPacsHostnameTooltip"));
            remoteAEPanel.add(remoteAeHostLabel, labelConstraints);

            remoteAEHostName = new AutoFocusTextField(giftCloudProperties.getPacsHostName().orElse(""));
            inputConstraints.gridy = 3;
            remoteAEPanel.add(remoteAEHostName, inputConstraints);
        }

        {
            labelConstraints.gridy = 4;
            JLabel remoteAeTitleLabel = new JLabel(resourceBundle.getString("configPanelPacsPort"),
                    SwingConstants.RIGHT);
            remoteAeTitleLabel.setToolTipText(resourceBundle.getString("configPanelPacsPortTooltip"));
            remoteAEPanel.add(remoteAeTitleLabel, labelConstraints);

            remoteAEPortField = new AutoFocusTextField(Integer.toString(giftCloudProperties.getPacsPort()));
            inputConstraints.gridy = 4;
            remoteAEPanel.add(remoteAEPortField, inputConstraints);
        }

    }

    // The panel containing the cancel and apply buttons
    JPanel buttonPanel = new JPanel();
    JPanel closeButtonPanel = new JPanel();
    {
        final GridBagLayout buttonPanellayout = new GridBagLayout();
        buttonPanel.setLayout(buttonPanellayout);

        JSeparator separator = new JSeparator();
        buttonPanel.add(separator, separatorConstraint);

        closeButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        JButton cancelButton = new JButton(resourceBundle.getString("cancelSettingsButtonLabelText"));
        cancelButton.setToolTipText(resourceBundle.getString("cancelSettingsButtonToolTipText"));
        closeButtonPanel.add(cancelButton);
        cancelButton.addActionListener(new CancelActionListener());

        JButton applyButton = new JButton(resourceBundle.getString("applySettingsButtonLabelText"));
        applyButton.setToolTipText(resourceBundle.getString("applySettingsButtonToolTipText"));
        closeButtonPanel.add(applyButton);
        applyButton.addActionListener(new ApplyActionListener());

        JButton closeButton = new JButton(resourceBundle.getString("closeSettingsButtonLabelText"));
        closeButton.setToolTipText(resourceBundle.getString("closeSettingsButtonToolTipText"));
        closeButtonPanel.add(closeButton);
        closeButton.addActionListener(new CloseActionListener());

        final GridBagConstraints constraints = new GridBagConstraints();
        constraints.gridx = 0;
        constraints.gridy = 1;
        constraints.weightx = 1;
        constraints.weighty = 1;
        constraints.insets = new Insets(5, 5, 5, 5);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        buttonPanellayout.setConstraints(closeButtonPanel, constraints);
        buttonPanel.add(closeButtonPanel);
    }

    // The main panel of the configuration dialog
    JPanel configPanel = new JPanel();
    {
        final GridBagLayout configPanelLayout = new GridBagLayout();
        configPanel.setLayout(configPanelLayout);
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 0;
            constraints.weightx = 1;
            constraints.weighty = 1;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(giftCloudServerPanel, constraints);
            configPanel.add(giftCloudServerPanel);
        }
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 1;
            constraints.weightx = 1;
            constraints.weighty = 1;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(listenerPanel, constraints);
            configPanel.add(listenerPanel);
        }
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 2;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(remoteAEPanel, constraints);
            configPanel.add(remoteAEPanel);
        }
        {
            final GridBagConstraints constraints = new GridBagConstraints();
            constraints.gridx = 0;
            constraints.gridy = 3;
            constraints.insets = new Insets(5, 5, 5, 5);
            constraints.fill = GridBagConstraints.HORIZONTAL;
            configPanelLayout.setConstraints(buttonPanel, constraints);
            configPanel.add(buttonPanel);
        }
    }

    projectList.setModel(temporaryDropDownListModel);
    showProjectList(projectListModel.isEnabled());

    // Create a listener to enable/disable the project list when it is set from the server.
    // The reason for this is that the project list is set after logging into the server, which can happen asynchronously after property changes have been applied.
    // If the server was configured in the dialog and apply clicked, it might take a few seconds for the project list to be updated, and we want it to become available when this happens
    projectListEnabledListener = new DropDownListModel.EnabledListener<Boolean>() {
        @Override
        public void statusChanged(final Boolean visibility) {
            showProjectList(projectListModel.isEnabled());
        }
    };

    projectListModel.addListener(projectListEnabledListener);

    GridBagLayout layout = new GridBagLayout();
    dialog.setLayout(layout);
    Container content = dialog.getContentPane();
    content.add(configPanel);
    dialog.pack();
    dialog.setVisible(true);
    dialog.pack();
}

From source file:org.jets3t.apps.cockpit.gui.LoginLocalFolderPanel.java

private void initGui() {
    // Textual information.
    String descriptionText = "<html><center>" + "Your credentials are stored in encrypted files in a folder on "
            + "your computer. Each stored login has a nickname."
            + "<br><font size=\"-2\">You need to store your credentials before you can use this login method.</font>"
            + "</center></html>";
    String folderTooltipText = "The folder containing your credentials";
    String browseButtonText = "Change Folder";
    String accountNicknameText = "Stored logins";
    String accountNicknameTooltipText = "Nicknames of the login credentials you have stored";
    String passwordLabelText = "Password";
    String passwordTooltipText = "The password that protects your encrypted file. "
            + "This password may be left empty if you are sure your computer cannot be compromised";

    // Components.
    JHtmlLabel descriptionLabel = new JHtmlLabel(descriptionText, hyperlinkListener);
    descriptionLabel.setHorizontalAlignment(JLabel.CENTER);
    folderPathTextField = new JTextField(this.cockpitHomeFolder.getAbsolutePath());
    folderPathTextField.setEnabled(false);
    folderPathTextField.setToolTipText(folderTooltipText);
    JButton browseButton = new JButton(browseButtonText);
    browseButton.addActionListener(this);
    JHtmlLabel accountNicknamesLabel = new JHtmlLabel(accountNicknameText, hyperlinkListener);
    nicknamesTableModel = new ProviderCredentialsFileTableModel();
    accountNicknameTable = new JTable(nicknamesTableModel);
    accountNicknameTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    accountNicknameTable.setShowHorizontalLines(true);
    accountNicknameTable.getTableHeader().setVisible(false);
    JScrollPane accountNicknamesScrollPane = new JScrollPane(accountNicknameTable);
    accountNicknamesScrollPane.setToolTipText(accountNicknameTooltipText);
    JHtmlLabel passwordLabel = new JHtmlLabel(passwordLabelText, hyperlinkListener);
    passwordPasswordField = new JPasswordField();
    passwordPasswordField.setToolTipText(passwordTooltipText);

    int row = 0;/*from www .  j  a v  a  2  s . c  o m*/
    add(descriptionLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    add(folderPathTextField, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    add(browseButton, new GridBagConstraints(1, row++, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    add(accountNicknamesLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    add(accountNicknamesScrollPane, new GridBagConstraints(0, row++, 2, 1, 0, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    add(passwordLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    add(passwordPasswordField, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
}

From source file:Main.java

private void initScreen() {
    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new GridBagLayout());
    sourceLabel = new JLabel(DEFAULT_SOURCE_CHOICE_LABEL);
    sourceListModel = new SortedListModel();
    sourceList = new JList(sourceListModel);
    add(sourceLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, EMPTY_INSETS, 0, 0));
    add(new JScrollPane(sourceList), new GridBagConstraints(0, 1, 1, 5, .5, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, EMPTY_INSETS, 0, 0));

    addButton = new JButton(ADD_BUTTON_LABEL);
    add(addButton, new GridBagConstraints(1, 2, 1, 2, 0, .25, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, EMPTY_INSETS, 0, 0));
    addButton.addActionListener(new AddListener());
    removeButton = new JButton(REMOVE_BUTTON_LABEL);
    add(removeButton, new GridBagConstraints(1, 4, 1, 2, 0, .25, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
    removeButton.addActionListener(new RemoveListener());

    destLabel = new JLabel(DEFAULT_DEST_CHOICE_LABEL);
    destListModel = new SortedListModel();
    destList = new JList(destListModel);
    add(destLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
            EMPTY_INSETS, 0, 0));//from  w w w.  ja  v  a2 s  .  c  o  m
    add(new JScrollPane(destList), new GridBagConstraints(2, 1, 1, 5, .5, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, EMPTY_INSETS, 0, 0));
}

From source file:com.oracle.tutorial.jdbc.CoffeesFrame.java

public CoffeesFrame(JDBCTutorialUtilities settingsArg) throws SQLException {

    super("The Coffee Break: COFFEES Table"); // Set window title

    this.settings = settingsArg;
    connection = settings.getConnection();

    // Close connections exit the application when the user
    // closes the window

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {

            try {
                connection.close();//from   w  ww  . j  av  a 2  s .  c  om
            } catch (SQLException sqle) {
                JDBCTutorialUtilities.printSQLException(sqle);
            }
            System.exit(0);
        }
    });

    // Initialize and lay out window controls

    CachedRowSet myCachedRowSet = getContentsOfCoffeesTable();
    myCoffeesTableModel = new CoffeesTableModel(myCachedRowSet);
    myCoffeesTableModel.addEventHandlersToRowSet(this);

    table = new JTable(); // Displays the table
    table.setModel(myCoffeesTableModel);

    label_COF_NAME = new JLabel();
    label_SUP_ID = new JLabel();
    label_PRICE = new JLabel();
    label_SALES = new JLabel();
    label_TOTAL = new JLabel();

    textField_COF_NAME = new JTextField(10);
    textField_SUP_ID = new JTextField(10);
    textField_PRICE = new JTextField(10);
    textField_SALES = new JTextField(10);
    textField_TOTAL = new JTextField(10);

    button_ADD_ROW = new JButton();
    button_UPDATE_DATABASE = new JButton();
    button_DISCARD_CHANGES = new JButton();

    label_COF_NAME.setText("Coffee Name:");
    label_SUP_ID.setText("Supplier ID:");
    label_PRICE.setText("Price:");
    label_SALES.setText("Sales:");
    label_TOTAL.setText("Total Sales:");

    textField_COF_NAME.setText("Enter new coffee name");
    textField_SUP_ID.setText("101");
    textField_PRICE.setText("0");
    textField_SALES.setText("0");
    textField_TOTAL.setText("0");

    button_ADD_ROW.setText("Add row to table");
    button_UPDATE_DATABASE.setText("Update database");
    button_DISCARD_CHANGES.setText("Discard changes");

    // Place the components within the container contentPane; use GridBagLayout
    // as the layout.

    Container contentPane = getContentPane();
    contentPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    contentPane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.5;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    contentPane.add(new JScrollPane(table), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(label_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(textField_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.25;
    c.weighty = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(label_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(textField_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(label_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(textField_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(label_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(textField_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(label_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(textField_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_ADD_ROW, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_UPDATE_DATABASE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    contentPane.add(button_DISCARD_CHANGES, c);

    // Add listeners for the buttons in the application

    button_ADD_ROW.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            JOptionPane.showMessageDialog(CoffeesFrame.this, new String[] { "Adding the following row:",
                    "Coffee name: [" + textField_COF_NAME.getText() + "]",
                    "Supplier ID: [" + textField_SUP_ID.getText() + "]",
                    "Price: [" + textField_PRICE.getText() + "]", "Sales: [" + textField_SALES.getText() + "]",
                    "Total: [" + textField_TOTAL.getText() + "]" });

            try {

                myCoffeesTableModel.insertRow(textField_COF_NAME.getText(),
                        Integer.parseInt(textField_SUP_ID.getText().trim()),
                        Float.parseFloat(textField_PRICE.getText().trim()),
                        Integer.parseInt(textField_SALES.getText().trim()),
                        Integer.parseInt(textField_TOTAL.getText().trim()));
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });

    button_UPDATE_DATABASE.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                myCoffeesTableModel.coffeesRowSet.acceptChanges();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
                // Now revert back changes
                try {
                    createNewTableModel();
                } catch (SQLException sqle2) {
                    displaySQLExceptionDialog(sqle2);
                }
            }
        }
    });

    button_DISCARD_CHANGES.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                createNewTableModel();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.LoginLocalFolderPanel.java

private void initGui() {
    // Textual information.
    String descriptionText = "<html><center>"
            + "Your AWS Credentials are stored in encrypted files in a folder on "
            + "your computer. Each stored login has a nickname."
            + "<br><font size=\"-2\">You need to store your AWS credentials before you can use this login method.</font>"
            + "</center></html>";
    String folderTooltipText = "The folder containing your AWS Credentials";
    String browseButtonText = "Change Folder";
    String accountNicknameText = "Stored logins";
    String accountNicknameTooltipText = "Nicknames of the login credentials you have stored";
    String passwordLabelText = "Password";
    String passwordTooltipText = "The password that protects your encrypted file. "
            + "This password may be left empty if you are sure your computer cannot be compromised";

    // Components.
    JHtmlLabel descriptionLabel = new JHtmlLabel(descriptionText, hyperlinkListener);
    descriptionLabel.setHorizontalAlignment(JLabel.CENTER);
    folderPathTextField = new JTextField(this.cockpitHomeFolder.getAbsolutePath());
    folderPathTextField.setEnabled(false);
    folderPathTextField.setToolTipText(folderTooltipText);
    JButton browseButton = new JButton(browseButtonText);
    browseButton.addActionListener(this);
    JHtmlLabel accountNicknamesLabel = new JHtmlLabel(accountNicknameText, hyperlinkListener);
    nicknamesTableModel = new AWSCredentialsFileTableModel();
    accountNicknameTable = new JTable(nicknamesTableModel);
    accountNicknameTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    accountNicknameTable.setShowHorizontalLines(true);
    accountNicknameTable.getTableHeader().setVisible(false);
    JScrollPane accountNicknamesScrollPane = new JScrollPane(accountNicknameTable);
    accountNicknamesScrollPane.setToolTipText(accountNicknameTooltipText);
    JHtmlLabel passwordLabel = new JHtmlLabel(passwordLabelText, hyperlinkListener);
    passwordPasswordField = new JPasswordField();
    passwordPasswordField.setToolTipText(passwordTooltipText);

    int row = 0;/*from   w  w  w  .  j a  va2  s  .  c  o  m*/
    add(descriptionLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    add(folderPathTextField, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    add(browseButton, new GridBagConstraints(1, row++, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
    add(accountNicknamesLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    add(accountNicknamesScrollPane, new GridBagConstraints(0, row++, 2, 1, 0, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, insetsDefault, 0, 0));
    add(passwordLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    add(passwordPasswordField, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
}

From source file:org.mbs3.juniuploader.gui.pnlSettings.java

private void initGUI() {
    try {//from   ww w. ja va  2 s  .c  o  m
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0 };
        thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 };
        thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 };
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(659, 349));
        {
            {
                grpMain = new ButtonGroup();
            }
            {
                grpGUI = new ButtonGroup();
            }
            {
                grpObjects = new ButtonGroup();
            }
            {
                grpHTTP = new ButtonGroup();
            }
            {
            }
            {
            }
            lblGUI = new JLabel();
            this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblGUI.setText("Graphical Interface");
        }
        {
            lblMain = new JLabel();
            this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblMain.setText("Main Program");
        }
        {
            lblObj = new JLabel();
            this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblObj.setText("Object Messages");
        }
        {
            lblLObj = new JLabel();
            this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblLObj.setText("HTTP Messages");
        }
        {
            lblFatal = new JLabel();
            this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblFatal.setText("Fatal Messages");
        }
        {
            lblError = new JLabel();
            this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblError.setText("Errors");
        }
        {
            lblWarn = new JLabel();
            this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblWarn.setText("Warnings");
        }
        {
            lblInfo = new JLabel();
            this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblInfo.setText("Info Messages");
        }
        {
            lblDebug = new JLabel();
            this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblDebug.setText("Debug Messages");
        }
        {
            lblTrace = new JLabel();
            this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblTrace.setText("Trace Execution");
        }
        {
            btnMainFatal = new JRadioButton();
            this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
        grpMain.add(btnMainFatal);
        btnMainFatal.setActionCommand("fatal");
        btnMainFatal.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                logLevelBtnAction(evt);
            }
        });
        {
            btnMainError = new JRadioButton();
            this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainError);
            btnMainError.setActionCommand("error");
            btnMainError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainWarn = new JRadioButton();
            this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainWarn);
            btnMainWarn.setActionCommand("warn");
            btnMainWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainInfo = new JRadioButton();
            this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainInfo);
            btnMainInfo.setActionCommand("info");
            btnMainInfo.setSelected(true);
            btnMainInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainDebug = new JRadioButton();
            this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainDebug);
            btnMainDebug.setActionCommand("debug");
            btnMainDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainTrace = new JRadioButton();
            this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainTrace);
            btnMainTrace.setActionCommand("trace");
            btnMainTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIFatal = new JRadioButton();
            this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIFatal);
            btnGUIFatal.setActionCommand("fatal");
            btnGUIFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIError = new JRadioButton();
            this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIError);
            btnGUIError.setActionCommand("error");
            btnGUIError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIWarn = new JRadioButton();
            this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIWarn);
            btnGUIWarn.setActionCommand("warn");
            btnGUIWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIInfo = new JRadioButton();
            this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIInfo);
            btnGUIInfo.setActionCommand("info");
            btnGUIInfo.setSelected(true);
            btnGUIInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIDebug = new JRadioButton();
            this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIDebug);
            btnGUIDebug.setActionCommand("debug");
            btnGUIDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUITrace = new JRadioButton();
            this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUITrace);
            btnGUITrace.setActionCommand("trace");
            btnGUITrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjFatal = new JRadioButton();
            this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjFatal);
            btnObjFatal.setActionCommand("fatal");
            btnObjFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjError = new JRadioButton();
            this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjError);
            btnObjError.setActionCommand("error");
            btnObjError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjWarn = new JRadioButton();
            this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjWarn);
            btnObjWarn.setActionCommand("warn");
            btnObjWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjInfo = new JRadioButton();
            this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjInfo);
            btnObjInfo.setActionCommand("info");
            btnObjInfo.setSelected(true);
            btnObjInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjDebug = new JRadioButton();
            this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjDebug);
            btnObjDebug.setActionCommand("debug");
            btnObjDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjTrace = new JRadioButton();
            this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjTrace);
            btnObjTrace.setActionCommand("trace");
            btnObjTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPFatal = new JRadioButton();
            this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPFatal);
            btnHTTPFatal.setActionCommand("fatal");
            btnHTTPFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPError = new JRadioButton();
            this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPError);
            btnHTTPError.setActionCommand("error");
            btnHTTPError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPWarn = new JRadioButton();
            this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPWarn);
            btnHTTPWarn.setActionCommand("warn");
            btnHTTPWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPInfo = new JRadioButton();
            this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPInfo);
            btnHTTPInfo.setActionCommand("info");
            btnHTTPInfo.setSelected(true);
            btnHTTPInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPDebug = new JRadioButton();
            this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPDebug);
            btnHTTPDebug.setActionCommand("debug");
            btnHTTPDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPTrace = new JRadioButton();
            this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPTrace);
            btnHTTPTrace.setActionCommand("trace");
            btnHTTPTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            lblLogLevel = new JLabel();
            this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblLogLevel.setText("Set the level of logging for different parts of this application:");
        }
        {
            lblDeLF = new JLabel();
            this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblDeLF.setText("Set the look and feel for the GUI of this application:");
        }
        {
            LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
            LookAndFeel lf = UIManager.getLookAndFeel();
            DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel();
            for (int i = 0; i < lfs.length; i++) {
                String n = lfs[i].getName();
                cmbLFModel.addElement(n);
                if (lf.getName().equals(lfs[i].getName()))
                    cmbLFModel.setSelectedItem(n);
            }
            cmbLF = new JComboBox();
            this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            cmbLF.setModel(cmbLFModel);
            cmbLF.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    cmbLFItemStateChanged(evt);
                }
            });
        }
        {
            tfUserAgent = new JTextField(Util.getUserAgent());
            this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            tfUserAgent.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent evt) {
                    tfUserAgentKeyReleased(evt);
                }
            });
        }
        {
            lblUserAgent = new JLabel();
            this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblUserAgent.setText("User Agent");
        }
        {
            btnExport = new JToggleButton();
            this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            btnExport.setText("Export All Settings and Data to File");
            btnExport.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnExportActionPerformed(evt);
                }
            });
        }
        {
            txtWarn = new JTextPane();
            this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            txtWarn.setText(
                    "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run.");
            txtWarn.setEditable(false);
            txtWarn.setBackground(new java.awt.Color(255, 255, 255));
            txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0)));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.rdv.ui.ImportDialog.java

private void initComponents() {
    JPanel container = new JPanel();
    setContentPane(container);//from  w w  w .j a  v a2 s  . co m

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    container.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;

    JLabel headerLabel = new JLabel("Please specify the desired source name for the data.");
    headerLabel.setBackground(Color.white);
    headerLabel.setOpaque(true);
    headerLabel.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray),
                    BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(0, 0, 0, 0);
    container.add(headerLabel, c);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.insets = new java.awt.Insets(10, 10, 10, 5);
    container.add(new JLabel("Source name: "), c);

    sourceNameTextField = new JTextField();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new java.awt.Insets(10, 0, 10, 10);
    container.add(sourceNameTextField, c);

    importProgressBar = new JProgressBar(0, 100000);
    importProgressBar.setStringPainted(true);
    importProgressBar.setValue(0);
    importProgressBar.setVisible(false);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new java.awt.Insets(0, 10, 10, 10);
    container.add(importProgressBar, c);

    JPanel panel = new JPanel();
    panel.setLayout(new FlowLayout());

    Action importAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -4719316285523193555L;

        public void actionPerformed(ActionEvent e) {
            importData();
        }
    };
    importAction.putValue(Action.NAME, "Import");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "import");
    actionMap.put("export", importAction);
    importButton = new JButton(importAction);
    getRootPane().setDefaultButton(importButton);
    panel.add(importButton);

    Action cancelAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = 7909429022904810958L;

        public void actionPerformed(ActionEvent e) {
            cancel();
        }
    };
    cancelAction.putValue(Action.NAME, "Cancel");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
    actionMap.put("cancel", cancelAction);
    cancelButton = new JButton(cancelAction);
    panel.add(cancelButton);

    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    ;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new java.awt.Insets(0, 0, 10, 5);
    container.add(panel, c);

    pack();

    sourceNameTextField.requestFocusInWindow();

    setLocationByPlatform(true);
    setVisible(true);
}

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

/**
 * This method initializes jContentPane// w  w  w  . java 2 s  .  com
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
    if (jContentPane == null) {
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.gridx = 0;
        gridBagConstraints10.weightx = 0.0;
        gridBagConstraints10.weighty = 1.0;
        gridBagConstraints10.gridy = 6;
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.gridx = 0;
        gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints9.gridwidth = 2;
        gridBagConstraints9.gridy = 4;
        jLabelResponse = new JLabel();
        jLabelResponse.setText("");
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.fill = GridBagConstraints.BOTH;
        gridBagConstraints8.gridy = 3;
        gridBagConstraints8.weightx = 1.0;
        gridBagConstraints8.anchor = GridBagConstraints.WEST;
        gridBagConstraints8.gridx = 1;
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.fill = GridBagConstraints.BOTH;
        gridBagConstraints7.gridy = 2;
        gridBagConstraints7.weightx = 1.0;
        gridBagConstraints7.anchor = GridBagConstraints.WEST;
        gridBagConstraints7.gridx = 1;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.fill = GridBagConstraints.BOTH;
        gridBagConstraints6.gridy = 1;
        gridBagConstraints6.weightx = 1.0;
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.gridx = 1;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.anchor = GridBagConstraints.EAST;
        gridBagConstraints5.gridy = 5;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.gridx = 1;
        gridBagConstraints4.anchor = GridBagConstraints.CENTER;
        gridBagConstraints4.gridy = 5;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.anchor = GridBagConstraints.EAST;
        gridBagConstraints3.gridy = 3;
        jLabel3 = new JLabel();
        jLabel3.setText("New Password Again");
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.gridy = 2;
        jLabel2 = new JLabel();
        jLabel2.setText("New Password");
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.anchor = GridBagConstraints.EAST;
        gridBagConstraints11.gridy = 1;
        jLabel1 = new JLabel();
        jLabel1.setText("Old Password");
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.gridx = 1;
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.gridy = 0;
        jLabel = new JLabel();
        jLabel.setText("Change Password For:");
        jContentPane = new JPanel();
        jContentPane.setLayout(new GridBagLayout());
        jContentPane.add(jLabel, gridBagConstraints);
        jContentPane.add(getJTextField(), gridBagConstraints1);
        jContentPane.add(jLabel1, gridBagConstraints11);
        jContentPane.add(jLabel2, gridBagConstraints2);
        jContentPane.add(jLabel3, gridBagConstraints3);
        jContentPane.add(getJButton(), gridBagConstraints4);
        jContentPane.add(getJButton1(), gridBagConstraints5);
        jContentPane.add(getJPasswordFieldOld(), gridBagConstraints6);
        jContentPane.add(getJPasswordField1(), gridBagConstraints7);
        jContentPane.add(getJPasswordField2(), gridBagConstraints8);
        jContentPane.add(jLabelResponse, gridBagConstraints9);
        jContentPane.add(getJPanel(), gridBagConstraints10);
    }
    return jContentPane;
}

From source file:ro.nextreports.designer.action.report.ViewReportSqlAction.java

public void actionPerformed(ActionEvent e) {

    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle(I18NSupport.getString("select.next.reports.file"));
    fc.setAcceptAllFileFilterUsed(false);
    fc.addChoosableFileFilter(new NextFileFilter());
    int returnVal = fc.showOpenDialog(Globals.getMainFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File f = fc.getSelectedFile();
        if (f != null) {

            String sql = null;//  w ww .jav a 2  s . com
            String entityName = null;
            Object entity = null;
            FileInputStream fis = null;
            entityName = f.getName();
            try {
                XStream xstream = XStreamFactory.createXStream();
                fis = new FileInputStream(f);
                entity = xstream.fromXML(fis);

            } catch (Exception ex) {
                Show.error(ex);
            } finally {
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }

            if (entityName.endsWith(QueryFilter.QUERY_EXTENSION)
                    || entityName.endsWith(ReportFilter.REPORT_EXTENSION)) {

                Report report = (Report) entity;
                if (report.getSql() != null) {
                    sql = report.getSql();
                } else if (report.getQuery() != null) {
                    SelectQuery query = report.getQuery();
                    try {
                        query.setDialect(DialectUtil.getDialect(Globals.getConnection()));
                    } catch (Exception ex) {
                        ex.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
                        LOG.error(ex.getMessage(), ex);
                    }
                    sql = query.toString();
                }

            } else if (entityName.endsWith(ChartFilter.CHART_EXTENSION)) {
                Chart chart = (Chart) entity;
                if (chart.getReport().getSql() != null) {
                    sql = chart.getReport().getSql();
                } else if (chart.getReport().getQuery() != null) {
                    SelectQuery query = chart.getReport().getQuery();
                    try {
                        query.setDialect(DialectUtil.getDialect(Globals.getConnection()));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        LOG.error(ex.getMessage(), ex);
                    }
                    sql = query.toString();
                }
            }

            Editor editor = new Editor();
            editor.setText(sql);
            editor.setPreferredSize(new Dimension(400, 400));
            JFrame frame = new JFrame(I18NSupport.getString("view.sql.info", entityName));
            frame.setIconImage(ImageUtil.getImageIcon("report_view").getImage());
            frame.setLayout(new GridBagLayout());
            frame.add(editor, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));
            frame.pack();
            Show.centrateComponent(Globals.getMainFrame(), frame);
            frame.setVisible(true);

        }
    }

}