Example usage for javax.swing JCheckBox JCheckBox

List of usage examples for javax.swing JCheckBox JCheckBox

Introduction

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

Prototype

public JCheckBox(Action a) 

Source Link

Document

Creates a check box where properties are taken from the Action supplied.

Usage

From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java

private Component createMainTab() {

    // bernahme der Eigenschaften
    String s = "";

    String appSchemaStr;//w ww . j  av a2s  .  co  m
    s = options.parameter("appSchemaName");
    if (s != null && s.trim().length() > 0)
        appSchemaStr = s.trim();
    else
        appSchemaStr = "";

    String schemaKennungenStr;
    s = options.parameter(paramKatalogClass, "schemakennungen");
    if (s != null && s.trim().length() > 0)
        schemaKennungenStr = s.trim();
    else
        schemaKennungenStr = "*";

    Boolean geerbEigBool = false;
    s = options.parameter(paramKatalogClass, "geerbteEigenschaften");
    if (s != null && s.equals("true"))
        geerbEigBool = true;

    String modellartenStr;
    s = options.parameter(paramKatalogClass, "modellarten");
    if (s == null || s.trim().length() == 0)
        modellartenStr = "";
    else
        modellartenStr = s.trim();

    Boolean grundDatBool = false;
    s = options.parameter(paramKatalogClass, "nurGrunddatenbestand");
    if (s != null && s.equals("true"))
        grundDatBool = true;

    Boolean profEinschrBool = false;
    Boolean profDateiBool = false;
    String profileStr;
    s = options.parameter(paramKatalogClass, "profile");
    if (s == null || s.trim().length() == 0)
        profileStr = "";
    else
        profileStr = s.trim();
    if (profileStr.length() > 0)
        profEinschrBool = true;
    s = options.parameter(paramKatalogClass, "profilquelle");
    if (s != null && s.trim().equals("Datei"))
        profDateiBool = true;

    Boolean pkgBool = false;
    String pkgStr;
    s = options.parameter(paramKatalogClass, "paket");
    if (s == null || s.trim().length() == 0)
        pkgStr = "";
    else
        pkgStr = s.trim();
    if (pkgStr.length() > 0)
        pkgBool = true;

    String xsltPfadStr;
    s = options.parameter(paramKatalogClass, "xsltPfad");
    if (s == null || s.trim().length() == 0)
        xsltPfadStr = "";
    else {
        if (s.toLowerCase().startsWith("http://")) {
            xsltPfadStr = s;
        } else {
            File f = new File(s.trim());
            if (f.exists())
                xsltPfadStr = f.getAbsolutePath();
            else
                xsltPfadStr = "";
        }
    }

    String outDirStr;
    s = options.parameter(paramKatalogClass, "Verzeichnis");
    if (s == null || s.trim().length() == 0)
        outDirStr = "";
    else {
        File f = new File(s.trim());
        if (f.exists())
            outDirStr = f.getAbsolutePath();
        else
            outDirStr = "";
    }

    String mdlDirStr = eap;

    // Anwendungsschema

    final JPanel appSchemaPanel = new JPanel();
    final JPanel appSchemaInnerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 30, 5));
    appSchemaPanel.setLayout(new BoxLayout(appSchemaPanel, BoxLayout.X_AXIS));
    appSchemaPanel.setBorder(BorderFactory.createEmptyBorder(15, 20, 15, 10));

    appSchemaField = new JTextField(37);
    appSchemaField.setText(appSchemaStr);
    appSchemaFieldLabel = new JLabel("Name des zu exportierenden Anwendungsschemas:");

    Box asBox = Box.createVerticalBox();
    asBox.add(appSchemaFieldLabel);
    asBox.add(appSchemaField);

    pkgBox = new JCheckBox("Eingeschrnkt auf Paket:");
    pkgBox.setSelected(pkgBool);
    pkgBox.addItemListener(this);
    pkgField = new JTextField(37);
    pkgField.setText(pkgStr);
    if (pkgStr.length() == 0) {
        pkgField.setEnabled(false);
        pkgField.setEditable(false);
    }
    asBox.add(pkgBox);
    asBox.add(pkgField);

    appSchemaInnerPanel.add(asBox);

    appSchemaPanel.add(appSchemaInnerPanel);

    // Ausgabeoptionen

    Box outOptBox = Box.createVerticalBox();

    final JPanel outOptInnerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 5));
    Box skBox = Box.createVerticalBox();
    schemaKennFieldLabel1 = new JLabel("Liste der zu bercksichtigenden Schema-Kennungen");
    skBox.add(schemaKennFieldLabel1);
    schemaKennFieldLabel2 = new JLabel("(nur Klassen mit diesen Kennungen werden exportiert)");
    skBox.add(schemaKennFieldLabel2);
    schemaKennField = new JTextField(35);
    schemaKennField.setText(schemaKennungenStr);
    skBox.add(schemaKennField);
    outOptInnerPanel.add(skBox);
    outOptBox.add(outOptInnerPanel);

    final JPanel targetPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    for (String label : targetLabels) {
        targetPanel.add(targetGuiElems.get(label).selBox);
    }
    outOptBox.add(targetPanel);

    final JPanel geerbEigPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    geerbEigBox = new JCheckBox("Eigenschaften aus Superklassen auch in abgeleiteten Klassen darstellen");
    geerbEigBox.setSelected(geerbEigBool);
    geerbEigBox.addItemListener(this);
    geerbEigPanel.add(geerbEigBox);
    outOptBox.add(geerbEigPanel);

    final JPanel outOptPanel = new JPanel();
    outOptPanel.add(outOptBox);
    outOptPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Ausgabeoptionen", TitledBorder.LEFT,
            TitledBorder.TOP));

    // Modellarten und Profile
    Box modProfBox = Box.createVerticalBox();

    final JPanel modProfInnerPanel1 = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 5));

    skBox = Box.createVerticalBox();
    modellartFieldLabel = new JLabel("Ausgewhlte Modellarten:");
    modellartField = new JTextField(45);
    modellartField.setText(modellartenStr);
    skBox.add(modellartFieldLabel);
    skBox.add(modellartField);
    modProfInnerPanel1.add(skBox);
    modProfBox.add(modProfInnerPanel1);
    final JPanel grundDatPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 8));
    grundDatBox = new JCheckBox("Nur Grunddatenbestand exportieren");
    grundDatBox.setSelected(grundDatBool);
    grundDatBox.addItemListener(this);
    grundDatPanel.add(grundDatBox);
    modProfBox.add(grundDatPanel);

    final JPanel profPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    profEinschrBox = new JCheckBox("Eingeschrnkt auf folgende Profilkennung(en) im Modell:");
    profEinschrBox.setSelected(profEinschrBool);
    profEinschrBox.addItemListener(this);
    profPanel.add(profEinschrBox);
    final JPanel profPanel2 = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 2));
    profileField = new JTextField(45);
    profileField.setText(profileStr);
    profPanel2.add(profileField);
    final JPanel profPanel3 = new JPanel(new FlowLayout(FlowLayout.LEADING, 15, 2));
    profDateiBox = new JCheckBox(
            "Profil(e) nur aus 3ap-Datei laden und verwenden statt der Profilkennungen aus dem Modell");
    profDateiBox.setSelected(profDateiBool);
    profDateiBox.addItemListener(this);
    profPanel3.add(profDateiBox);
    if (profileStr.length() == 0) {
        profileField.setEnabled(false);
        profileField.setEditable(false);
        profDateiBox.setEnabled(false);
    }

    modProfBox.add(profPanel);
    modProfBox.add(profPanel2);
    modProfBox.add(profPanel3);

    final JPanel modProfPanel = new JPanel();
    modProfPanel.add(modProfBox);
    modProfPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Auswahl der Modellarten und Profile",
            TitledBorder.LEFT, TitledBorder.TOP));

    // Pfadangaben
    Box pfadBox = Box.createVerticalBox();
    final JPanel pfadInnerPanel = new JPanel();
    skBox = Box.createVerticalBox();
    xsltpfadFieldLabel = new JLabel("Pfad in dem die XSLT-Skripte liegen:");
    skBox.add(xsltpfadFieldLabel);
    xsltpfadField = new JTextField(45);
    xsltpfadField.setText(xsltPfadStr);
    skBox.add(xsltpfadField);
    outDirFieldLabel = new JLabel("Pfad in den die Kataloge geschrieben werden:");
    skBox.add(outDirFieldLabel);
    outDirField = new JTextField(45);
    outDirField.setText(outDirStr);
    skBox.add(outDirField);
    mdlDirFieldLabel = new JLabel("Pfad zum Modell:");
    skBox.add(mdlDirFieldLabel);
    mdlDirField = new JTextField(45);
    mdlDirField.setText(mdlDirStr);
    skBox.add(mdlDirField);
    pfadInnerPanel.add(skBox);
    pfadBox.add(pfadInnerPanel);

    final JPanel pfadPanel = new JPanel();
    pfadPanel.add(pfadBox);
    pfadPanel.setBorder(
            new TitledBorder(new LineBorder(Color.black), "Pfadangaben", TitledBorder.LEFT, TitledBorder.TOP));

    // Zusammenstellung
    Box fileBox = Box.createVerticalBox();
    fileBox.add(appSchemaPanel);
    fileBox.add(outOptPanel);
    fileBox.add(modProfPanel);
    fileBox.add(pfadPanel);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(fileBox, BorderLayout.NORTH);

    return panel;
}

