Example usage for javax.swing JLabel setToolTipText

List of usage examples for javax.swing JLabel setToolTipText

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:com.dragoniade.deviantart.ui.PreferencesDialog.java

public PreferencesDialog(final DownloaderGUI owner, Properties config) {
    super(owner, "Preferences", true);

    HttpClientParams params = new HttpClientParams();
    params.setVersion(HttpVersion.HTTP_1_1);
    params.setSoTimeout(30000);/*from   w w  w . jav a2  s  .  c  om*/
    client = new HttpClient(params);
    setProxy(ProxyCfg.parseConfig(config));

    sample = new Deviation();
    sample.setId(15972367L);
    sample.setTitle("Fella Promo");
    sample.setArtist("devart");
    sample.setImageDownloadUrl(DOWNLOAD_URL);
    sample.setImageFilename(Deviation.extractFilename(DOWNLOAD_URL));
    sample.setCollection(new Collection(1L, "MyCollect"));
    setLayout(new BorderLayout());
    panes = new JTabbedPane(JTabbedPane.TOP);

    JPanel genPanel = new JPanel();
    BoxLayout genLayout = new BoxLayout(genPanel, BoxLayout.Y_AXIS);
    genPanel.setLayout(genLayout);
    panes.add("General", genPanel);

    JLabel userLabel = new JLabel("Username");

    userLabel.setToolTipText("The username the account you want to download the favorites from.");

    userField = new JTextField(config.getProperty(Constants.USERNAME));

    userLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    userLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    userField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    userField.setMaximumSize(new Dimension(Integer.MAX_VALUE, userField.getFont().getSize() * 2));

    genPanel.add(userLabel);
    genPanel.add(userField);

    JPanel radioPanel = new JPanel();
    BoxLayout radioLayout = new BoxLayout(radioPanel, BoxLayout.X_AXIS);
    radioPanel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    radioPanel.setBorder(new EmptyBorder(0, 5, 0, 5));

    radioPanel.setLayout(radioLayout);

    JLabel searchLabel = new JLabel("Search for");
    searchLabel
            .setToolTipText("Select what you want to download from that user: it favorites or it galleries.");
    searchLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    searchLabel.setBorder(new EmptyBorder(0, 5, 0, 5));

    selectedSearch = SEARCH.lookup(config.getProperty(Constants.SEARCH, SEARCH.getDefault().getId()));
    buttonGroup = new ButtonGroup();

    for (final SEARCH search : SEARCH.values()) {
        JRadioButton radio = new JRadioButton(search.getLabel());
        radio.setAlignmentX(JLabel.LEFT_ALIGNMENT);
        radio.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                selectedSearch = search;
            }
        });

        buttonGroup.add(radio);
        radioPanel.add(radio);
        if (search.equals(selectedSearch)) {
            radio.setSelected(true);
        }
    }

    genPanel.add(radioPanel);

    final JTextField sampleField = new JTextField("");
    sampleField.setEditable(false);

    JLabel locationLabel = new JLabel("Download location");
    locationLabel.setToolTipText("The folder pattern where you want the file to be downloaded in.");

    JLabel legendsLabel = new JLabel(
            "<html><body>Field names: %user%, %artist%, %title%, %id%, %filename%, %collection%, %ext%<br></br>Example:</body></html>");
    legendsLabel.setToolTipText("An example of where a file will be downloaded to.");

    locationString = new StringBuilder();
    locationField = new JTextField(config.getProperty(Constants.LOCATION));
    locationField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub

        }

        public void keyReleased(KeyEvent e) {
            File dest = LocationHelper.getFile(locationField.getText(), userField.getText(), sample,
                    sample.getImageFilename());
            locationString.setLength(0);
            locationString.append(dest.getAbsolutePath());
            sampleField.setText(locationString.toString());
            if (useSameForMatureBox.isSelected()) {
                locationMatureString.setLength(0);
                locationMatureString.append(sampleField.getText());
                locationMatureField.setText(locationField.getText());
            }
        }

        public void keyTyped(KeyEvent e) {
        }

    });
    locationField.addMouseListener(new MouseListener() {
        public void mouseReleased(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
            sampleField.setText(locationString.toString());
        }

        public void mouseEntered(MouseEvent e) {
            sampleField.setText(locationString.toString());
        }

        public void mouseClicked(MouseEvent e) {
        }
    });
    JLabel locationMatureLabel = new JLabel("Mature download location");
    locationMatureLabel.setToolTipText(
            "The folder pattern where you want the file marked as 'Mature' to be downloaded in.");

    locationMatureString = new StringBuilder();
    locationMatureField = new JTextField(config.getProperty(Constants.MATURE));
    locationMatureField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub

        }

        public void keyReleased(KeyEvent e) {
            File dest = LocationHelper.getFile(locationMatureField.getText(), userField.getText(), sample,
                    sample.getImageFilename());
            locationMatureString.setLength(0);
            locationMatureString.append(dest.getAbsolutePath());
            sampleField.setText(locationMatureString.toString());
        }

        public void keyTyped(KeyEvent e) {
        }

    });

    locationMatureField.addMouseListener(new MouseListener() {
        public void mouseReleased(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
            sampleField.setText(locationString.toString());
        }

        public void mouseEntered(MouseEvent e) {
            sampleField.setText(locationMatureString.toString());
        }

        public void mouseClicked(MouseEvent e) {
        }
    });

    useSameForMatureBox = new JCheckBox("Use same location for mature deviation?");
    useSameForMatureBox.setSelected(locationLabel.getText().equals(locationMatureField.getText()));
    useSameForMatureBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (useSameForMatureBox.isSelected()) {
                locationMatureField.setEditable(false);
                locationMatureField.setText(locationField.getText());
                locationMatureString.setLength(0);
                locationMatureString.append(locationString);
            } else {
                locationMatureField.setEditable(true);
            }

        }
    });

    File dest = LocationHelper.getFile(locationField.getText(), userField.getText(), sample,
            sample.getImageFilename());
    sampleField.setText(dest.getAbsolutePath());
    locationString.append(sampleField.getText());

    dest = LocationHelper.getFile(locationMatureField.getText(), userField.getText(), sample,
            sample.getImageFilename());
    locationMatureString.append(dest.getAbsolutePath());

    locationLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    locationLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    locationField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    locationField.setMaximumSize(new Dimension(Integer.MAX_VALUE, locationField.getFont().getSize() * 2));
    locationMatureLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    locationMatureLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    locationMatureField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    locationMatureField
            .setMaximumSize(new Dimension(Integer.MAX_VALUE, locationMatureField.getFont().getSize() * 2));
    useSameForMatureBox.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    legendsLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    legendsLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    legendsLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, legendsLabel.getFont().getSize() * 2));
    sampleField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    sampleField.setMaximumSize(new Dimension(Integer.MAX_VALUE, sampleField.getFont().getSize() * 2));

    genPanel.add(locationLabel);
    genPanel.add(locationField);

    genPanel.add(locationMatureLabel);
    genPanel.add(locationMatureField);
    genPanel.add(useSameForMatureBox);

    genPanel.add(legendsLabel);
    genPanel.add(sampleField);
    genPanel.add(Box.createVerticalBox());

    final KeyListener prxChangeListener = new KeyListener() {

        public void keyTyped(KeyEvent e) {
            proxyChangeState = true;
        }

        public void keyPressed(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
        }
    };

    JPanel prxPanel = new JPanel();
    BoxLayout prxLayout = new BoxLayout(prxPanel, BoxLayout.Y_AXIS);
    prxPanel.setLayout(prxLayout);
    panes.add("Proxy", prxPanel);

    JLabel prxHostLabel = new JLabel("Proxy Host");
    prxHostLabel.setToolTipText("The hostname of the proxy server");
    prxHostField = new JTextField(config.getProperty(Constants.PROXY_HOST));
    prxHostLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxHostLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    prxHostField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxHostField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxHostField.getFont().getSize() * 2));

    JLabel prxPortLabel = new JLabel("Proxy Port");
    prxPortLabel.setToolTipText("The port of the proxy server (Default 80).");

    prxPortSpinner = new JSpinner();
    prxPortSpinner.setModel(new SpinnerNumberModel(
            Integer.parseInt(config.getProperty(Constants.PROXY_PORT, "80")), 1, 65535, 1));

    prxPortLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxPortLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    prxPortSpinner.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxPortSpinner.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxPortSpinner.getFont().getSize() * 2));

    JLabel prxUserLabel = new JLabel("Proxy username");
    prxUserLabel.setToolTipText("The username used for authentication, if applicable.");
    prxUserField = new JTextField(config.getProperty(Constants.PROXY_USERNAME));
    prxUserLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxUserLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    prxUserField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxUserField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxUserField.getFont().getSize() * 2));

    JLabel prxPassLabel = new JLabel("Proxy username");
    prxPassLabel.setToolTipText("The username used for authentication, if applicable.");
    prxPassField = new JPasswordField(config.getProperty(Constants.PROXY_PASSWORD));
    prxPassLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxPassLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    prxPassField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    prxPassField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prxPassField.getFont().getSize() * 2));

    prxUseBox = new JCheckBox("Use a proxy?");
    prxUseBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            prxChangeListener.keyTyped(null);

            if (prxUseBox.isSelected()) {
                prxHostField.setEditable(true);
                prxPortSpinner.setEnabled(true);
                prxUserField.setEditable(true);
                prxPassField.setEditable(true);

            } else {
                prxHostField.setEditable(false);
                prxPortSpinner.setEnabled(false);
                prxUserField.setEditable(false);
                prxPassField.setEditable(false);
            }
        }
    });

    prxUseBox.setSelected(!Boolean.parseBoolean(config.getProperty(Constants.PROXY_USE)));
    prxUseBox.doClick();
    proxyChangeState = false;

    prxHostField.addKeyListener(prxChangeListener);
    prxUserField.addKeyListener(prxChangeListener);
    prxPassField.addKeyListener(prxChangeListener);
    prxPortSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            proxyChangeState = true;
        }
    });
    prxPanel.add(prxUseBox);

    prxPanel.add(prxHostLabel);
    prxPanel.add(prxHostField);

    prxPanel.add(prxPortLabel);
    prxPanel.add(prxPortSpinner);

    prxPanel.add(prxUserLabel);
    prxPanel.add(prxUserField);

    prxPanel.add(prxPassLabel);
    prxPanel.add(prxPassField);
    prxPanel.add(Box.createVerticalBox());

    final JPanel advPanel = new JPanel();
    BoxLayout advLayout = new BoxLayout(advPanel, BoxLayout.Y_AXIS);
    advPanel.setLayout(advLayout);
    panes.add("Advanced", advPanel);
    panes.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            JTabbedPane pane = (JTabbedPane) e.getSource();

            if (proxyChangeState && pane.getSelectedComponent() == advPanel) {
                Properties properties = new Properties();
                properties.setProperty(Constants.PROXY_USERNAME, prxUserField.getText().trim());
                properties.setProperty(Constants.PROXY_PASSWORD, new String(prxPassField.getPassword()).trim());
                properties.setProperty(Constants.PROXY_HOST, prxHostField.getText().trim());
                properties.setProperty(Constants.PROXY_PORT, prxPortSpinner.getValue().toString());
                properties.setProperty(Constants.PROXY_USE, Boolean.toString(prxUseBox.isSelected()));
                ProxyCfg prx = ProxyCfg.parseConfig(properties);
                setProxy(prx);
                revalidateSearcher(null);
            }
        }
    });
    JLabel domainLabel = new JLabel("Deviant Art domain name");
    domainLabel.setToolTipText("The deviantART main domain, should it ever change.");

    domainField = new JTextField(config.getProperty(Constants.DOMAIN));
    domainLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    domainLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    domainField.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    domainField.setMaximumSize(new Dimension(Integer.MAX_VALUE, domainField.getFont().getSize() * 2));

    advPanel.add(domainLabel);
    advPanel.add(domainField);

    JLabel throttleLabel = new JLabel("Throttle search delay");
    throttleLabel.setToolTipText(
            "Slow down search query by inserting a pause between them. This help prevent abuse when doing a massive download.");

    throttleSpinner = new JSpinner();
    throttleSpinner.setModel(
            new SpinnerNumberModel(Integer.parseInt(config.getProperty(Constants.THROTTLE, "0")), 5, 60, 1));

    throttleLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    throttleLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    throttleSpinner.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    throttleSpinner.setMaximumSize(new Dimension(Integer.MAX_VALUE, throttleSpinner.getFont().getSize() * 2));

    advPanel.add(throttleLabel);
    advPanel.add(throttleSpinner);

    JLabel searcherLabel = new JLabel("Searcher");
    searcherLabel.setToolTipText("Select a searcher that will look for your favorites.");

    searcherBox = new JComboBox();
    searcherBox.setRenderer(new TogglingRenderer());

    final AtomicInteger index = new AtomicInteger(0);
    searcherBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox combo = (JComboBox) e.getSource();
            Object selectedItem = combo.getSelectedItem();
            if (selectedItem instanceof SearchItem) {
                SearchItem item = (SearchItem) selectedItem;
                if (item.isValid) {
                    index.set(combo.getSelectedIndex());
                } else {
                    combo.setSelectedIndex(index.get());
                }
            }
        }
    });

    try {
        for (Class<Search> clazz : SearcherClassCache.getInstance().getClasses()) {

            Search searcher = clazz.newInstance();
            String name = searcher.getName();

            SearchItem item = new SearchItem(name, clazz.getName(), true);
            searcherBox.addItem(item);
        }
        String selectedClazz = config.getProperty(Constants.SEARCHER,
                com.dragoniade.deviantart.deviation.SearchRss.class.getName());
        revalidateSearcher(selectedClazz);
    } catch (Exception e1) {
        throw new RuntimeException(e1);
    }

    searcherLabel.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    searcherLabel.setBorder(new EmptyBorder(0, 5, 0, 5));
    searcherBox.setAlignmentX(JLabel.LEFT_ALIGNMENT);
    searcherBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, searcherBox.getFont().getSize() * 2));

    advPanel.add(searcherLabel);
    advPanel.add(searcherBox);

    advPanel.add(Box.createVerticalBox());

    add(panes, BorderLayout.CENTER);

    JButton saveBut = new JButton("Save");

    userField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JTextField field = (JTextField) input;
            if (field.getText().trim().length() == 0) {
                JOptionPane.showMessageDialog(input, "The user musn't be empty.", "Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }
            return true;
        }
    });

    locationField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JTextField field = (JTextField) input;
            String content = field.getText().trim();
            if (content.length() == 0) {
                JOptionPane.showMessageDialog(input, "The location musn't be empty.", "Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }

            if (!content.contains("%filename%") && !content.contains("%id%")) {
                JOptionPane.showMessageDialog(input,
                        "The location must contains at least a %filename% or an %id% field.", "Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }
            return true;
        }
    });

    locationMatureField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JTextField field = (JTextField) input;
            String content = field.getText().trim();
            if (content.length() == 0) {
                JOptionPane.showMessageDialog(input, "The Mature location musn't be empty.", "Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }

            if (!content.contains("%filename%") && !content.contains("%id%")) {
                JOptionPane.showMessageDialog(input,
                        "The Mature location must contains at least a %username% or an %id% field.", "Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }
            return true;
        }
    });

    domainField.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JTextField field = (JTextField) input;
            String domain = field.getText().trim();
            if (domain.length() == 0) {
                JOptionPane.showMessageDialog(input, "You must specify the deviantART main domain.", "Warning",
                        JOptionPane.WARNING_MESSAGE);
                return false;
            }

            if (domain.toLowerCase().startsWith("http://")) {
                JOptionPane.showMessageDialog(input,
                        "You must specify the deviantART main domain, not the full URL (aka www.deviantart.com).",
                        "Warning", JOptionPane.WARNING_MESSAGE);
                return false;
            }

            return true;
        }
    });
    locationField.setVerifyInputWhenFocusTarget(true);

    final JDialog parent = this;
    saveBut.addActionListener(new ActionListener() {

        String errorMsg = "The location is invalid or cannot be written to.";

        public void actionPerformed(ActionEvent e) {

            String username = userField.getText().trim();
            String location = locationField.getText().trim();
            String locationMature = locationMatureField.getText().trim();
            String domain = domainField.getText().trim();
            String throttle = throttleSpinner.getValue().toString();
            String searcher = searcherBox.getSelectedItem().toString();

            String prxUse = Boolean.toString(prxUseBox.isSelected());
            String prxHost = prxHostField.getText().trim();
            String prxPort = prxPortSpinner.getValue().toString();
            String prxUsername = prxUserField.getText().trim();
            String prxPassword = new String(prxPassField.getPassword()).trim();

            if (!testPath(location, username)) {
                JOptionPane.showMessageDialog(parent, errorMsg, "Error", JOptionPane.ERROR_MESSAGE);
            }
            if (!testPath(locationMature, username)) {
                JOptionPane.showMessageDialog(parent, errorMsg, "Error", JOptionPane.ERROR_MESSAGE);
            }

            Properties p = new Properties();
            p.setProperty(Constants.USERNAME, username);
            p.setProperty(Constants.LOCATION, location);
            p.setProperty(Constants.MATURE, locationMature);
            p.setProperty(Constants.DOMAIN, domain);
            p.setProperty(Constants.THROTTLE, throttle);
            p.setProperty(Constants.SEARCHER, searcher);
            p.setProperty(Constants.SEARCH, selectedSearch.getId());

            p.setProperty(Constants.PROXY_USE, prxUse);
            p.setProperty(Constants.PROXY_HOST, prxHost);
            p.setProperty(Constants.PROXY_PORT, prxPort);
            p.setProperty(Constants.PROXY_USERNAME, prxUsername);
            p.setProperty(Constants.PROXY_PASSWORD, prxPassword);

            owner.savePreferences(p);
            parent.dispose();
        }
    });

    JButton cancelBut = new JButton("Cancel");
    cancelBut.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            parent.dispose();
        }
    });

    JPanel buttonPanel = new JPanel();
    BoxLayout butLayout = new BoxLayout(buttonPanel, BoxLayout.X_AXIS);
    buttonPanel.setLayout(butLayout);

    buttonPanel.add(saveBut);
    buttonPanel.add(cancelBut);
    add(buttonPanel, BorderLayout.SOUTH);

    pack();
    setResizable(false);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2);
    setVisible(true);
}

