Example usage for javax.swing JToolBar setName

List of usage examples for javax.swing JToolBar setName

Introduction

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

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

Usage

From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java

/**
 * Mostly created by Eclipse WindowBuilder
 *//*from w ww . j a v  a2 s.c om*/
private void initComponents() {
    setTitle("perfLoad - Load Profile Configurator");
    setSize(1032, 984);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    SwingUtils.setUIFontStyle(Font.PLAIN);
    {
        JMenuBar menuBar = new JMenuBar();
        menuBar.setName("menuBar");
        setJMenuBar(menuBar);
        initMenuBar(menuBar);
    }

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new MigLayout("insets 0", "[grow][]", "[25px][400][grow]"));
    {
        JToolBar toolBar = new JToolBar() {
            @Override
            protected JButton createActionComponent(final Action a) {
                JButton button = super.createActionComponent(a);
                button.setFocusable(false);
                button.setHideActionText(false);
                return button;
            }
        };
        toolBar.setName("toolBar");
        contentPane.add(toolBar, "cell 0 0 2 1,growx,aligny top");
        initToolBar(toolBar);
    }
    {
        JScrollPane spTree = new JScrollPane();
        spTree.setBorder(new CompoundBorder(
                new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Load Profile Elements",
                        TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)),
                new EmptyBorder(4, 4, 4, 4)));
        contentPane.add(spTree, "cell 0 1,grow");
        spTree.setName("spTree");
        {
            tree = new JTree();
            tree.addKeyListener(new TreeKeyListener());
            tree.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
            tree.addTreeSelectionListener(new TreeTreeSelectionListener());
            tree.setShowsRootHandles(true);
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setName("tree");
            spTree.setViewportView(tree);
        }
    }
    {
        JPanel pnlMain = new JPanel();
        contentPane.add(pnlMain, "cell 1 1");
        pnlMain.setName("pnlMain");
        pnlMain.setLayout(new MigLayout("insets 0", "[664!]", "[grow][]"));
        {
            JPanel pnlLoadProfileProperties = new JPanel();
            pnlLoadProfileProperties.setBorder(new TitledBorder(null, "Load Profile Properties",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
            pnlLoadProfileProperties.setName("pnlLoadProfileProperties");
            pnlMain.add(pnlLoadProfileProperties, "flowx,cell 0 0,grow");
            pnlLoadProfileProperties
                    .setLayout(new MigLayout("insets 4", "[270,grow]8[]8[200]8[]8[200]", "[][][][grow]"));
            {
                lblName = new JLabel("Name");
                lblName.setDisplayedMnemonic('N');
                lblName.setHorizontalAlignment(SwingConstants.CENTER);
                lblName.setName("lblName");
                pnlLoadProfileProperties.add(lblName, "cell 0 0");
            }
            {
                JSeparator separator = new JSeparator();
                separator.setPreferredSize(new Dimension(0, 200));
                separator.setOrientation(SwingConstants.VERTICAL);
                separator.setName("separator");
                pnlLoadProfileProperties.add(separator, "cell 1 0 1 4, growy");
            }
            {
                JLabel lblClient = new JLabel("Clients");
                lblClient.setName("lblClient");
                pnlLoadProfileProperties.add(lblClient, "cell 2 0");
            }
            {
                JSeparator separator = new JSeparator();
                separator.setPreferredSize(new Dimension(0, 200));
                separator.setOrientation(SwingConstants.VERTICAL);
                separator.setName("separator");
                pnlLoadProfileProperties.add(separator, "cell 3 0 1 4, growy");
            }
            {
                lblTargets = new JLabel("Targets");
                lblTargets.setName("lblTargets");
                pnlLoadProfileProperties.add(lblTargets, "cell 4 0");
            }
            {
                txtName = new JTextField();
                lblName.setLabelFor(txtName);
                txtName.setColumns(10);
                txtName.setName("txtName");
                txtName.getDocument().addDocumentListener(dirtyListener);
                pnlLoadProfileProperties.add(txtName, "cell 0 1,growx");
            }
            {
                JScrollPane spClients = new JScrollPane();
                spClients.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spClients.setName("spClients");
                pnlLoadProfileProperties.add(spClients, "cell 2 1 1 3,grow");
                {
                    tblClients = new JCheckListTable();
                    tblClients.setName("tblClients");
                    spClients.setViewportView(tblClients);
                    spClients.setColumnHeaderView(null);
                }
            }
            {
                JScrollPane spTargets = new JScrollPane();
                spTargets.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spTargets.setName("spTargets");
                pnlLoadProfileProperties.add(spTargets, "cell 4 1 1 3,grow");
                {
                    tblTargets = new JCheckListTable();
                    tblTargets.setName("tblTargets");
                    spTargets.setViewportView(tblTargets);
                    spTargets.setColumnHeaderView(null);
                }
            }
            {
                lblDescription = new JLabel("Description");
                lblDescription.setDisplayedMnemonic('D');
                lblDescription.setName("lblDescription");
                pnlLoadProfileProperties.add(lblDescription, "cell 0 2");
            }
            {
                JScrollPane spDescription = new JScrollPane();
                spDescription.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spDescription.setName("spDescription");
                pnlLoadProfileProperties.add(spDescription, "cell 0 3,height 50:50:,grow");
                {
                    taDescription = new JTextArea();
                    taDescription.setFont(txtName.getFont());
                    lblDescription.setLabelFor(taDescription);
                    taDescription.setRows(3);
                    taDescription.setName("taDescription");
                    taDescription.getDocument().addDocumentListener(dirtyListener);
                    spDescription.setViewportView(taDescription);
                }
            }
        }
        {
            JPanel pnlCurveAssignment = new JPanel();
            pnlCurveAssignment.setBorder(new TitledBorder(null, "Active Load Curve Assignment",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
            pnlMain.add(pnlCurveAssignment, "cell 0 1,grow");
            pnlCurveAssignment.setLayout(new MigLayout("insets 4", "[grow]", "[grow][]"));
            {
                pnlCard = new JPanel();
                pnlCard.setName("pnlCard");
                pnlCurveAssignment.add(pnlCard, "cell 0 0,grow");
                cardLayout = new CardLayout(0, 0);
                pnlCard.setLayout(cardLayout);
                {
                    stairsPanel = new StairsPanel();
                    stairsPanel.setName("stairsPanel");
                    pnlCard.add(stairsPanel, "stairs");
                }
                {
                    oneTimePanel = new OneTimePanel();
                    oneTimePanel.setName("oneTimePanel");
                    pnlCard.add(oneTimePanel, "oneTime");
                }
                {
                    markerPanel = new MarkerPanel();
                    markerPanel.setName("markerPanel");
                    pnlCard.add(markerPanel, "marker");
                }
                {
                    JLabel lblNoActiveCurve = new JLabel("no active curve assignment");
                    lblNoActiveCurve.setHorizontalAlignment(SwingConstants.CENTER);
                    pnlCard.add(lblNoActiveCurve, "none");
                    lblNoActiveCurve.setName("lblNoActiveCurve");
                }
            }
            {
                btnOk = new JButtonExt("OK");
                getRootPane().setDefaultButton(btnOk);
                btnOk.setEnabled(false);
                btnOk.addActionListener(new BtnOkActionListener());
                btnOk.setMnemonic(KeyEvent.VK_O);
                btnOk.setName("btnOk");
                pnlCurveAssignment.add(btnOk, "cell 0 1,alignx right");
            }
            {
                btnCancel = new JButtonExt("Cancel");
                btnCancel.setEnabled(false);
                btnCancel.addActionListener(new BtnCancelActionListener());
                btnCancel.setMnemonic(KeyEvent.VK_C);
                btnCancel.setName("btnCancel");
                pnlCurveAssignment.add(btnCancel, "cell 0 1,alignx right");
            }
        }
    }
}

From source file:savant.snp.SNPFinderPlugin.java

private void setupGUI(JPanel panel) {

    // add a toolbar
    JToolBar tb = new JToolBar();
    tb.setName("SNP Finder Toolbar");

    // add an ON/OFF checkbox
    JLabel lab_on = new JLabel("On/Off: ");
    JCheckBox cb_on = new JCheckBox();
    cb_on.setSelected(isSNPFinderOn);//w  w  w .j  a  v a 2 s  .c o m

    // what to do when a user clicks the checkbox
    cb_on.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // switch the SNP finder on/off
            setIsOn(!isSNPFinderOn);
            addMessage("Turning SNP finder " + (isSNPFinderOn ? "on" : "off"));
        }
    });
    // add a  Bookmarking ON/OFF checkbox
    JLabel lab_bm = new JLabel("Add Bookmarks: ");
    JCheckBox cb_bm = new JCheckBox();
    cb_bm.setSelected(addBookmarks);

    // what to do when a user clicks the checkbox
    cb_bm.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // switch the SNP finder on/off
            setBookmarking(!addBookmarks);
            addMessage("Turning Bookmarking " + (addBookmarks ? "on" : "off"));
        }
    });

    JLabel lab_sp = new JLabel("Heterozygosity: ");
    //add snp prior textfield
    final JTextField snpPriorField = new JTextField(String.valueOf(snpPrior), 4);
    snpPriorField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                setSNPPrior(Double.valueOf(snpPriorField.getText()));
            } catch (NumberFormatException ex) {
                snpPriorField.setText(String.valueOf(snpPrior));
            }
        }
    });
    int tfwidth = 35;
    int tfheight = 22;
    snpPriorField.setPreferredSize(new Dimension(tfwidth, tfheight));
    snpPriorField.setMaximumSize(new Dimension(tfwidth, tfheight));
    snpPriorField.setMinimumSize(new Dimension(tfwidth, tfheight));

    // add a sensitivity slider
    JLabel lab_confidence = new JLabel("Confidence: ");
    final JSlider sens_slider = new JSlider(0, 50);
    sens_slider.setValue(confidence);
    final JLabel lab_confidence_status = new JLabel("" + sens_slider.getValue());

    // what to do when a user slides the slider
    sens_slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            // set the snp finder's sensitivity
            lab_confidence_status.setText("" + sens_slider.getValue());
            setSensitivity(sens_slider.getValue());
        }
    });
    // don't report the new setting until the user stops sliding
    sens_slider.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            addMessage("Changed confidence to " + confidence);
        }
    });

    // add a transparency slider
    JLabel lab_trans = new JLabel("Transparency: ");
    final JSlider trans_slider = new JSlider(0, 100);
    trans_slider.setValue(transparency);
    final JLabel lab_transparency_status = new JLabel("" + trans_slider.getValue());

    // what to do when a user slides the slider
    trans_slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            // set the snp finder's transparency
            lab_transparency_status.setText("" + trans_slider.getValue());
            setTransparency(trans_slider.getValue());
        }
    });

    // don't report the new setting until the user stops sliding
    trans_slider.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            addMessage("Changed transparency to " + transparency);
        }
    });

    // add the components to the GUI
    panel.setLayout(new BorderLayout());
    tb.add(lab_on);
    tb.add(cb_on);
    tb.add(lab_bm);
    tb.add(cb_bm);
    tb.add(new JToolBar.Separator());
    tb.add(lab_sp);
    tb.add(snpPriorField);
    tb.add(new JToolBar.Separator());
    tb.add(lab_confidence);
    tb.add(sens_slider);
    tb.add(lab_confidence_status);

    tb.add(new JToolBar.Separator());

    tb.add(lab_trans);
    tb.add(trans_slider);
    tb.add(lab_transparency_status);

    panel.add(tb, BorderLayout.NORTH);

    // add a text area to the GUI
    info = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(info);
    panel.add(scrollPane, BorderLayout.CENTER);

}