From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java

private void initComponents() {
    JPanel mainPanel = new JPanel(new GridBagLayout());

    // Base font for all components on the form
    Font baseFont = new JLabel("base font").getFont().deriveFont(11f);

    // Title panel
    JPanel titlePanel = new JPanel(new FlowLayout(LEFT));
    titlePanel.setBackground(WHITE);//from w  w  w .  j av  a  2  s  .c  om
    // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    JLabel titleLabel = new JLabel(WELCOME);
    titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f));
    // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    JLabel titleIcon = new JLabel(tavernaCogs32x32Icon);
    // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10));
    DialogTextArea titleMessage = new DialogTextArea(PLEASE_FILL_IN_THIS_REGISTRATION_FORM);
    titleMessage.setMargin(new Insets(0, 20, 0, 10));
    titleMessage.setFont(baseFont);
    titleMessage.setEditable(false);
    titleMessage.setFocusable(false);
    // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10));
    JPanel messagePanel = new JPanel(new BorderLayout());
    messagePanel.add(titleLabel, NORTH);
    messagePanel.add(titleMessage, CENTER);
    messagePanel.setBackground(WHITE);
    titlePanel.add(titleIcon);
    titlePanel.add(messagePanel);
    addDivider(titlePanel, BOTTOM, true);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    // gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(titlePanel, gbc);

    // Registration messages
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    // gbc.insets = new Insets(5, 0, 0, 10);
    DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER);
    registrationMessage1.setMargin(new Insets(0, 10, 0, 0));
    registrationMessage1.setFont(baseFont);
    registrationMessage1.setEditable(false);
    registrationMessage1.setFocusable(false);
    registrationMessage1.setBackground(getBackground());

    DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO);
    registrationMessage2.setMargin(new Insets(0, 10, 0, 10));
    registrationMessage2.setFont(baseFont);
    registrationMessage2.setEditable(false);
    registrationMessage2.setFocusable(false);
    registrationMessage2.setBackground(getBackground());
    JPanel registrationMessagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    registrationMessagePanel.add(registrationMessage1);
    registrationMessagePanel.add(registrationMessage2);
    addDivider(registrationMessagePanel, BOTTOM, true);
    mainPanel.add(registrationMessagePanel, gbc);

    // Mandatory label
    // JLabel mandatoryLabel = new JLabel("* Mandatory fields");
    // mandatoryLabel.setFont(baseFont);
    // gbc.weightx = 0.0;
    // gbc.weighty = 0.0;
    // gbc.gridx = 0;
    // gbc.gridy = 3;
    // gbc.fill = NONE;
    // gbc.anchor = GridBagConstraints.EAST;
    // gbc.gridwidth = 2;
    // gbc.insets = new Insets(0, 10, 0, 20);
    // mainPanel.add(mandatoryLabel, gbc);

    // First name
    JLabel firstNameLabel = new JLabel(FIRST_NAME);
    firstNameLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 10, 0, 10);
    mainPanel.add(firstNameLabel, gbc);

    firstNameTextField = new JTextField();
    firstNameTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        firstNameTextField.setText(previousRegistrationData.getFirstName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(firstNameTextField, gbc);

    // Last name
    JLabel lastNameLabel = new JLabel(LAST_NAME);
    lastNameLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 10, 0, 10);
    mainPanel.add(lastNameLabel, gbc);

    lastNameTextField = new JTextField();
    lastNameTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        lastNameTextField.setText(previousRegistrationData.getLastName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(lastNameTextField, gbc);

    // Email address
    JLabel emailLabel = new JLabel(EMAIL_ADDRESS);
    emailLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(emailLabel, gbc);

    emailTextField = new JTextField();
    emailTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        emailTextField.setText(previousRegistrationData.getEmailAddress());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(emailTextField, gbc);

    // Keep me informed
    keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED);
    keepMeInformedCheckBox.setFont(baseFont);
    if (previousRegistrationData != null)
        keepMeInformedCheckBox.setSelected(previousRegistrationData.getKeepMeInformed());
    keepMeInformedCheckBox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox.isSelected());
            }
        }
    });
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(keepMeInformedCheckBox, gbc);

    // Institution name
    JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME);
    institutionLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(institutionLabel, gbc);

    institutionOrCompanyTextField = new JTextField();
    institutionOrCompanyTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        institutionOrCompanyTextField.setText(previousRegistrationData.getInstitutionOrCompanyName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(institutionOrCompanyTextField, gbc);

    // Industry type
    JLabel industryLabel = new JLabel(" Industry type:");
    industryLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 9;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(industryLabel, gbc);

    industryTypeTextField = new JComboBox<>(industryTypes);
    industryTypeTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        industryTypeTextField.setSelectedItem(previousRegistrationData.getIndustry());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(industryTypeTextField, gbc);

    // Field of investigation
    JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION);
    fieldLabel.setFont(baseFont);
    fieldLabel.setEditable(false);
    fieldLabel.setFocusable(false);
    fieldLabel.setBackground(getBackground());
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 10;
    gbc.fill = NONE;
    gbc.anchor = LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(fieldLabel, gbc);

    fieldTextField = new JTextField();
    fieldTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        fieldTextField.setText(previousRegistrationData.getField());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 10;
    gbc.fill = HORIZONTAL;
    gbc.anchor = FIRST_LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(fieldTextField, gbc);

    // Purpose of using Taverna
    JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA);
    purposeLabel.setFont(baseFont);
    purposeLabel.setEditable(false);
    purposeLabel.setFocusable(false);
    purposeLabel.setBackground(getBackground());
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 11;
    gbc.fill = NONE;
    gbc.anchor = LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(purposeLabel, gbc);

    purposeTextArea = new JTextArea(4, 30);
    purposeTextArea.setFont(baseFont);
    purposeTextArea.setLineWrap(true);
    purposeTextArea.setAutoscrolls(true);
    if (previousRegistrationData != null)
        purposeTextArea.setText(previousRegistrationData.getPurposeOfUsingTaverna());
    purposeTextArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_TAB) {
                if (evt.getModifiers() > 0)
                    purposeTextArea.transferFocusBackward();
                else
                    purposeTextArea.transferFocus();
                evt.consume();
            }
        }
    });
    JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea);
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 11;
    gbc.fill = HORIZONTAL;
    gbc.anchor = FIRST_LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(purposeScrollPane, gbc);

    // Terms and conditions
    termsAndConditionsCheckBox = new JCheckBox(I_AGREE_TO_THE_TERMS_AND_CONDITIONS);
    termsAndConditionsCheckBox.setFont(baseFont);
    termsAndConditionsCheckBox.setBorder(null);
    termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                termsAndConditionsCheckBox.setSelected(!termsAndConditionsCheckBox.isSelected());
            }
        }
    });
    // gbc.weightx = 0.0;
    // gbc.weighty = 0.0;
    // gbc.gridx = 0;
    // gbc.gridy = 12;
    // gbc.fill = NONE;
    // gbc.anchor = WEST;
    // gbc.gridwidth = 2;
    // gbc.insets = new Insets(10, 10, 0, 0);
    // mainPanel.add(termsAndConditionsCheckBox, gbc);

    // Terms and conditions link
    JEditorPane termsAndConditionsURL = new JEditorPane();
    termsAndConditionsURL.setEditable(false);
    termsAndConditionsURL.setBackground(getBackground());
    termsAndConditionsURL.setFocusable(false);
    HTMLEditorKit kit = new HTMLEditorKit();
    termsAndConditionsURL.setEditorKit(kit);
    StyleSheet styleSheet = kit.getStyleSheet();
    // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}");
    // // base font looks bigger when rendered as HTML
    styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:9px;}");
    Document doc = kit.createDefaultDocument();
    termsAndConditionsURL.setDocument(doc);
    termsAndConditionsURL.setText("<html><body><a href=\"" + TERMS_AND_CONDITIONS_URL + "\">"
            + TERMS_AND_CONDITIONS_URL + "</a></body></html>");
    termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent he) {
            if (he.getEventType() == ACTIVATED)
                followHyperlinkToTandCs();
        }
    });
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 13;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 10, 0, 10);
    JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT));
    termsAndConditionsPanel.add(termsAndConditionsCheckBox);
    termsAndConditionsPanel.add(termsAndConditionsURL);
    mainPanel.add(termsAndConditionsPanel, gbc);

    // Button panel
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton registerButton = new JButton("Register");
    registerButton.setFont(baseFont);
    registerButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                register();
            }
        }
    });
    registerButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            register();
        }
    });
    JButton doNotRegisterButton = new JButton("Do not ask me again");
    doNotRegisterButton.setFont(baseFont);
    doNotRegisterButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                doNotRegister();
            }
        }
    });
    doNotRegisterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doNotRegister();
        }
    });
    JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks
    remindMeLaterButton.setFont(baseFont);
    remindMeLaterButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                remindMeLater();
            }
        }
    });
    remindMeLaterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            remindMeLater();
        }
    });
    buttonPanel.add(registerButton);
    buttonPanel.add(remindMeLaterButton);
    buttonPanel.add(doNotRegisterButton);
    addDivider(buttonPanel, TOP, true);
    gbc.gridx = 0;
    gbc.gridy = 14;
    gbc.fill = HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(5, 10, 0, 10);
    gbc.gridwidth = 2;
    mainPanel.add(buttonPanel, gbc);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, CENTER);

    pack();
    setResizable(false);
    // Center the dialog on the screen (we do not have the parent)
    Dimension dimension = getToolkit().getScreenSize();
    Rectangle abounds = getBounds();
    setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2);
    setSize(getPreferredSize());
}

