Example usage for javax.swing JTextArea setFocusable

List of usage examples for javax.swing JTextArea setFocusable

Introduction

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

Prototype

public void setFocusable(boolean focusable) 

Source Link

Document

Sets the focusable state of this Component to the specified value.

Usage

From source file:io.github.tavernaextras.biocatalogue.integration.config.BioCataloguePluginConfigurationPanel.java

private void initialiseUI() {
    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.weightx = 1.0;//  w w  w . j a  v a 2s. com

    c.gridx = 0;
    c.gridy = 0;
    JTextArea taDescription = new JTextArea("Configure the Service Catalogue integration functionality");
    taDescription.setFont(taDescription.getFont().deriveFont(Font.PLAIN, 11));
    taDescription.setLineWrap(true);
    taDescription.setWrapStyleWord(true);
    taDescription.setEditable(false);
    taDescription.setFocusable(false);
    taDescription.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    this.add(taDescription, c);

    c.gridy++;
    c.insets = new Insets(20, 0, 0, 0);
    JLabel jlBioCatalogueAPIBaseURL = new JLabel("Base URL of the Service Catalogue instance to connect to:");
    this.add(jlBioCatalogueAPIBaseURL, c);

    c.gridy++;
    c.insets = new Insets(0, 0, 0, 0);
    tfBioCatalogueAPIBaseURL = new JTextField();
    this.add(tfBioCatalogueAPIBaseURL, c);

    c.gridy++;
    c.insets = new Insets(30, 0, 0, 0);
    // We are not removing BioCatalogue services from its config panel any more - 
    // they are being handled by the Taverna's Service Registry
    //    JButton bForgetStoredServices = new JButton("Forget services added to Service Panel by BioCatalogue Plugin");
    //    bForgetStoredServices.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e)
    //      {
    //        int response = JOptionPane.showConfirmDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent...
    //                                       "Are you sure you want to clear all SOAP operations and REST methods\n" +
    //                                       "that were added to the Service Panel by the BioCatalogue Plugin?\n\n" +
    //                                       "This action is permanent is cannot be undone.\n\n" +
    //                                       "Do you want to proceed?", "BioCatalogue Plugin", JOptionPane.YES_NO_OPTION);
    //        
    //        if (response == JOptionPane.YES_OPTION)
    //        {
    //          BioCatalogueServiceProvider.clearRegisteredServices();
    //          JOptionPane.showMessageDialog(null,  // no way T2ConfigurationFrame instance can be obtained to be used as a parent...
    //                          "Stored services have been successfully cleared, but will remain\n" +
    //                          "being shown in Service Panel during this session.\n\n" +
    //                          "They will not appear in the Service Panel after you restart Taverna.",
    //                          "BioCatalogue Plugin", JOptionPane.INFORMATION_MESSAGE);
    //        }
    //      }
    //    });
    //    this.add(bForgetStoredServices, c);

    JButton bLoadDefaults = new JButton("Load Defaults");
    bLoadDefaults.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            loadDefaults();
        }
    });

    JButton bReset = new JButton("Reset");
    bReset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetFields();
        }
    });

    JButton bApply = new JButton("Apply");
    bApply.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyChanges();
        }
    });

    JPanel jpActionButtons = new JPanel();
    jpActionButtons.add(bLoadDefaults);
    jpActionButtons.add(bReset);
    jpActionButtons.add(bApply);
    c.insets = new Insets(30, 0, 0, 0);
    c.gridy++;
    c.weighty = 1.0;
    this.add(jpActionButtons, c);
}

From source file:ConfigFiles.java