From source file:davmail.ui.SettingsFrame.java

protected void addPortSettingComponent(JPanel panel, String label, JComponent component,
        JComponent checkboxComponent, JComponent checkboxSSLComponent, String toolTipText) {
    JLabel fieldLabel = new JLabel(label);
    fieldLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    fieldLabel.setVerticalAlignment(SwingConstants.CENTER);
    panel.add(fieldLabel);/*from w w  w  .j  ava2s. c o m*/
    component.setMaximumSize(component.getPreferredSize());
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));
    innerPanel.add(checkboxComponent);
    innerPanel.add(component);
    innerPanel.add(checkboxSSLComponent);
    panel.add(innerPanel);
    if (toolTipText != null) {
        fieldLabel.setToolTipText(toolTipText);
        component.setToolTipText(toolTipText);
    }
}

From source file:edu.harvard.i2b2.query.ui.TopPanel.java

public void addPanel() {
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override/*  ww  w.j av  a 2  s. c o m*/
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    // jPanel1.add(label);
    // label.setBounds(rightmostPosition, 90, 30, 18);

    ConceptTreePanel panel = new ConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1), this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:edu.harvard.i2b2.query.ui.TopPanel.java

private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (dataModel.hasEmptyPanels()) {
        JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one.");
        return;/*www  .ja  v  a2  s  .c  o m*/
    }
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    ConceptTreePanel panel = new ConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1), this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    /*
     * System.out.println(jScrollPane4.getViewport().getExtentSize().width+":"
     * + jScrollPane4.getViewport().getExtentSize().height);
     * System.out.println
     * (jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":"
     * +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height);
     * System
     * .out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount
     * ());
     * System.out.println(jScrollPane4.getHorizontalScrollBar().getValue());
     */
    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    // this.jScrollPane4.removeAll();
    // this.jScrollPane4.setViewportView(jPanel1);
    // revalidate();
    // jScrollPane3.setBounds(420, 0, 170, 300);
    // jScrollPane4.setBounds(20, 35, 335, 220);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:lcmc.gui.resources.EditableInfo.java