From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java

private JCheckBox getSolenoidValveTwoCheckBox() {
    if (solenoidValveTwoCheckBox == null) {
        solenoidValveTwoCheckBox = new JCheckBox("2.0"); //$NON-NLS-1$

        solenoidValveTwoCheckBox.addActionListener(new ActionListener() {

            @Override/*from w  w  w  . j a v a  2s  .com*/
            public void actionPerformed(ActionEvent e) {
                if (solenoidValveTwoCheckBox.isSelected())
                    solenoidValvesOfInterest.add(Double.valueOf(2.0));
                else
                    solenoidValvesOfInterest.remove(Double.valueOf(2.0));
            }
        });
    }
    return solenoidValveTwoCheckBox;
}

From source file:ca.phon.app.project.ProjectWindow.java

private void init() {
    /* Layout *//*from w w  w  .j  a va2s  .c o  m*/
    setLayout(new BorderLayout());

    final ProjectDataTransferHandler transferHandler = new ProjectDataTransferHandler(this);

    /* Create components */
    newCorpusButton = createNewCorpusButton();
    createCorpusButton = createCorpusButton();

    corpusList = new JList<String>();
    corpusModel = new CorpusListModel(getProject());
    corpusList.setModel(corpusModel);
    corpusList.setCellRenderer(new CorpusListCellRenderer());
    corpusList.setVisibleRowCount(20);
    corpusList.addListSelectionListener(e -> {
        if (getSelectedCorpus() != null) {
            String corpus = getSelectedCorpus();
            sessionModel.setCorpus(corpus);
            sessionList.clearSelection();
            corpusDetails.setCorpus(corpus);

            if (getProject().getCorpusSessions(corpus).size() == 0) {
                onSwapNewAndCreateSession(newSessionButton);
            } else {
                onSwapNewAndCreateSession(createSessionButton);
            }
        }
    });
    corpusList.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = corpusList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(corpusList.getSelectedIndices(), clickedIdx) < 0) {
                    corpusList.setSelectedIndex(clickedIdx);
                }
                showCorpusListContextMenu(e.getPoint());
            }
        }
    });

    final DragSource corpusDragSource = new DragSource();
    corpusDragSource.createDefaultDragGestureRecognizer(corpusList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        for (String corpus : getSelectedCorpora()) {
            final ProjectPath corpusPath = new ProjectPath(getProject(), corpus, null);
            paths.add(corpusPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    corpusList.setDragEnabled(true);
    corpusList.setTransferHandler(transferHandler);

    corpusDetails = new CorpusDetailsPane(getProject());
    corpusDetails.setWrapStyleWord(true);
    corpusDetails.setRows(6);
    corpusDetails.setLineWrap(true);
    corpusDetails.setBackground(Color.white);
    corpusDetails.setOpaque(true);
    JScrollPane corpusDetailsScroller = new JScrollPane(corpusDetails);

    sessionList = new JList<String>();
    newSessionButton = createNewSessionButton();
    createSessionButton = createSessionButton();
    sessionModel = new SessionListModel(getProject());
    sessionList.setModel(sessionModel);
    sessionList.setCellRenderer(new SessionListCellRenderer());
    sessionList.setVisibleRowCount(20);
    sessionList.addListSelectionListener(e -> {
        if (sessionList.getSelectedValue() != null && !e.getValueIsAdjusting()) {
            String corpus = getSelectedCorpus();
            String session = getSelectedSessionName();

            sessionDetails.setSession(corpus, session);
        }
    });
    sessionList.addMouseListener(new MouseInputAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == 1) {
                // get the clicked item
                int clickedItem = sessionList.locationToIndex(e.getPoint());
                if (sessionList.getModel().getElementAt(clickedItem) == null)
                    return;

                final String session = sessionList.getModel().getElementAt(clickedItem).toString();
                final String corpus = ((SessionListModel) sessionList.getModel()).getCorpus();

                msgPanel.reset();
                msgPanel.setMessageLabel("Opening '" + corpus + "." + session + "'");
                msgPanel.setIndeterminate(true);
                msgPanel.repaint();

                SwingUtilities.invokeLater(() -> {
                    final ActionEvent ae = new ActionEvent(sessionList, -1, "openSession");
                    (new OpenSessionAction(ProjectWindow.this, corpus, session)).actionPerformed(ae);

                    msgPanel.setIndeterminate(false);
                });
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = sessionList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(sessionList.getSelectedIndices(), clickedIdx) < 0) {
                    sessionList.setSelectedIndex(clickedIdx);
                }
                showSessionListContextMenu(e.getPoint());
            }
        }
    });

    sessionList.setDragEnabled(true);
    sessionList.setTransferHandler(transferHandler);

    final DragSource sessionDragSource = new DragSource();
    sessionDragSource.createDefaultDragGestureRecognizer(sessionList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        final String corpus = getSelectedCorpus();
        if (corpus == null)
            return;
        for (String session : getSelectedSessionNames()) {
            final ProjectPath sessionPath = new ProjectPath(getProject(), corpus, session);
            paths.add(sessionPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    sessionDetails = new SessionDetailsPane(getProject());
    sessionDetails.setLineWrap(true);
    sessionDetails.setRows(6);
    sessionDetails.setWrapStyleWord(true);
    sessionDetails.setBackground(Color.white);
    sessionDetails.setOpaque(true);
    JScrollPane sessionDetailsScroller = new JScrollPane(sessionDetails);

    JScrollPane corpusScroller = new JScrollPane(corpusList);
    JScrollPane sessionScroller = new JScrollPane(sessionList);

    blindModeBox = new JCheckBox("Blind transcription");
    blindModeBox.setSelected(false);

    msgPanel = new StatusPanel();

    corpusPanel = new JPanel(new BorderLayout());
    corpusPanel.add(newCorpusButton, BorderLayout.NORTH);
    corpusPanel.add(corpusScroller, BorderLayout.CENTER);
    corpusPanel.add(corpusDetailsScroller, BorderLayout.SOUTH);

    sessionPanel = new JPanel(new BorderLayout());
    sessionPanel.add(newSessionButton, BorderLayout.NORTH);
    sessionPanel.add(sessionScroller, BorderLayout.CENTER);
    sessionPanel.add(sessionDetailsScroller, BorderLayout.SOUTH);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(corpusPanel);
    splitPane.setRightComponent(sessionPanel);
    splitPane.setResizeWeight(0.5);

    // invoke later
    SwingUtilities.invokeLater(() -> {
        splitPane.setDividerLocation(0.5);
    });

    // the frame layout
    String projectName = null;
    projectName = getProject().getName();

    DialogHeader header = new DialogHeader(projectName, StringUtils.abbreviate(projectLoadPath, 80));

    add(header, BorderLayout.NORTH);

    CellConstraints cc = new CellConstraints();
    final JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref"));
    topPanel.add(msgPanel, cc.xy(1, 1));
    topPanel.add(blindModeBox, cc.xy(3, 1));

    add(splitPane, BorderLayout.CENTER);
    add(topPanel, BorderLayout.SOUTH);

    // if no corpora are currently available, 'prompt' the user to create a new one
    if (getProject().getCorpora().size() == 0) {
        SwingUtilities.invokeLater(() -> {
            onSwapNewAndCreateCorpus(newCorpusButton);
        });
    } else {
        SwingUtilities.invokeLater(() -> {
            corpusList.setSelectedIndex(0);
        });
    }
}

From source file:com.mirth.connect.client.ui.SettingsPanelServer.java

public void doRestore() {
    if (getFrame().isSaveEnabled()) {
        if (!getFrame().alertOkCancel(this, "Your new settings will first be saved.  Continue?")) {
            return;
        }/*from  ww w .j a v a2s . c  o  m*/
        if (!doSave()) {
            return;
        }
    }

    String content = getFrame().browseForFileString("XML");

    if (content != null) {
        try {
            if (!getFrame().promptObjectMigration(content, "server configuration")) {
                return;
            }

            final ServerConfiguration configuration = ObjectXMLSerializer.getInstance().deserialize(content,
                    ServerConfiguration.class);

            final JCheckBox deployChannelsCheckBox = new JCheckBox("Deploy all channels after import");
            deployChannelsCheckBox.setSelected(true);
            String warningMessage = "Import configuration from " + configuration.getDate()
                    + "?\nWARNING: This will overwrite all current channels,\nalerts, server properties, and plugin properties.\n";
            Object[] params = { warningMessage, new JLabel(" "), deployChannelsCheckBox };
            int option = JOptionPane.showConfirmDialog(this, params, "Select an Option",
                    JOptionPane.YES_NO_OPTION);

            if (option == JOptionPane.YES_OPTION) {
                final Set<String> alertIds = new HashSet<String>();
                for (AlertStatus alertStatus : PlatformUI.MIRTH_FRAME.mirthClient.getAlertStatusList()) {
                    alertIds.add(alertStatus.getId());
                }

                final String workingId = getFrame().startWorking("Restoring server config...");

                SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

                    private boolean updateAlerts = false;

                    public Void doInBackground() {
                        try {
                            getFrame().mirthClient.setServerConfiguration(configuration,
                                    deployChannelsCheckBox.isSelected());
                            getFrame().channelPanel.clearChannelCache();
                            doRefresh();
                            getFrame().alertInformation(SettingsPanelServer.this,
                                    "Your configuration was successfully restored.");
                            updateAlerts = true;
                        } catch (ClientException e) {
                            getFrame().alertThrowable(SettingsPanelServer.this, e);
                        }
                        return null;
                    }

                    public void done() {
                        if (getFrame().alertPanel == null) {
                            getFrame().alertPanel = new DefaultAlertPanel();
                        }

                        if (updateAlerts) {
                            getFrame().alertPanel.updateAlertDetails(alertIds);
                        }
                        getFrame().stopWorking(workingId);
                    }
                };

                worker.execute();
            }
        } catch (Exception e) {
            getFrame().alertError(this, "Invalid server configuration file.");
        }
    }
}

From source file:gtu._work.ui.RegexCatchReplacer_Ebao.java

private void initGUI() {
    try {//from ww  w  . j a  va  2s  . com
        {
        }
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("source", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        replaceArea = new JTextArea();
                        jScrollPane1.setViewportView(replaceArea);
                        replaceArea.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt)
                                        .addJMenuItem("load from file", true, new ActionListener() {

                                            Thread newThread;

                                            public void actionPerformed(ActionEvent arg0) {
                                                if (newThread != null
                                                        && newThread.getState() != Thread.State.TERMINATED) {
                                                    JCommonUtil._jOptionPane_showMessageDialog_error(
                                                            "file is loading!");
                                                    return;
                                                }

                                                final File file = JCommonUtil._jFileChooser_selectFileOnly();
                                                if (file == null) {
                                                    JCommonUtil._jOptionPane_showMessageDialog_error(
                                                            "file is not correct!");
                                                    return;
                                                }
                                                String defaultCharset = Charset.defaultCharset().displayName();
                                                String chst = (String) JCommonUtil._jOptionPane_showInputDialog(
                                                        "input your charset!", defaultCharset);
                                                final Charset charset2 = Charset.forName(
                                                        StringUtils.defaultIfEmpty(chst, defaultCharset));

                                                newThread = new Thread(Thread.currentThread().getThreadGroup(),
                                                        new Runnable() {
                                                            public void run() {
                                                                try {
                                                                    loadFromFileSb = new StringBuilder();
                                                                    BufferedReader reader = new BufferedReader(
                                                                            new InputStreamReader(
                                                                                    new FileInputStream(file),
                                                                                    charset2));
                                                                    for (String line = null; (line = reader
                                                                            .readLine()) != null;) {
                                                                        loadFromFileSb.append(line + "\n");
                                                                    }
                                                                    reader.close();
                                                                    replaceArea
                                                                            .setText(loadFromFileSb.toString());
                                                                    JCommonUtil
                                                                            ._jOptionPane_showMessageDialog_info(
                                                                                    "load completed!");
                                                                } catch (Exception e) {
                                                                    JCommonUtil.handleException(e);
                                                                }
                                                            }
                                                        }, "" + System.currentTimeMillis());
                                                newThread.setDaemon(true);
                                                newThread.start();
                                            }
                                        }).show();
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("param", null, jPanel2, null);
                {
                    exeucte = new JButton();
                    jPanel2.add(exeucte, BorderLayout.SOUTH);
                    exeucte.setText("exeucte");
                    exeucte.setPreferredSize(new java.awt.Dimension(491, 125));
                    exeucte.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exeucteActionPerformed(evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel2.add(jPanel3, BorderLayout.CENTER);
                    {
                        repFromText = new JTextField();
                    }
                    {
                        repToText = new JTextField();
                    }
                    jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup()
                            .addContainerGap(25, 25)
                            .addGroup(jPanel3Layout.createParallelGroup()
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(20, Short.MAX_VALUE));
                    jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
                }
                {
                    addToTemplate = new JButton();
                    jPanel2.add(addToTemplate, BorderLayout.NORTH);
                    addToTemplate.setText("add to template");
                    addToTemplate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            prop.put(repFromText.getText(), repToText.getText());
                            reloadTemplateList();
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("result", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283));
                    {
                        DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count");
                        resultArea = new JTable();
                        jScrollPane2.setViewportView(resultArea);
                        JTableUtil.defaultSetting(resultArea);
                        resultArea.setModel(resultAreaModel);
                    }
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                jTabbedPane1.addTab("template", null, jPanel5, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        templateList = new JList();
                        jScrollPane3.setViewportView(templateList);
                        reloadTemplateList();
                    }
                    templateList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            if (templateList.getLeadSelectionIndex() == -1) {
                                return;
                            }
                            Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil
                                    .getLeadSelectionObject(templateList);
                            repFromText.setText((String) entry.getKey());
                            repToText.setText((String) entry.getValue());
                        }
                    });
                    templateList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(templateList).defaultJListKeyPressed(evt);
                        }
                    });
                }
            }
            {
                jPanel6 = new JPanel();
                FlowLayout jPanel6Layout = new FlowLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("result1", null, jPanel6, null);
                {
                    resultBtn1 = new JButton();
                    jPanel6.add(resultBtn1);
                    resultBtn1.setText("to String[]");
                    resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32));
                    resultBtn1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            JTableUtil tableUtil = JTableUtil.newInstance(resultArea);
                            int[] rowPoss = tableUtil.getSelectedRows();
                            DefaultTableModel model = tableUtil.getModel();
                            List<Object> valueList = new ArrayList<Object>();
                            for (int ii = 0; ii < rowPoss.length; ii++) {
                                valueList.add(model.getValueAt(rowPoss[ii], 0));
                            }
                            String reult = valueList.toString().replaceAll("[\\s]", "")
                                    .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\"");
                            ClipboardUtil.getInstance().setContents(reult);
                        }
                    });
                }
                {
                    resultBtn2 = new JButton();
                    jPanel6.add(resultBtn2);
                    resultBtn2.setText("TODO");
                    resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32));
                    resultBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("resultBtn1.actionPerformed, event=" + evt);
                            // TODO add your code for
                            // resultBtn1.actionPerformed
                            JCommonUtil._jOptionPane_showMessageDialog_info("TODO");
                        }
                    });
                }
            }
        }
        this.setSize(512, 350);
        JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList);
        {
            panel = new JPanel();
            jTabbedPane1.addTab("eBao", null, panel, null);
            panel.setLayout(new BorderLayout(0, 0));
            {
                scrollPane = new JScrollPane();
                panel.add(scrollPane, BorderLayout.CENTER);
                {
                    ebaoTable = new JTable();
                    scrollPane.setViewportView(ebaoTable);
                    // TODO
                    DefaultTableModel ebaoModel = JTableUtil.createModel(true, "match", "label");
                    JTableUtil.defaultSetting(ebaoTable);
                    ebaoTable.setModel(ebaoModel);
                }
            }
            {
                exactEbaoSearchChk = new JCheckBox("");
                panel.add(exactEbaoSearchChk, BorderLayout.NORTH);
            }
        }

        JCommonUtil.frameCloseDo(this, new WindowAdapter() {
            public void windowClosing(WindowEvent paramWindowEvent) {
                if (StringUtils.isNotBlank(repFromText.getText())) {
                    prop.put(repFromText.getText(), repToText.getText());
                }
                try {
                    prop.store(new FileOutputStream(propFile), "regexText");
                } catch (Exception e) {
                    JCommonUtil.handleException("properties store error!", e);
                }
                setVisible(false);
                dispose();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java

private JCheckBox getSolenoidValveFourCheckBox() {
    if (solenoidValveFourCheckBox == null) {
        solenoidValveFourCheckBox = new JCheckBox("4.0"); //$NON-NLS-1$

        solenoidValveFourCheckBox.addActionListener(new ActionListener() {

            @Override//  w ww . j  a va 2 s  .  com
            public void actionPerformed(ActionEvent e) {
                if (solenoidValveFourCheckBox.isSelected())
                    solenoidValvesOfInterest.add(Double.valueOf(4.0));
                else
                    solenoidValvesOfInterest.remove(Double.valueOf(4.0));
            }
        });
    }
    return solenoidValveFourCheckBox;
}

From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java

/**
 *
 * @return Create the menu that allows load the result from others
 * experiments.//from w  w  w.j av  a  2s.c  o m
 */
private JMenu createMenu() {

    final JMenu fileMenu = new JMenu("Options");

    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    fileMenu.add("Add report file or directory").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (curveOptions != null) {
                curveOptions.setVisible(false);
                curveOptions = null;
            }
            int action = f.showOpenDialog(fileMenu);

            if (action == JFileChooser.APPROVE_OPTION) {

                loadReportFile(f.getSelectedFile());

            }

        }
    });

    fileMenu.add("Area under learning curve (ALC)").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            if (comboBox.getItemCount() != 0) {

                if (!comboBox.getSelectedItem().toString().isEmpty()) {

                    StringBuilder st = new StringBuilder();

                    st.append("Measure: ").append(comboBox.getSelectedItem()).append("\n\n");

                    for (int query = 0; query < queryNames.size(); query++) {

                        double value = LearningCurveUtility.getArea(evaluationsCollection.get(query),
                                comboBox.getSelectedItem().toString());

                        String valueString = String.format("%.3f", value);

                        st.append(queryNames.get(query)).append(": ").append(valueString).append("\n");

                    }

                    JOptionPane.showMessageDialog(content, st.toString(), "Area under the learning curve",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
    });

    fileMenu.add("Clear").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            queryNames = new ArrayList<String>();
            evaluationsCollection = new ArrayList<List<AbstractEvaluation>>();
            comboBox.removeAllItems();
            controlCurveColor = new HashMap<String, Color>();
            colors.clear();
            data = null;
            set.clear();
            curveOptions.setVisible(false);
            curveOptions = null;
            setSeries.clear();
            passiveEvaluation = null;

        }
    });

    fileMenu.add("Curve options").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            data = informationTable();

            if (queryNames.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Please add curves");
                return;
            }
            if (curveOptions == null) {
                curveOptions = new LearningCurvesVisualTable(ExternalBasicChart.this);
            } else {
                curveOptions.setVisible(true);
            }

        }

    });

    final JCheckBox viewPoints = new JCheckBox("View points's shapes");
    viewPoints.setSelected(false);

    viewPoints.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewPointsForm = viewPoints.isSelected();
            jComboBoxItemStateChanged();
        }
    });

    fileMenu.add(viewPoints);

    final JCheckBox withOutColor = new JCheckBox("View without color");
    withOutColor.setSelected(false);

    withOutColor.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewWithOutColor = withOutColor.isSelected();
            jComboBoxItemStateChanged();
        }
    });

    fileMenu.add(withOutColor);

    return fileMenu;
}