public JPanel addPanel(String title, String description, final JTextField textfield, String fieldtext, int Y,
        boolean withbutton, ActionListener actionlistener) {
    JPanel p1 = new JPanel();
    p1.setBackground(Color.WHITE);
    TitledBorder border = BorderFactory.createTitledBorder(title);
    border.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p1.setBorder(border);//from w ww.j ava2 s  .c  o m
    p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
    p1.setBounds(80, Y, 800, 75);
    paths.add(p1);
    JTextArea tcpath = new JTextArea(description);
    tcpath.setWrapStyleWord(true);
    tcpath.setLineWrap(true);
    tcpath.setEditable(false);
    tcpath.setCursor(null);
    tcpath.setOpaque(false);
    tcpath.setFocusable(false);
    tcpath.setFont(new Font("Arial", Font.PLAIN, 12));
    tcpath.setBackground(getBackground());
    tcpath.setMaximumSize(new Dimension(170, 22));
    tcpath.setPreferredSize(new Dimension(170, 22));
    tcpath.setBorder(null);
    JPanel p11 = new JPanel();
    p11.setBackground(Color.WHITE);
    p11.setLayout(new GridLayout());
    p11.add(tcpath);
    p11.setMaximumSize(new Dimension(700, 18));
    p11.setPreferredSize(new Dimension(700, 18));
    textfield.setMaximumSize(new Dimension(340, 27));
    textfield.setPreferredSize(new Dimension(340, 27));
    textfield.setText(fieldtext);
    JButton b = null;
    if (withbutton) {
        b = new JButton("...");
        if (!PermissionValidator.canChangeFWM()) {
            b.setEnabled(false);
        }
        b.setMaximumSize(new Dimension(50, 20));
        b.setPreferredSize(new Dimension(50, 20));
        if (actionlistener == null) {
            b.addActionListener(new AbstractAction() {
                public void actionPerformed(ActionEvent ev) {
                    Container c;

                    if (RunnerRepository.container != null)
                        c = RunnerRepository.container.getParent();
                    else
                        c = RunnerRepository.window;
                    try {
                        new MySftpBrowser(RunnerRepository.host, RunnerRepository.user,
                                RunnerRepository.password, textfield, c, false);
                    } catch (Exception e) {
                        System.out.println("There was a problem in opening sftp browser!");
                        e.printStackTrace();
                    }
                }
            });
        } else {
            b.addActionListener(actionlistener);
            b.setText("Save");
            b.setMaximumSize(new Dimension(70, 20));
            b.setPreferredSize(new Dimension(70, 20));
        }
    }
    JPanel p12 = new JPanel();
    p12.setBackground(Color.WHITE);
    p12.add(textfield);
    if (withbutton)
        p12.add(b);
    p12.setMaximumSize(new Dimension(700, 32));
    p12.setPreferredSize(new Dimension(700, 32));
    p1.add(p11);
    p1.add(p12);
    return p12;
}

From source file:ConfigFiles.java