/** Adds parameters to the panel. */
private void addParams(final JPanel optionsPanel, final String prefix, final String[] params,
        final MyButton thisApplyButton, final int leftWidth, final int rightWidth,
        final Map<String, Widget> sameAsFields) {
    if (params == null) {
        return;//from  w ww.  ja va 2s  . c o m
    }
    final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>();
    final List<PanelPart> panelPartsList = new ArrayList<PanelPart>();
    final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>();

    for (final String param : params) {
        final Widget paramWi = createWidget(param, prefix, rightWidth);
        /* sub panel */
        final String section = getSection(param);
        JPanel panel;
        final ConfigData.AccessType accessType = getAccessType(param);
        final String accessTypeString = accessType.toString();
        final Boolean advanced = isAdvanced(param);
        final String advancedString = advanced.toString();
        if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) {
            panel = panelPartsMap.get(section, accessTypeString, advancedString);
            panelPartRowsMap.put(section, accessTypeString, advancedString,
                    panelPartRowsMap.get(section, accessTypeString, advancedString) + 1);
        } else {
            panel = new JPanel(new SpringLayout());
            panel.setBackground(Browser.PANEL_BACKGROUND);
            if (advanced) {
                advancedPanelList.add(panel);
                final JPanel p = panel;
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        p.setVisible(Tools.getConfigData().isAdvancedMode());
                    }
                });
            }
            panelPartsMap.put(section, accessTypeString, advancedString, panel);
            panelPartsList.add(new PanelPart(section, accessType, advanced));
            panelPartRowsMap.put(section, accessTypeString, advancedString, 1);
        }

        /* label */
        final JLabel label = new JLabel(getParamShortDesc(param));
        final String longDesc = getParamLongDesc(param);
        paramWi.setLabel(label, longDesc);

        /* tool tip */
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                paramWi.setToolTipText(getToolTipText(param));
                label.setToolTipText(longDesc);
            }
        });
        int height = 0;
        if (paramWi.getType() == Widget.Type.LABELFIELD) {
            height = Tools.getDefaultSize("Browser.LabelFieldHeight");
        }
        addField(panel, label, paramWi, leftWidth, rightWidth, height);
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if ("wizard".equals(prefix)) {
            rpwi = getWidget(param, null);
            if (rpwi == null) {
                Tools.appError("unkown param: " + param + ". Man pages not installed?");
                continue;
            }
            int height = 0;
            if (rpwi.getType() == Widget.Type.LABELFIELD) {
                height = Tools.getDefaultSize("Browser.LabelFieldHeight");
            }
            final Widget rpwi0 = rpwi;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (paramWi.getValue() == null || paramWi.getValue() == Widget.NOTHING_SELECTED) {
                        rpwi0.setValueAndWait(null);
                    } else {
                        final Object value = paramWi.getStringValue();
                        rpwi0.setValueAndWait(value);
                    }
                }
            });
        }
    }
    for (final String param : params) {
        final Widget paramWi = getWidget(param, prefix);
        Widget rpwi = null;
        if ("wizard".equals(prefix)) {
            rpwi = getWidget(param, null);
        }
        final Widget realParamWi = rpwi;
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                paramWi.addListeners(new WidgetListener() {
                    @Override
                    public void check(final Object value) {
                        checkParameterFields(paramWi, realParamWi, param, params, thisApplyButton);
                    }
                });

            }
        });
    }

    /* add sub panels to the option panel */
    final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>();
    final Set<JPanel> notAdvancedSections = new HashSet<JPanel>();
    final Set<JPanel> advancedSections = new HashSet<JPanel>();
    for (final PanelPart panelPart : panelPartsList) {
        final String section = panelPart.getSection();
        final ConfigData.AccessType accessType = panelPart.getAccessType();
        final String accessTypeString = accessType.toString();
        final Boolean advanced = panelPart.isAdvanced();
        final String advancedString = advanced.toString();

        final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString);
        final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString);
        final int columns = 2;
        SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY
                1, 1); // xPad, yPad
        JPanel sectionPanel;
        if (sectionMap.containsKey(section)) {
            sectionPanel = sectionMap.get(section);
        } else {
            sectionPanel = getParamPanel(section);
            sectionMap.put(section, sectionPanel);
            optionsPanel.add(sectionPanel);
            if (sameAsFields != null) {
                final Widget sameAsCombo = sameAsFields.get(section);
                if (sameAsCombo != null) {
                    final JPanel saPanel = new JPanel(new SpringLayout());
                    saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
                    final JLabel label = new JLabel("Same As");
                    sameAsCombo.setLabel(label, "");
                    addField(saPanel, label, sameAsCombo, leftWidth, rightWidth, 0);
                    SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY
                            1, 1); // xPad, yPad
                    sectionPanel.add(saPanel);
                }
            }
        }
        sectionPanel.add(panel);
        if (advanced) {
            advancedSections.add(sectionPanel);
        } else {
            notAdvancedSections.add(sectionPanel);
        }
    }
    boolean advanced = false;
    for (final JPanel sectionPanel : sectionMap.values()) {
        if (advancedSections.contains(sectionPanel)) {
            advanced = true;
        }
        if (!notAdvancedSections.contains(sectionPanel)) {
            advancedOnlySectionList.add(sectionPanel);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    sectionPanel.setVisible(Tools.getConfigData().isAdvancedMode());
                }
            });
        }
    }
    final boolean a = advanced;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            moreOptionsPanel.setVisible(a && !Tools.getConfigData().isAdvancedMode());
        }
    });
}

