Example usage for javax.swing JToggleButton setText

List of usage examples for javax.swing JToggleButton setText

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.")
public void setText(String text) 

Source Link

Document

Sets the button's text.

Usage

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

/**
 * Creates a new image toggle button./*from  w w w  . j a  va  2s. co  m*/
 * 
 * @param icon
 *            the normal icon
 * @param rolloverIcon
 *            the rollover icon
 * @param action
 *            the action
 * 
 * @return the newly created image button
 */
public static JToggleButton newImageToggleButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JToggleButton button = new JToggleButton(action);
    button.setToolTipText(button.getText());
    button.setText(null);
    button.setContentAreaFilled(false);
    button.setBorder(new EmptyBorder(0, 0, 0, 0));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setFocusable(false);

    button.setIcon(icon);
    button.setRolloverIcon(rolloverIcon);
    button.setRolloverSelectedIcon(rolloverIcon);
    button.setSelectedIcon(rolloverIcon);

    return button;
}

From source file:org.ut.biolab.medsavant.client.view.component.KeyValuePairPanel.java

public void addMoreRow() {

    final JToggleButton b = ViewUtil.getSoftToggleButton("MORE");
    ViewUtil.makeMini(b);//  w  w w  .j a  v a2  s  .c  o  m
    b.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            toggleMoreVisibility();

            if (b.getText().equals("MORE")) {
                b.setText("LESS");
            } else {
                b.setText("MORE");
            }
        }
    });

    /*
     * final JLabel keyLabel = new JLabel(); ViewUtil.makeMini(keyLabel);
     * keyLabel.setForeground(Color.darkGray);
     * keyLabel.setBorder(ViewUtil.getMediumBorder());
     *
     * keyLabel.setText(" MORE ");
     *
     * keyLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
     * keyLabel.addMouseListener(new MouseAdapter() { @Override public void
     * mouseClicked(MouseEvent me) { toggleMoreVisibility();
     *
     * if (keyLabel.getText().startsWith("")) { keyLabel.setText(" MORE
     * "); } else { keyLabel.setText(" LESS "); }
     *
     * }
     * });
     */

    toolbar.add(ViewUtil.getCenterAlignedComponent(b));
    newRowsGoIntoMoreSection = true;

}

From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.DetailedVariantSubInspector.java

@Override
public JPanel getInfoPanel() {
    if (p == null) {
        p = new KeyValuePairPanel(4);
        p.addKey(KEY_DNAID);/* www.ja v  a2  s  . c om*/
        p.addKey(KEY_ZYGOSITY);
        p.addKey(KEY_QUAL);
        p.addKey(KEY_DBSNP);

        p.addKey(KEY_INFO);

        JButton genomeBrowserButton = ViewUtil
                .getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.BROWSER));
        genomeBrowserButton.setToolTipText("View region in genome browser");
        genomeBrowserButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                LocationController.getInstance().setLocation(selectedVariant.getChrom(),
                        new Range((int) (selectedVariant.getStartPosition() - 20),
                                (int) (selectedVariant.getEndPosition() + 21)));
                AppDirectory.launchApp(AppDirectory.BuiltInApp.GENOME_BROWSER);
            }
        });

        JButton bamButton = ViewUtil
                .getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.BAMFILE));
        bamButton.setToolTipText("<html>Load read alignments for this<br/> sample in genome browser</html>");
        bamButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {

                Set<AppCommHandler> handlers = AppCommRegistry.getInstance()
                        .getHandlersForEvent(BAMFileComm.class);
                if (handlers.isEmpty()) {
                    return;
                }

                String dnaID = selectedVariant.getDnaID();
                String bamPath;
                try {
                    bamPath = MedSavantClient.PatientManager.getReadAlignmentPathForDNAID(
                            LoginController.getSessionID(),
                            ProjectController.getInstance().getCurrentProjectID(), dnaID);
                    if (bamPath != null && !bamPath.equals("")) {
                        AppCommHandler<BAMFileComm> handler = handlers.iterator().next();
                        handler.handleCommEvent(new BAMFileComm(null, new URL(bamPath)));

                        //BrowserPage.getInstance().addTrackFromURLString(bamPath, DataFormat.ALIGNMENT);
                        //DialogUtils.displayMessage("Read alignments have been loaded into Browser.  Click 'Browser' at left to view.");
                    }
                } catch (Exception ex) {
                    ClientMiscUtils.reportError("Unable to load BAM file: %s", ex);
                }
            }
        });

        JButton geneInspectorButton = ViewUtil
                .getTexturedButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.INSPECTOR));
        geneInspectorButton.setToolTipText("Inspect this gene");
        geneInspectorButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                StaticGeneInspector.getInstance().setGene((Gene) (geneBox).getSelectedItem());
                StaticInspectorPanel.getInstance().switchToGeneInspector();
            }
        });

        JLabel l = new JLabel("This will eventually show a chart");
        //p.setDetailComponent(KEY_QUAL, l);

        final JToggleButton button = ViewUtil.getTexturedToggleButton("SHOW");
        ViewUtil.makeSmall(button);
        button.setToolTipText("Toggle Info");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                p.toggleDetailVisibility(KEY_INFO);
                button.setText(button.isSelected() ? "HIDE" : "SHOW");
            }
        });
        p.setValue(KEY_INFO, button);

        int col = 0;

        p.setAdditionalColumn(KEY_DNAID, col, KeyValuePairPanel.getCopyButton(KEY_DNAID, p));
        p.setAdditionalColumn(KEY_DBSNP, col, KeyValuePairPanel.getCopyButton(KEY_DBSNP, p));
        //p.setAdditionalColumn(KEY_QUAL, col, getChartButton(KEY_QUAL));

        col++;
        p.setAdditionalColumn(KEY_DBSNP, col, getNCBIButton(KEY_DBSNP));
        p.setAdditionalColumn(KEY_DNAID, col, bamButton);

    }
    return p;
}