public ConfigFiles(Dimension screensize) {
    //         initializeFileBrowser();
    paths = new JPanel();
    paths.setBackground(Color.WHITE);
    //paths.setBorder(BorderFactory.createTitledBorder("Paths"));
    paths.setLayout(null);//from   w  ww .  jav  a 2s . c o m
    paths.setPreferredSize(new Dimension(930, 1144));
    paths.setSize(new Dimension(930, 1144));
    paths.setMinimumSize(new Dimension(930, 1144));
    paths.setMaximumSize(new Dimension(930, 1144));
    //paths.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    setLayout(null);
    ttcpath = new JTextField();
    addPanel("TestCase Source Path",
            "Master directory with the test cases that can" + " be run by the framework", ttcpath,
            RunnerRepository.TESTSUITEPATH, 10, true, null);
    tMasterXML = new JTextField();
    tUsers = new JTextField();

    addPanel("Projects Path", "Location of projects XML files", tUsers, RunnerRepository.REMOTEUSERSDIRECTORY,
            83, true, null);

    tSuites = new JTextField();
    addPanel("Predefined Suites Path", "Location of predefined suites", tSuites,
            RunnerRepository.PREDEFINEDSUITES, 156, true, null);

    testconfigpath = new JTextField();
    addPanel("Test Configuration Path", "Test Configuration path", testconfigpath,
            RunnerRepository.TESTCONFIGPATH, 303, true, null);

    tepid = new JTextField();
    addPanel("EP name File", "Location of the file that contains" + " the Ep name list", tepid,
            RunnerRepository.REMOTEEPIDDIR, 595, true, null);
    tlog = new JTextField();
    addPanel("Logs Path", "Location of the directory that stores the most recent log files."
            + " The files are re-used each Run.", tlog, RunnerRepository.LOGSPATH, 667, true, null);
    tsecondarylog = new JTextField();

    JPanel p = addPanel("Secondary Logs Path",
            "Location of the directory that archives copies of the most recent log files, with"
                    + " original file names appended with <.epoch time>",
            tsecondarylog, RunnerRepository.SECONDARYLOGSPATH, 930, true, null);
    logsenabled.setSelected(Boolean.parseBoolean(RunnerRepository.PATHENABLED));
    logsenabled.setBackground(Color.WHITE);
    p.add(logsenabled);

    JPanel p7 = new JPanel();
    p7.setBackground(Color.WHITE);
    TitledBorder border7 = BorderFactory.createTitledBorder("Log Files");
    border7.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border7.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p7.setBorder(border7);
    p7.setLayout(new BoxLayout(p7, BoxLayout.Y_AXIS));
    p7.setBounds(80, 740, 800, 190);
    paths.add(p7);
    JTextArea log2 = new JTextArea("All the log files that will be monitored");
    log2.setWrapStyleWord(true);
    log2.setLineWrap(true);
    log2.setEditable(false);
    log2.setCursor(null);
    log2.setOpaque(false);
    log2.setFocusable(false);
    log2.setBorder(null);
    log2.setFont(new Font("Arial", Font.PLAIN, 12));
    log2.setBackground(getBackground());
    log2.setMaximumSize(new Dimension(170, 25));
    log2.setPreferredSize(new Dimension(170, 25));
    JPanel p71 = new JPanel();
    p71.setBackground(Color.WHITE);
    p71.setLayout(new GridLayout());
    p71.setMaximumSize(new Dimension(700, 13));
    p71.setPreferredSize(new Dimension(700, 13));
    p71.add(log2);
    JPanel p72 = new JPanel();
    p72.setBackground(Color.WHITE);
    p72.setLayout(new BoxLayout(p72, BoxLayout.Y_AXIS));
    trunning = new JTextField();
    p72.add(addField(trunning, "Running: ", 0));
    tdebug = new JTextField();
    p72.add(addField(tdebug, "Debug: ", 1));
    tsummary = new JTextField();
    p72.add(addField(tsummary, "Summary: ", 2));
    tinfo = new JTextField();
    p72.add(addField(tinfo, "Info: ", 3));
    tcli = new JTextField();
    p72.add(addField(tcli, "Cli: ", 4));
    p7.add(p71);
    p7.add(p72);
    libpath = new JTextField();

    addPanel("Library path", "Secondary user library path", libpath, RunnerRepository.REMOTELIBRARY, 229, true,
            null);

    JPanel p8 = new JPanel();
    p8.setBackground(Color.WHITE);
    TitledBorder border8 = BorderFactory.createTitledBorder("File");
    border8.setTitleFont(new Font("Arial", Font.PLAIN, 14));
    border8.setBorder(BorderFactory.createLineBorder(new Color(150, 150, 150), 1));
    p8.setBorder(border8);
    p8.setLayout(null);
    p8.setBounds(80, 1076, 800, 50);
    if (PermissionValidator.canChangeFWM()) {
        paths.add(p8);
    }
    JButton save = new JButton("Save");
    save.setToolTipText("Save and automatically load config");
    save.setBounds(490, 20, 70, 20);
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            saveXML(false, "fwmconfig");
            loadConfig("fwmconfig.xml");
        }
    });
    p8.add(save);
    //         if(!PermissionValidator.canChangeFWM()){
    //             save.setEnabled(false);
    //         }
    JButton saveas = new JButton("Save as");
    saveas.setBounds(570, 20, 90, 20);
    saveas.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            String filename = CustomDialog.showInputDialog(JOptionPane.QUESTION_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "File Name", "Please enter file name");
            if (!filename.equals("NULL")) {
                saveXML(false, filename);
            }
        }
    });
    p8.add(saveas);

    final JButton loadXML = new JButton("Load Config");
    loadXML.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                String[] configs = RunnerRepository
                        .getRemoteFolderContent(RunnerRepository.USERHOME + "/twister/config/");
                JComboBox combo = new JComboBox(configs);
                int resp = (Integer) CustomDialog.showDialog(combo, JOptionPane.INFORMATION_MESSAGE,
                        JOptionPane.OK_CANCEL_OPTION, ConfigFiles.this, "Config", null);
                final String config;
                if (resp == JOptionPane.OK_OPTION)
                    config = combo.getSelectedItem().toString();
                else
                    config = null;
                if (config != null) {
                    new Thread() {
                        public void run() {
                            setEnabledTabs(false);
                            JFrame progress = new JFrame();
                            progress.setAlwaysOnTop(true);
                            progress.setLocation((int) loadXML.getLocationOnScreen().getX(),
                                    (int) loadXML.getLocationOnScreen().getY());
                            progress.setUndecorated(true);
                            JProgressBar bar = new JProgressBar();
                            bar.setIndeterminate(true);
                            progress.add(bar);
                            progress.pack();
                            progress.setVisible(true);
                            loadConfig(config);
                            progress.dispose();
                            setEnabledTabs(true);
                        }
                    }.start();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    loadXML.setBounds(670, 20, 120, 20);
    p8.add(loadXML);
    //         if(!PermissionValidator.canChangeFWM()){
    //             loadXML.setEnabled(false);
    //         }

    tdbfile = new JTextField();
    addPanel("Database XML path", "File location for database configuration", tdbfile,
            RunnerRepository.REMOTEDATABASECONFIGPATH + RunnerRepository.REMOTEDATABASECONFIGFILE, 375, true,
            null);
    temailfile = new JTextField();
    //         emailpanel = (JPanel)
    addPanel("Email XML path", "File location for email configuration", temailfile,
            RunnerRepository.REMOTEEMAILCONFIGPATH + RunnerRepository.REMOTEEMAILCONFIGFILE, 448, true, null)
                    .getParent();
    //paths.remove(emailpanel);

    //         emailpanel.setBounds(360,440,350,100);
    //         RunnerRepository.window.mainpanel.p4.getEmails().add(emailpanel);

    tglobalsfile = new JTextField();
    addPanel("Globals XML file", "File location for globals parameters", tglobalsfile,
            RunnerRepository.GLOBALSREMOTEFILE, 521, true, null);

    tceport = new JTextField();
    addPanel("Central Engine Port", "Central Engine port", tceport, RunnerRepository.getCentralEnginePort(),
            1003, false, null);
    //         traPort = new JTextField();
    //         addPanel("Resource Allocator Port","Resource Allocator Port",
    //                 traPort,RunnerRepository.getResourceAllocatorPort(),808,false,null);                
    //         thttpPort = new JTextField();
    //         addPanel("HTTP Server Port","HTTP Server Port",thttpPort,
    //                 RunnerRepository.getHTTPServerPort(),740,false,null);

    //paths.add(loadXML);

    if (!PermissionValidator.canChangeFWM()) {
        ttcpath.setEnabled(false);
        tMasterXML.setEnabled(false);
        tUsers.setEnabled(false);
        tepid.setEnabled(false);
        tSuites.setEnabled(false);
        tlog.setEnabled(false);
        trunning.setEnabled(false);
        tdebug.setEnabled(false);
        tsummary.setEnabled(false);
        tinfo.setEnabled(false);
        tcli.setEnabled(false);
        tdbfile.setEnabled(false);
        temailfile.setEnabled(false);
        tceport.setEnabled(false);
        libpath.setEnabled(false);
        tsecondarylog.setEnabled(false);
        testconfigpath.setEnabled(false);
        tglobalsfile.setEnabled(false);
        logsenabled.setEnabled(false);
    }

}

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);//www  .ja  v  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:org.kchine.rpf.PoolUtils.java