From source file:edu.harvard.i2b2.query.ui.MainPanel.java

public void addPanel() {
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override/* www  .ja  va2 s. c  om*/
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    // jPanel1.add(label);
    // label.setBounds(rightmostPosition, 90, 30, 18);

    GroupPanel panel = new GroupPanel("Group " + (dataModel.getCurrentPanelCount() + 1), this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:edu.harvard.i2b2.query.ui.MainPanel.java

private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (dataModel.hasEmptyPanels()) {
        JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one.");
        return;/*from   www. j a  v  a  2  s. c  o m*/
    }
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    GroupPanel panel = new GroupPanel("Group " + (dataModel.getCurrentPanelCount() + 1), this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181 + 60, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    /*
     * System.out.println(jScrollPane4.getViewport().getExtentSize().width+":"
     * + jScrollPane4.getViewport().getExtentSize().height);
     * System.out.println
     * (jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":"
     * +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height);
     * System
     * .out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount
     * ());
     * System.out.println(jScrollPane4.getHorizontalScrollBar().getValue());
     */
    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    // this.jScrollPane4.removeAll();
    // this.jScrollPane4.setViewportView(jPanel1);
    // revalidate();
    // jScrollPane3.setBounds(420, 0, 170, 300);   
    // jScrollPane4.setBounds(20, 35, 335, 220);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

protected void chooseServer() {
    final TwoObjectsX<String, String> serverAndClientId = new TwoObjectsX<String, String>(
            iliasProperties.getIliasServerURL(), iliasProperties.getIliasClient());
    final boolean noConfigDoneYet = serverAndClientId.getObjectA() == null
            || serverAndClientId.getObjectA().trim().isEmpty();

    final JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    final JLabel labelServer = new JLabel("Server: " + serverAndClientId.getObjectA());
    final JLabel labelClientId = new JLabel("Client Id: " + serverAndClientId.getObjectB());

    JComboBox<LoginType> comboboxLoginType = null;
    JComboBox<DownloadMethod> comboboxDownloadMethod = null;

    final Runnable findOutClientId = new Runnable() {

        @Override/* www  .  j  av  a2  s .  c o  m*/
        public void run() {
            try {
                String s = IliasUtil.findClientByLoginPageOrWebserviceURL(serverAndClientId.getObjectA());
                serverAndClientId.setObjectB(s);
                labelClientId.setText("Client Id: " + s);
            } catch (Exception e1) {
                showError("Client Id konnte nicht ermittelt werden", e1);
            }
        }
    };

    final Runnable promptInputServer = new Runnable() {

        @Override
        public void run() {

            String s = JOptionPane.showInputDialog(panel,
                    "Geben Sie die Ilias Loginseitenadresse oder Webserviceadresse ein",
                    serverAndClientId.getObjectA());
            if (s != null) {
                try {
                    s = IliasUtil.findSOAPWebserviceByLoginPage(s.trim());

                    if (!s.toLowerCase().startsWith("https://")) {
                        JOptionPane.showMessageDialog(mainFrame,
                                "Achtung! Die von Ihnen angegebene Adresse beginnt nicht mit 'https://'.\nDie Verbindung ist daher nicht ausreichend gesichert. Ein Angreifer knnte Ihre Ilias Daten und Ihr Passwort abgreifen",
                                "Achtung, nicht geschtzt", JOptionPane.WARNING_MESSAGE);
                    }

                    serverAndClientId.setObjectA(s);
                    labelServer.setText("Server: " + serverAndClientId.getObjectA());

                    if (noConfigDoneYet) {
                        findOutClientId.run();
                    }
                } catch (IliasException e1) {
                    showError(
                            "Bitte geben Sie die Adresse der Ilias Loginseite oder die des Webservice an. Die Adresse der Loginseite muss 'login.php' enthalten",
                            e1);
                }
            }
        }
    };

    {
        JPanel panel2 = new JPanel(new BorderLayout());

        panel2.add(labelServer, BorderLayout.NORTH);
        panel2.add(labelClientId, BorderLayout.SOUTH);

        panel.add(panel2, BorderLayout.NORTH);
    }
    {
        JPanel panel2 = new JPanel(new BorderLayout());

        JPanel panel3 = new JPanel(new GridLayout());
        {
            JButton b = new JButton("Server ndern");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    promptInputServer.run();
                }
            });
            panel3.add(b);

            b = new JButton("Client Id ndern");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String s = JOptionPane.showInputDialog(panel, "Client Id eingeben",
                            serverAndClientId.getObjectB());
                    if (s != null) {
                        serverAndClientId.setObjectB(s);
                        labelClientId.setText("Client Id: " + serverAndClientId.getObjectB());
                    }

                }
            });
            panel3.add(b);

            b = new JButton("Client Id automatisch ermitteln");
            b.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    findOutClientId.run();
                }
            });
            panel3.add(b);
        }
        panel2.add(panel3, BorderLayout.NORTH);

        panel3 = new JPanel(new GridLayout(0, 2, 5, 2));
        {
            panel3.add(new JLabel("Loginmethode: "));
            comboboxLoginType = new JComboBox<LoginType>();
            FunctionsX.setComboBoxLayoutString(comboboxLoginType, new ObjectDoInterface<LoginType, String>() {

                @Override
                public String doSomething(LoginType loginType) {
                    switch (loginType) {
                    case DEFAULT:
                        return "Standard";
                    case LDAP:
                        return "LDAP";
                    case CAS:
                        return "CAS";
                    default:
                        return "<Fehler>";
                    }
                }

            });
            val model = ((DefaultComboBoxModel<LoginType>) comboboxLoginType.getModel());
            for (LoginType loginType : LoginType.values()) {
                model.addElement(loginType);
            }
            model.setSelectedItem(iliasProperties.getLoginType());
            panel3.add(comboboxLoginType);

            JLabel label = new JLabel("Dateien herunterladen ber:");
            label.setToolTipText("Die restliche Kommunikation luft immer ber den SOAP Webservice");
            panel3.add(label);
            comboboxDownloadMethod = new JComboBox<DownloadMethod>();
            FunctionsX.setComboBoxLayoutString(comboboxDownloadMethod,
                    new ObjectDoInterface<DownloadMethod, String>() {

                        @Override
                        public String doSomething(DownloadMethod downloadMethod) {
                            switch (downloadMethod) {
                            case WEBSERVICE:
                                return "SOAP Webservice (Standard)";
                            case WEBDAV:
                                return "WEBDAV";
                            default:
                                return "<Fehler>";
                            }
                        }

                    });
            val model2 = ((DefaultComboBoxModel<DownloadMethod>) comboboxDownloadMethod.getModel());
            for (DownloadMethod downloadMethod : DownloadMethod.values()) {
                model2.addElement(downloadMethod);
            }
            model2.setSelectedItem(iliasProperties.getDownloadMethod());
            panel3.add(comboboxDownloadMethod);
        }
        panel2.add(panel3, BorderLayout.WEST);

        panel.add(panel2, BorderLayout.SOUTH);
    }

    if (noConfigDoneYet) {
        promptInputServer.run();
    }

    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Server konfigurieren",
            JOptionPane.OK_CANCEL_OPTION)) {
        if (syncService != null) {
            syncService.logoutIfLoggedIn();
        }
        iliasProperties.setIliasServerURL(serverAndClientId.getObjectA());
        iliasProperties.setIliasClient(serverAndClientId.getObjectB());
        iliasProperties.setLoginType((LoginType) comboboxLoginType.getSelectedItem());
        iliasProperties.setDownloadMethod((DownloadMethod) comboboxDownloadMethod.getSelectedItem());
        saveProperties(iliasProperties);
        updateTitleCaption();
    }

}