From source file:org.ut.biolab.medsavant.client.view.LoginView.java

/** This method is called from within the constructor to
 * initialize the form.//from w w w.j a  v  a 2s.  co  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    titlePanel = new javax.swing.JPanel();
    userField = new javax.swing.JTextField();
    passwordField = new javax.swing.JPasswordField();
    spiralPanel = new javax.swing.JPanel();
    versionLabel = new javax.swing.JLabel();
    javax.swing.JLabel userLabel = new javax.swing.JLabel();
    javax.swing.JLabel passwordLabel = new javax.swing.JLabel();
    javax.swing.JToggleButton button_settings = new javax.swing.JToggleButton();
    detailsPanel = new javax.swing.JPanel();
    javax.swing.JLabel hostLabel = new javax.swing.JLabel();
    hostField = new javax.swing.JTextField();
    javax.swing.JLabel portLabel = new javax.swing.JLabel();
    portField = new javax.swing.JTextField();
    javax.swing.JButton dbCreateButton = new javax.swing.JButton();
    databaseField = new javax.swing.JTextField();
    javax.swing.JLabel databaseLabel = new javax.swing.JLabel();
    javax.swing.JButton dbRemoveButton = new javax.swing.JButton();
    loginButton = new javax.swing.JButton();
    progressSigningIn = new javax.swing.JProgressBar();

    setLayout(new java.awt.GridBagLayout());

    titlePanel.setBackground(new java.awt.Color(255, 255, 255));
    titlePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(6, 6, 6, 6));
    titlePanel.setMaximumSize(new java.awt.Dimension(400, 32767));
    titlePanel.setMinimumSize(new java.awt.Dimension(400, 800));
    titlePanel.setOpaque(false);

    userField.setColumns(25);
    userField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    userField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            userFieldKeyPressed(evt);
        }
    });

    passwordField.setColumns(25);
    passwordField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    passwordField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            passwordFieldKeyPressed(evt);
        }
    });

    spiralPanel.setPreferredSize(new java.awt.Dimension(150, 150));

    javax.swing.GroupLayout spiralPanelLayout = new javax.swing.GroupLayout(spiralPanel);
    spiralPanel.setLayout(spiralPanelLayout);
    spiralPanelLayout.setHorizontalGroup(spiralPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
    spiralPanelLayout.setVerticalGroup(spiralPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 150, Short.MAX_VALUE));

    versionLabel.setFont(versionLabel.getFont());
    versionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    versionLabel.setText("version information");

    userLabel.setFont(new java.awt.Font("Helvetica", 0, 12)); // NOI18N
    userLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    userLabel.setText("USERNAME");

    passwordLabel.setFont(new java.awt.Font("Helvetica", 0, 12)); // NOI18N
    passwordLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    passwordLabel.setText("PASSWORD");

    button_settings.setText("Connection Settings");
    button_settings.putClientProperty("JButton.buttonType", "textured");
    button_settings.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            button_settingsActionPerformed(evt);
        }
    });

    detailsPanel.setBackground(new java.awt.Color(204, 204, 204));
    detailsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Connection Settings",
            javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
    detailsPanel.setName("Connection Settings"); // NOI18N
    detailsPanel.setOpaque(false);

    hostLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    hostLabel.setText("SERVER ADDRESS");

    hostField.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
    hostField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    hostField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            hostFieldKeyPressed(evt);
        }
    });

    portLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    portLabel.setText("SERVER PORT");

    portField.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
    portField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    portField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            portFieldKeyPressed(evt);
        }
    });

    dbCreateButton.setText("Create Database");
    dbCreateButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            dbCreateButtonActionPerformed(evt);
        }
    });

    databaseField.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
    databaseField.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    databaseField.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            databaseFieldKeyPressed(evt);
        }
    });

    databaseLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    databaseLabel.setText("DATABASE NAME");

    dbRemoveButton.setText("Remove Database");
    dbRemoveButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            dbRemoveButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout detailsPanelLayout = new javax.swing.GroupLayout(detailsPanel);
    detailsPanel.setLayout(detailsPanelLayout);
    detailsPanelLayout.setHorizontalGroup(detailsPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(databaseLabel, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(detailsPanelLayout.createSequentialGroup().addContainerGap().addGroup(detailsPanelLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(hostLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(hostField).addComponent(portField)
                    .addComponent(portLabel, javax.swing.GroupLayout.Alignment.TRAILING,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            detailsPanelLayout.createSequentialGroup().addComponent(dbRemoveButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(dbCreateButton))
                    .addComponent(databaseField, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addContainerGap()));
    detailsPanelLayout.setVerticalGroup(detailsPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(detailsPanelLayout.createSequentialGroup().addComponent(hostLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(portLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(databaseLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(databaseField, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(detailsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(dbCreateButton).addComponent(dbRemoveButton))));

    loginButton.setBackground(new java.awt.Color(0, 0, 0));
    loginButton.setText("Log In");
    loginButton.putClientProperty("JButton.buttonType", "textured");
    loginButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loginButtonActionPerformed(evt);
        }
    });

    progressSigningIn.setIndeterminate(true);

    javax.swing.GroupLayout titlePanelLayout = new javax.swing.GroupLayout(titlePanel);
    titlePanel.setLayout(titlePanelLayout);
    titlePanelLayout.setHorizontalGroup(titlePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(versionLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(spiralPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE)
            .addComponent(detailsPanel, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(titlePanelLayout.createSequentialGroup()
                    .addGroup(titlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(userLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(titlePanelLayout.createSequentialGroup().addContainerGap()
                                    .addGroup(titlePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(button_settings).addComponent(userField,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 201,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(titlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(titlePanelLayout.createSequentialGroup().addGap(6, 6, 6).addComponent(
                                    passwordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 189,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, titlePanelLayout
                                    .createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(titlePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                    titlePanelLayout.createSequentialGroup()
                                                            .addComponent(progressSigningIn,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 26,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(
                                                                    javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                            .addComponent(loginButton))
                                            .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    197, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addContainerGap()))));
    titlePanelLayout.setVerticalGroup(titlePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, titlePanelLayout.createSequentialGroup()
                    .addComponent(spiralPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(versionLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(titlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(userLabel).addComponent(passwordLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(titlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(titlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(loginButton)
                            .addComponent(progressSigningIn, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button_settings))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(detailsPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.gridheight = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(45, 45, 45, 45);
    add(titlePanel, gridBagConstraints);
}