From source file:de.mycrobase.jcloudapp.Main.java

private static Map<String, String> showLoginDialog() {
    String message = ""; //"Welcome to JCloudApp!";

    JTextField usernameField = new JTextField();
    JPasswordField passwordField = new JPasswordField();
    JCheckBox remeberCheck = new JCheckBox("Remember login (on disk)");
    remeberCheck.setSelected(true);/*ww  w .  ja  va2s. c o  m*/
    Object[] content = { message, "Username:", usernameField, "Password:", passwordField, remeberCheck };

    //        int res = JOptionPane.showOptionDialog(
    //            null, content, "JCloudApp - Login",
    //            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, icon,
    //            null, usernameField);
    int res = JOptionPane.showConfirmDialog(null, content, "JCloudApp - Login", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, IconLarge);

    if (res == JOptionPane.OK_OPTION) {
        HashMap<String, String> m = new HashMap<String, String>();
        m.put("username", usernameField.getText());
        m.put("password", new String(passwordField.getPassword()));
        m.put("remember", Boolean.toString(remeberCheck.isSelected()));
        return m;
    } else {
        return null;
    }
}

From source file:edu.uci.ics.jung.samples.PluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 *//*  w ww . j  av a  2 s. com*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.EAST);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.NORTH);
    control_panel.add(edge_panel, BorderLayout.SOUTH);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("seed highlight");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("stroke highlight on selection");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show voltage values");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("shape by degree");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("size by voltage");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("stretch by degree ratio");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    e_ortho = new JRadioButton("orthogonal");
    e_ortho.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_ortho);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    shape_panel.add(e_ortho);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("highlight edge weights");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weight values");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    e_arrow_centered = new JCheckBox("centered");
    e_arrow_centered.addActionListener(this);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);
    arrow_panel.add(e_arrow_centered);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);
    zoom_at_mouse.setSelected(true);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel zoomPanel = new JPanel();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    JPanel fontPanel = new JPanel();
    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);
    fontPanel.add(font);

    both_panel.add(zoomPanel);
    both_panel.add(fontPanel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    JPanel comboGrid = new JPanel(new GridLayout(0, 1));
    comboGrid.add(modePanel);
    fontPanel.add(comboGrid);

    JComboBox cb = new JComboBox();
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.NE);
    cb.addItem(Renderer.VertexLabel.Position.E);
    cb.addItem(Renderer.VertexLabel.Position.SE);
    cb.addItem(Renderer.VertexLabel.Position.S);
    cb.addItem(Renderer.VertexLabel.Position.SW);
    cb.addItem(Renderer.VertexLabel.Position.W);
    cb.addItem(Renderer.VertexLabel.Position.NW);
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.CNTR);
    cb.addItem(Renderer.VertexLabel.Position.AUTO);
    cb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
    JPanel positionPanel = new JPanel();
    positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position"));
    positionPanel.add(cb);

    comboGrid.add(positionPanel);

}