From source file:me.paddingdun.gen.code.gui.view.dbtable.TableView.java

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

    setIconifiable(true);
    setMaximizable(true);
    setResizable(true);
    setTitle("?/");
    fileChooser = new javax.swing.JFileChooser();
    p = new javax.swing.JSplitPane();
    p0t = new javax.swing.JPanel();
    pt = new javax.swing.JSplitPane();
    ptt = new javax.swing.JScrollPane();
    ptb = new javax.swing.JScrollPane();
    ptba = new javax.swing.JPanel();
    pb = new javax.swing.JSplitPane();
    p0b = new javax.swing.JPanel();
    pbt = new javax.swing.JScrollPane();
    pbb = new javax.swing.JScrollPane();
    pbba = new javax.swing.JPanel();

    p.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    pt.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    pb.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

    p.setTopComponent(p0t);
    p.setBottomComponent(p0b);

    p0t.setLayout(new BorderLayout());
    p0t.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "?",
            TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, Color.BLACK));
    p0t.add(pt, BorderLayout.CENTER);
    p0t.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            p.setDividerLocation(p.getHeight() - 40);
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    pt.setDividerLocation(0.38);
                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            pb.setDividerLocation(1.0d);
                        }
                    });
                }
            });
        }
    });

    p0b.setLayout(new BorderLayout());
    p0b.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "",
            TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, Color.BLACK));
    p0b.add(pb, BorderLayout.CENTER);
    p0b.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            p.setDividerLocation(30);
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    pt.setDividerLocation(1.0d);

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            pb.setDividerLocation(0.38);
                        }
                    });
                }
            });
        }
    });

    pt.setTopComponent(ptt);
    pt.setBottomComponent(ptb);

    ptb.setViewportView(ptba);
    ptb.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    pb.setTopComponent(pbt);
    pb.setBottomComponent(pbb);

    pbb.setViewportView(pbba);
    pbb.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    tableColumnTable = new javax.swing.JTable() {
        public void editingStopped(ChangeEvent e) {
            TableCellEditor editor = this.getCellEditor();
            if (editor != null) {
                Object value = editor.getCellEditorValue();
                setTableColumnValue(value);
            }
            // System.out.println(MessageFormat.format("c:{0}-r:{1}",
            // this.getSelectedColumn(), this.getSelectedRow()));
            super.editingStopped(e);
        }
    };
    // ColumnModel?false;
    // table.setAutoCreateColumnsFromModel(false);
    ptt.setViewportView(tableColumnTable);

    /**
     * add by 2016422 ;
     */
    listColumnTable = new javax.swing.JTable() {
        public void editingStopped(ChangeEvent e) {
            TableCellEditor editor = this.getCellEditor();
            if (editor != null) {
                Object value = editor.getCellEditorValue();
                setListColumnValue(value);
            }
            // System.out.println(MessageFormat.format("c:{0}-r:{1}",
            // this.getSelectedColumn(), this.getSelectedRow()));
            super.editingStopped(e);
        }
    };
    listColumnTable.getTableHeader().addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

        }
    });
    pbt.setViewportView(listColumnTable);

    jLabel1 = new javax.swing.JLabel();
    basePackageName = new javax.swing.JTextField();
    btnGen = new javax.swing.JButton();
    btnListColumnOk = new javax.swing.JButton();
    btnTableColumnOk = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jcombo_sqlMapMarkUse = new javax.swing.JComboBox<Option<Integer>>();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jLabel12 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    jLabel15 = new javax.swing.JLabel();
    jLabel16 = new javax.swing.JLabel();
    columnTitle = new javax.swing.JTextField();
    listTitle = new javax.swing.JTextField();
    jcombo_showGsonAnnotation = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_queryRenderShow = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_listRenderShow = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_editRenderShow = new javax.swing.JComboBox<Option<Boolean>>();
    jcombo_queryRenderWay = new javax.swing.JComboBox<Option<Integer>>();
    jcombo_listRenderWay = new javax.swing.JComboBox<Option<Integer>>();
    jcombo_editRenderWay = new javax.swing.JComboBox<Option<Integer>>();
    saveMethodPrefix = new javax.swing.JTextField();
    updateMethodPrefix = new javax.swing.JTextField();
    getMethodPrefix = new javax.swing.JTextField();
    deleteMethodPrefix = new javax.swing.JTextField();
    queryMethodPrefix = new javax.swing.JTextField();
    queryPagingMethodPrefix = new javax.swing.JTextField();

    queryColumnJson = new javax.swing.JTextArea(1, 10);
    javax.swing.JScrollPane cqpc = new javax.swing.JScrollPane(queryColumnJson);
    // customQueryProperty.setAutoscrolls(true);

    editValueGenWayJson = new javax.swing.JTextArea(1, 10);
    javax.swing.JScrollPane cevfw = new javax.swing.JScrollPane(editValueGenWayJson);

    //      editValidateJson = new javax.swing.JTextArea(1, 10);
    //      javax.swing.JScrollPane evj = new javax.swing.JScrollPane(editValidateJson);

    editValidateEasyuiString = new javax.swing.JTextArea(1, 10);
    javax.swing.JScrollPane evj = new javax.swing.JScrollPane(editValidateEasyuiString);

    jLabel1.setText("??");

    btnGen.setText("?");
    btnTableColumnOk.setText("Ok");
    btnListColumnOk.setText("Ok");

    jLabel2.setText("SQL??");

    // sqlMapMarkUse.setModel(null);

    jLabel3.setText("??");

    jLabel4.setText("?");

    jLabel5.setText("??");

    jLabel6.setText("?");

    jLabel7.setText("?");

    jLabel8.setText("?");

    jLabel9.setText("?gosn");

    jLabel10.setText("?");
    jLabel11.setText("?");

    jLabel12.setText("?");
    jLabel13.setText("?");

    jLabel14.setText("?");
    jLabel15.setText("?");

    jLabel16.setText("");

    TableLayout tableLayout_ptba = new TableLayout();
    double border = 2; // 0 1 2 3 4 5 6
    tableLayout_ptba.setColumn(new double[] { border, 50, 50, 80, -1, 50, 70, border });
    tableLayout_ptba.setRow(new double[] { border, 30, 30, 30, 130, 130, 130, border });
    ptba.setLayout(tableLayout_ptba);

    queryRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE));
    queryRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_queryRenderShow.setModel(queryRenderShow);

    listRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE));
    listRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_listRenderShow.setModel(listRenderShow);

    editRenderShow.addElement(CollectionHelper.option("", Boolean.TRUE));
    editRenderShow.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_editRenderShow.setModel(editRenderShow);

    CollectionHelper.renderWayOption(queryRenderWay, "query");
    jcombo_queryRenderWay.setModel(queryRenderWay);

    CollectionHelper.renderWayOption(listRenderWay, "list");
    jcombo_listRenderWay.setModel(listRenderWay);

    CollectionHelper.renderWayOption(editRenderWay, "edit");
    jcombo_editRenderWay.setModel(editRenderWay);
    jcombo_editRenderWay.addItemListener(new ItemListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) { //??   
                Option<Integer> o = (Option<Integer>) e.getItem();
                String s = EditValueGenWayHelper.toEditValueShowWayJson(o.getValue());
                editRenderWayJson.setText(s);
            }
        }
    });

    int row = 1;
    ptba.add(new JLabel(""), MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(columnTitle, MessageFormat.format("3,{0},4,{0}", row));
    ptba.add(btnTableColumnOk, MessageFormat.format("6,{0}", row));
    row++;
    ptba.add(jLabel14, MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(jcombo_editRenderShow, MessageFormat.format("3,{0},4,{0}", row));
    ptba.add(btnListColumnOk, MessageFormat.format("6,{0}", row));
    row++;
    ptba.add(jLabel15, MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(jcombo_editRenderWay, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    ptba.add(new JLabel("?"), MessageFormat.format("1,{0},2,{0}", row));
    editRenderWayJson = new javax.swing.JTextArea(1, 10);
    editRenderWayJson.setLineWrap(true);
    editRenderWayJson.setWrapStyleWord(true);
    javax.swing.JScrollPane erwjj = new javax.swing.JScrollPane(editRenderWayJson);
    ptba.add(erwjj, MessageFormat.format("3,{0},6,{0}", row));
    row++;
    JLabel j1 = new JLabel("?");
    j1.setToolTipText("<html>\n" + "<table border=\"1\">\n" + "<tr>\n" + "   <th>?</th>\n"
            + "   <th>??</th>\n" + "</tr>\n" + "<tr>\n" + "   <td>new</td>\n"
            + "   <td>?,\"input\":, \"time\":??, \"nothing\":??</td>\n"
            + "</tr>\n" + "</table>\n" + "</html>");

    ptba.add(j1, MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(cevfw, MessageFormat.format("3,{0},6,{0}", row));
    row++;
    ptba.add(new JLabel("JS?"), MessageFormat.format("1,{0},2,{0}", row));
    ptba.add(evj, MessageFormat.format("3,{0},6,{0}", row));

    // showGsonAnnotation.setModel(null);

    btnGen.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnGenActionPerformed(evt);
        }
    });

    btnListColumnOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnListColumnOkActionPerformed(evt);
        }
    });

    btnTableColumnOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnTableColumnOkActionPerformed(evt);
        }
    });

    TableLayout tableLayout_pbba = new TableLayout();
    // double border = 2; //0 1 2 3 4 5 6
    tableLayout_pbba.setColumn(new double[] { border, 50, 50, 80, -1, 50, 70, border });
    tableLayout_pbba.setRow(new double[] { border, 30, 30, 30, 30, 30, 130, border });
    pbba.setLayout(tableLayout_pbba);

    row = 1;
    pbba.add(jLabel16, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(listTitle, MessageFormat.format("3,{0},4,{0}", row));
    pbba.add(btnListColumnOk, MessageFormat.format("6,{0}", row));

    row++;
    pbba.add(jLabel12, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(jcombo_listRenderShow, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    pbba.add(jLabel13, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(jcombo_listRenderWay, MessageFormat.format("3,{0},4,{0}", row));

    row++;
    pbba.add(jLabel10, MessageFormat.format("1,{0},2,{0}", row, row));
    pbba.add(jcombo_queryRenderShow, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    pbba.add(jLabel11, MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(jcombo_queryRenderWay, MessageFormat.format("3,{0},4,{0}", row));
    row++;
    pbba.add(new JLabel(""), MessageFormat.format("1,{0},2,{0}", row));
    pbba.add(cqpc, MessageFormat.format("3,{0},6,{0}", row));

    // TableLayout tableLayout_pba = new TableLayout();
    //// double border = 2; //0 1 2 3 4 5 6
    // tableLayout_pba.setColumn(new double[]{border, 50, 50, 80, -1, 50,
    // 70, border});
    // tableLayout_pba.setRow(new double[]{border,30, 30, 30, 30, 30, 30,
    // 30, 30, 30, 30, border});
    // pba.setLayout(tableLayout_pba);
    //
    // pba.add(jLabel1, "1,1,2,1");
    // pba.add(basePackageName, "3,1,5,1");
    // pba.add(btnGen, "6,1");
    //
    // pba.add(jLabel2, "1,2,2,2");
    // pba.add(jcombo_sqlMapMarkUse, "3,2,4,2");
    //
    // pba.add(jLabel9, "1,3,2,3");
    // pba.add(jcombo_showGsonAnnotation, "3,3,4,3");
    //
    // pba.add(jLabel3, "1,4,2,4");
    // pba.add(saveMethodPrefix, "3,4,4,4");
    //
    // pba.add(jLabel4, "1,5,2,5");
    // pba.add(updateMethodPrefix, "3,5,4,5");
    //
    // pba.add(jLabel5, "1,6,2,6");
    // pba.add(getMethodPrefix, "3,6,4,6");
    //
    // pba.add(jLabel6, "1,7,2,7");
    // pba.add(deleteMethodPrefix, "3,7,4,7");
    //
    // pba.add(jLabel7, "1,8,2,8");
    // pba.add(queryMethodPrefix, "3,8,4,8");
    //
    // pba.add(jLabel8, "1,9,2,9");
    // pba.add(queryPagingMethodPrefix, "3,9,4,9");

    sqlMapMarkUse.addElement(CollectionHelper.option("??", 1));
    sqlMapMarkUse.addElement(CollectionHelper.option("??", 2));
    jcombo_sqlMapMarkUse.setModel(sqlMapMarkUse);

    showGsonAnnotation.addElement(CollectionHelper.option("", Boolean.TRUE));
    showGsonAnnotation.addElement(CollectionHelper.option("?", Boolean.FALSE));
    jcombo_showGsonAnnotation.setModel(showGsonAnnotation);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(p, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,
                    470, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
            p, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 446,
            Short.MAX_VALUE));

    this.addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentShown(java.awt.event.ComponentEvent evt) {
            afterShow(evt);
        }
    });

    pack();
}

From source file:org.forester.archaeopteryx.ControlPanel.java

void setupSearchTools() {
    final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND.";
    final JLabel search_label = new JLabel("Search:");
    search_label.setFont(ControlPanel.jcb_bold_font);
    if (!getConfiguration().isUseNativeUI()) {
        search_label.setForeground(ControlPanel.jcb_text_color);
    }/*from   w  w  w  . j  a v a2s. co  m*/
    add(search_label);
    search_label.setToolTipText(tip);
    _search_found_label = new JLabel();
    getSearchFoundCountsLabel().setVisible(false);
    _search_found_label.setFont(ControlPanel.jcb_bold_font);
    if (!getConfiguration().isUseNativeUI()) {
        _search_found_label.setForeground(ControlPanel.jcb_text_color); //Color of Found: X
    }
    _search_tf = new JTextField(3);
    _search_tf.setToolTipText(tip);
    _search_tf.setEditable(true);
    if (!getConfiguration().isUseNativeUI()) {
        _search_tf.setForeground(Color.GREEN);//ControlPanel.jcb_text_color );
        _search_tf.setBackground(ControlPanel.button_background_color);
        _search_tf.setBorder(null);
    }
    _search_reset_button = new JButton();
    getSearchResetButton().setText("Reset");
    getSearchResetButton().setEnabled(false);
    getSearchResetButton().setVisible(false);
    final JPanel s_panel_1 = new JPanel(new BorderLayout());
    final JPanel s_panel_2 = new JPanel(new GridLayout(1, 2, 0, 0));
    s_panel_1.setBackground(getBackground());
    add(s_panel_1);
    s_panel_2.setBackground(getBackground());
    add(s_panel_2);
    final KeyAdapter key_adapter = new KeyAdapter() {

        @Override
        public void keyReleased(final KeyEvent key_event) {
            search();
            displayedPhylogenyMightHaveChanged(true);
        }
    };
    final ActionListener action_listener = new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            searchReset();
            setSearchFoundCountsOnLabel(0);
            getSearchFoundCountsLabel().setVisible(false);
            getSearchTextField().setText("");
            getSearchResetButton().setEnabled(false);
            getSearchResetButton().setVisible(false);
            displayedPhylogenyMightHaveChanged(true);
        }
    };
    _search_reset_button.addActionListener(action_listener);
    _search_tf.addKeyListener(key_adapter);
    addJTextField(_search_tf, s_panel_1);
    s_panel_2.add(_search_found_label);
    addJButton(_search_reset_button, s_panel_2);
}