public static void unzip(InputStream is, String destination, NameFilter nameFilter, int bufferSize,
        boolean showProgress, String taskName, int estimatedFilesNumber) {

    destination.replace('\\', '/');
    if (!destination.endsWith("/"))
        destination = destination + "/";

    final JTextArea area = showProgress ? new JTextArea() : null;
    final JProgressBar jpb = showProgress ? new JProgressBar(0, 100) : null;
    final JFrame f = showProgress ? new JFrame(taskName) : null;

    if (showProgress) {
        Runnable runnable = new Runnable() {
            public void run() {
                area.setFocusable(false);
                jpb.setIndeterminate(true);
                JPanel p = new JPanel(new BorderLayout());
                p.add(jpb, BorderLayout.SOUTH);
                p.add(new JScrollPane(area), BorderLayout.CENTER);
                f.add(p);//from   ww w  .j av  a2  s.  c  o m
                f.pack();
                f.setSize(300, 90);
                f.setVisible(true);
                locateInScreenCenter(f);
            }
        };

        if (SwingUtilities.isEventDispatchThread())
            runnable.run();
        else {
            SwingUtilities.invokeLater(runnable);
        }
    }

    try {

        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
        int entriesNumber = 0;
        int currentPercentage = 0;
        int count;
        byte data[] = new byte[bufferSize];
        ZipEntry entry;
        while ((entry = zis.getNextEntry()) != null) {
            if (!entry.isDirectory() && (nameFilter == null || nameFilter.accept(entry.getName()))) {
                String entryName = entry.getName();
                prepareFileDirectories(destination, entryName);
                String destFN = destination + File.separator + entry.getName();

                FileOutputStream fos = new FileOutputStream(destFN);
                BufferedOutputStream dest = new BufferedOutputStream(fos, bufferSize);
                while ((count = zis.read(data, 0, bufferSize)) != -1) {
                    dest.write(data, 0, count);
                }
                dest.flush();
                dest.close();

                if (showProgress) {
                    ++entriesNumber;
                    final int p = (int) (100 * entriesNumber / estimatedFilesNumber);
                    if (p > currentPercentage) {
                        currentPercentage = p;
                        final JTextArea fa = area;
                        final JProgressBar fjpb = jpb;
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                fjpb.setIndeterminate(false);
                                fjpb.setValue(p);
                                fa.setText("\n" + p + "%" + " Done ");
                            }
                        });

                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                fa.setCaretPosition(fa.getText().length());
                                fa.repaint();
                                fjpb.repaint();
                            }
                        });

                    }
                }
            }
        }
        zis.close();
        if (showProgress) {
            f.dispose();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterUIElement.java

/**
 * Make the JTextArea represent a multiline label.
 * /*  w w w .j  a  va  2  s  .  c om*/
 * @param textArea The component to handle.
 */
private void makeLabelStyle(JTextArea textArea) {
    if (textArea == null)
        return;
    textArea.setEditable(false);
    textArea.setCursor(null);
    textArea.setOpaque(false);
    textArea.setFocusable(false);
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new title text area for popup windows.
 * //www . j ava 2  s .  c o m
 * @param titleText
 *            the title text
 * 
 * @return the newly created text area
 */
public static JTextArea newPopupTitleArea(String titleText) {
    JTextArea textTitle = new JTextArea();
    textTitle.setEditable(false);
    textTitle.setText(titleText);
    textTitle.setBackground(UI.POPUP_BACKGROUND);
    textTitle.setFont(UI.STANDARD_FONT.deriveFont(Font.BOLD));
    textTitle.setLineWrap(true);
    textTitle.setWrapStyleWord(true);
    textTitle.setFocusable(false);
    textTitle.setBorder(new EmptyBorder(5, 5, 5, 5));
    return textTitle;
}

From source file:util.ui.UiUtilities.java

/**
 * Creates a text area that holds a help text.
 *
 * @param msg//from  w  w w.j  a v  a 2s. com
 *          The help text.
 * @return A text area containing the help text.
 */
public static JTextArea createHelpTextArea(String msg) {
    JTextArea descTA = new JTextArea(msg);
    descTA.setBorder(BorderFactory.createEmptyBorder());
    descTA.setFont(new JLabel().getFont());
    descTA.setEditable(false);
    descTA.setOpaque(false);
    descTA.setWrapStyleWord(true);
    descTA.setLineWrap(true);
    descTA.setFocusable(false);

    Color bg = new JPanel().getBackground();

    descTA.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));

    return descTA;
}