Example usage for javax.swing JButton setText

List of usage examples for javax.swing JButton setText

Introduction

In this page you can find the example usage for javax.swing JButton 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:uk.ac.soton.mib104.t2.workbench.ui.ActivityConfigurationPanelWithInputPortAndOutputPortComponents.java

/**
 * Initializes the graphical user interface (GUI).
 * <p>/*from  w  w  w .  ja  v  a2s.com*/
 * Subclasses may refine the implementation of this method. 
 */
protected void initGui() {
    this.setDoubleBuffered(false);
    this.setLayout(new BorderLayout());

    tabbedPane.setBorder(BorderFactory.createEmptyBorder());

    tabbedPane.addTab(defaultInputPortsTabText, defaultInputPortsTabIcon, inputPortsPane,
            defaultInputPortsTabTip);
    tabbedPane.addTab(defaultOutputPortsTabText, defaultOutputPortsTabIcon, outputPortsPane,
            defaultOutputPortsTabTip);

    this.add(tabbedPane, BorderLayout.CENTER);

    inputPortsPane.setBorder(BorderFactory.createEmptyBorder());
    inputPortsPane.setLayout(new BorderLayout());

    emptyInputPortsLabel.setHorizontalAlignment(JLabel.CENTER);
    emptyInputPortsLabel.setText(defaultEmptyInputPortsText);

    final JButton addInputPortButton = new JButton();
    addInputPortButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            final String portName = nextPortName(defaultInputPortName,
                    ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this.getInputPortComponents()
                            .keySet());

            final IN_CONFIG inputPortConfigBean = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this
                    .newInputPortConfiguration();

            final IN_COMPONENT inputPortComponent = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this
                    .toInputPortComponent(portName, inputPortConfigBean);

            inputPortsTabbedPane.addTab(portName, inputPortComponent);
        }

    });
    addInputPortButton.setIcon(defaultAddInputPortButtonIcon);
    addInputPortButton.setText(defaultAddInputPortButtonText);
    addInputPortButton.setToolTipText(defaultAddInputPortButtonTip);

    inputPortsPane.add(emptyInputPortsLabel, BorderLayout.CENTER);
    inputPortsPane.add(addInputPortButton, BorderLayout.SOUTH);

    outputPortsPane.setBorder(BorderFactory.createEmptyBorder());
    outputPortsPane.setLayout(new BorderLayout());

    emptyOutputPortsLabel.setHorizontalAlignment(JLabel.CENTER);
    emptyOutputPortsLabel.setText(defaultEmptyOutputPortsText);

    final JButton addOutputPortButton = new JButton();
    addOutputPortButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            final String portName = nextPortName(defaultOutputPortName,
                    ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this
                            .getOutputPortComponents().keySet());

            final OUT_CONFIG outputPortConfigBean = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this
                    .newOutputPortConfiguration();

            final OUT_COMPONENT outputPortComponent = ActivityConfigurationPanelWithInputPortAndOutputPortComponents.this
                    .toOutputPortComponent(portName, outputPortConfigBean);

            outputPortsTabbedPane.addTab(portName, outputPortComponent);
        }

    });
    addOutputPortButton.setIcon(defaultAddOutputPortButtonIcon);
    addOutputPortButton.setText(defaultAddOutputPortButtonText);
    addOutputPortButton.setToolTipText(defaultAddOutputPortButtonTip);

    outputPortsPane.add(emptyOutputPortsLabel, BorderLayout.CENTER);
    outputPortsPane.add(addOutputPortButton, BorderLayout.SOUTH);
}

From source file:zxmax.tools.timerreview.gui.StartTimerWindow.java

private Component getPnlNewTimer() {
    setTitle(I18N.getLabel(getClass(), "window.title"));
    JPanel pnlNewTimer = new JPanel();
    LayoutManager layout = new MigLayout("flowy", "[328.00][grow,fill]", "[][][][][]");
    taFocusOn = new JTextArea();
    taFocusOn.setWrapStyleWord(true);/*from  w w w  .j a v  a 2 s . com*/
    JScrollPane spFocusOn = new JScrollPane();
    tfTitle = new JTextField(30);
    JButton btnStart = new JButton();

    pnlNewTimer.setLayout(layout);
    btnStart.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_BTN_START_LABEL));
    taFocusOn.setColumns(20);
    taFocusOn.setForeground(new Color(0, 153, 0));
    taFocusOn.setRows(5);
    taFocusOn.setTabSize(2);
    taFocusOn.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TEXT));
    taFocusOn.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TOOL_TIP));
    spFocusOn.setViewportView(taFocusOn);
    taFocusOn.getAccessibleContext().setAccessibleName("taFocusOn");

    btnStart.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            storeDataAndStartTimer();
        }
    });
    btnStart.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            logger.debug(evt.getKeyCode() + ", " + evt.getKeyChar());
            if (KeyEvent.VK_ENTER == evt.getKeyCode()) {
                storeDataAndStartTimer();
            }
        }
    });

    JLabel lblTitle = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_TITLE_LABEL));

    pnlNewTimer.add(lblTitle, "cell 0 0");
    pnlNewTimer.add(tfTitle, "cell 0 1 2 1,growx");
    JLabel lblFocusOn = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_LABEL));
    pnlNewTimer.add(lblFocusOn, "cell 0 2");
    pnlNewTimer.add(spFocusOn, "cell 0 3 2 1,growx");
    pnlNewTimer.add(btnStart, "cell 0 4 2 1,growx");

    Box horizontalBox = Box.createHorizontalBox();
    pnlNewTimer.add(horizontalBox, "flowx,cell 1 0");

    JLabel lblDurata = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_LABEL));
    lblDurata.setHorizontalAlignment(SwingConstants.RIGHT);
    pnlNewTimer.add(lblDurata, "cell 1 0,alignx right");
    lblDurata.setLabelFor(txtDurata);

    txtDurata = new JTextField("20");
    txtDurata.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_TOOL_TIP));
    pnlNewTimer.add(txtDurata, "cell 1 0,alignx center");
    txtDurata.setColumns(2);

    return pnlNewTimer;
}