当前位置: 首页>>代码示例>>Java>>正文


Java JButton类代码示例

本文整理汇总了Java中javax.swing.JButton的典型用法代码示例。如果您正苦于以下问题:Java JButton类的具体用法?Java JButton怎么用?Java JButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JButton类属于javax.swing包,在下文中一共展示了JButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inizializzaExitButton

import javax.swing.JButton; //导入依赖的package包/类
private void inizializzaExitButton() {
    esci = new JButton(caricaImmagine("dominio/immagini/esci.png"));
    esci.setBounds(35, 600, 96, 58);
    esci.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                audio.ferma("soundTrack");
                audio.riavvolgi("soundTrack");
            } catch (CanzoneNonTrovataException ex) {
                ex.printStackTrace();
            }
            menu_pre_partita.setVisible(true);
            dispose();
        }
    });
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-A,代码行数:18,代码来源:PartitaOfflineGuiView.java

示例2: show

import javax.swing.JButton; //导入依赖的package包/类
boolean show () {
    panel.rbSoft.addActionListener(this);
    panel.rbMixed.addActionListener(this);
    panel.rbHard.addActionListener(this);
    
    okButton = new JButton(NbBundle.getMessage(Reset.class, "LBL_Reset.OKButton.text")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(okButton, okButton.getText());
    dd = new DialogDescriptor(panel, NbBundle.getMessage(Reset.class, "LBL_Reset.title"), true,  //NOI18N
            new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(Reset.class), null);
    revisionPicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName() == RevisionDialogController.PROP_VALID) {
                setRevisionValid(Boolean.TRUE.equals(evt.getNewValue()));
            }
        }
    });
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    validate();
    d.setVisible(true);
    return okButton == dd.getValue();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:Reset.java

示例3: actionPerformed

import javax.swing.JButton; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    String title = NbBundle.getMessage(RunTargetsAction.class, "TITLE_run_advanced");
    AdvancedActionPanel panel = new AdvancedActionPanel(project, allTargets);
    DialogDescriptor dd = new DialogDescriptor(panel, title);
    dd.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton run = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_run"));
    run.setDefaultCapable(true);
    JButton cancel = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_cancel"));
    dd.setOptions(new Object[] {run, cancel});
    dd.setModal(true);
    Object result = DialogDisplayer.getDefault().notify(dd);
    if (result.equals(run)) {
        try {
            panel.run();
        } catch (IOException x) {
            AntModule.err.notify(x);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RunTargetsAction.java

示例4: keyReleased

import javax.swing.JButton; //导入依赖的package包/类
public void keyReleased(KeyEvent e)
{
	if ( e.getKeyChar() == '\n' )
	{
		((JButton)e.getSource()).doClick();
	}
}
 
开发者ID:HY-ZhengWei,项目名称:HBaseClient,代码行数:8,代码来源:SubmitActionListener.java

示例5: addAdditionalControls

import javax.swing.JButton; //导入依赖的package包/类
protected void addAdditionalControls(JComponent c, boolean enabled) {
  jabberHost.setEditable(enabled);
  jabberPort.setEditable(enabled);
  jabberUser.setEditable(enabled);
  jabberPw.setEditable(enabled);
  c.add(new JLabel(Resources.getString("ServerAddressBook.jabber_host"))); //$NON-NLS-1$
  c.add(jabberHost, "wrap, grow, push"); //$NON-NLS-1$
  c.add(new JLabel(Resources.getString("ServerAddressBook.port"))); //$NON-NLS-1$
  c.add(jabberPort, "wrap, grow, push"); //$NON-NLS-1$
  c.add(new JLabel(Resources.getString("ServerAddressBook.user_name"))); //$NON-NLS-1$
  c.add(jabberUser, "wrap, grow, push"); //$NON-NLS-1$
  c.add(new JLabel(Resources.getString("ServerAddressBook.password"))); //$NON-NLS-1$
  c.add(jabberPw, "wrap, grow, push"); //$NON-NLS-1$

  testButton = new JButton(Resources.getString("ServerAddressBook.test_connection")); //$NON-NLS-1$
  testButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      test();
    }
  });
  c.add(testButton, "span 2, align center, wrap"); //$NON-NLS-1$
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:23,代码来源:ServerAddressBook.java

示例6: erzeugeRuecknahmeButton

import javax.swing.JButton; //导入依赖的package包/类
/**
 * Erzeuge den Rücknahme-Button.
 */
private void erzeugeRuecknahmeButton()
{
    JPanel buttonPanel = new JPanel();
    _ruecknahmePanel.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setPreferredSize(new java.awt.Dimension(-1, 110));
    buttonPanel.setSize(-1, -1);
    buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    _ruecknahmeButton = new JButton();
    buttonPanel.add(_ruecknahmeButton);
    _ruecknahmeButton.setText("zurücknehmen");
    _ruecknahmeButton.setPreferredSize(new java.awt.Dimension(140, 100));
    _ruecknahmeButton.setSize(-1, -1);
    _ruecknahmeButton.setEnabled(false);
    _ruecknahmeButton.setFont(UIConstants.BUTTON_FONT);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:20,代码来源:RueckgabeUI.java

示例7: inEQtestReadListOfSubmitButtons

import javax.swing.JButton; //导入依赖的package包/类
public void inEQtestReadListOfSubmitButtons() throws Exception {
    String page = "<html><body><form action='http://xyz.cz' method='POST'>" +
        "<input type='hidden' name='submit' value=\"Send Feedback\"/>" +
        "\n" +
        "</form></body></html>";
    
    InputStream is = new ByteArrayInputStream(page.getBytes());
    JButton def = new JButton("Default");
    Object[] buttons = parseButtons(is, def);
    is.close();
    
    assertNotNull("buttons parsed", buttons);
    assertEquals("Second is default", def, buttons[1]);
    assertEquals("There is one button", 2, buttons.length);
    assertEquals("It is a button", JButton.class, buttons[0].getClass());
    JButton b = (JButton)buttons[0];
    assertEquals("It is named", "Send Feedback", b.getText());
    assertEquals("It url attribute is set", "http://xyz.cz", b.getClientProperty("url"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:InstallerTest.java

示例8: getToolbarPresenter

import javax.swing.JButton; //导入依赖的package包/类
public static Component getToolbarPresenter(Action action) {
    JButton button = new JButton(action);
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setText(null);
    button.putClientProperty("hideActionText", Boolean.TRUE); // NOI18N
    Object icon = action.getValue(Action.SMALL_ICON);
    if (icon == null) {
        icon = ImageUtilities.loadImageIcon("org/netbeans/modules/dlight/terminal/action/local_term.png", false);// NOI18N
    }
    if (!(icon instanceof Icon)) {
        throw new IllegalStateException("No icon provided for " + action); // NOI18N
    }
    button.setDisabledIcon(ImageUtilities.createDisabledIcon((Icon) icon));
    return button;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TerminalSupportImpl.java

示例9: NewDatabaseDialog

import javax.swing.JButton; //导入依赖的package包/类
public NewDatabaseDialog() {
	newDatabaseNameField = new JTextField();
	nextButton = new JButton("NEXT");
	newDatabaseNameField.setPreferredSize(new Dimension(TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT));
	
	setLayout(new BorderLayout());
	
	EmptyBorder padding = new EmptyBorder(5, 5, 5, 5);
	JPanel textFieldPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	
	textFieldPanel.setBorder(padding);
	buttonsPanel.setBorder(padding);
	
	textFieldPanel.add(new JLabel("DB name: "));
	textFieldPanel.add(newDatabaseNameField);
	buttonsPanel.add(nextButton);
	
	add(textFieldPanel, BorderLayout.NORTH);
	add(buttonsPanel, BorderLayout.SOUTH);
	
	buildWindow();
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:24,代码来源:NewDatabaseDialog.java

示例10: status

import javax.swing.JButton; //导入依赖的package包/类
@Messages({
    "JobCreator.copy_message=Global libraries should be copied to a dedicated libraries folder.",
    "JobCreator.copy_label=&Copy Libraries..."
})
public ConfigurationStatus status() {
    if (scm == null) {
        return Helper.noSCMError();
    }
    if (shar != null && !shar.isSharable()) {
        String msg = JobCreator_copy_message();
        JButton button = new JButton();
        Mnemonics.setLocalizedText(button, JobCreator_copy_label());
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                shar.makeSharable();
            }
        });
        return ConfigurationStatus.withWarning(msg).withExtraButton(button);
    }
    ConfigurationStatus scmStatus = scm.problems();
    if (scmStatus != null) {
        return scmStatus;
    } else {
        return ConfigurationStatus.valid();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JobCreator.java

示例11: createTab

import javax.swing.JButton; //导入依赖的package包/类
private JPanel createTab(String subject, JTextField field, JButton button, JList list)
{
	JLabel instruction = new JLabel(CurrentLocale.get(
		"com.dytech.edge.admin.helper.usergroupdialog.selectsomething", //$NON-NLS-1$
		subject));

	JScrollPane scrollPane = new JScrollPane(list);

	final int height1 = instruction.getPreferredSize().height;
	final int height2 = button.getPreferredSize().height;
	final int width1 = button.getPreferredSize().width;

	final int[] rows = {height1, height2, TableLayout.FILL};
	final int[] cols = {TableLayout.FILL, width1};

	JPanel all = new JPanel(new TableLayout(rows, cols));
	all.setBorder(AppletGuiUtils.DEFAULT_BORDER);

	all.add(instruction, new Rectangle(0, 0, 2, 1));
	all.add(field, new Rectangle(0, 1, 1, 1));
	all.add(button, new Rectangle(1, 1, 1, 1));
	all.add(scrollPane, new Rectangle(0, 2, 2, 1));

	return all;
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:UserGroupDialog.java

示例12: controls

import javax.swing.JButton; //导入依赖的package包/类
private JComponent controls()
{
	ds = new JButton("Delete Start");
	ds.addActionListener(this);
	ff = new JButton("Fake Finish");
	ff.addActionListener(this);

	df = new JButton("Delete Finish");
	df.addActionListener(this);
	df.setFont(new Font("dialog", Font.BOLD, 13));

	JPanel top = new JPanel();
	top.add(ds);
	top.add(df);
	top.add(ff);

	return top;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:19,代码来源:Timer.java

示例13: show

import javax.swing.JButton; //导入依赖的package包/类
boolean show() {
    okButton = new JButton(NbBundle.getMessage(CreateBranch.class, "LBL_CreateBranch.OKButton.text")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(okButton, okButton.getText());
    dd = new DialogDescriptor(panel, NbBundle.getMessage(CreateBranch.class, "LBL_CreateBranch.title"), true,  //NOI18N
            new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx("org.netbeans.modules.git.ui.branch.CreateBranch"), null); //NOI18N
    validate();
    revisionPicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName() == RevisionDialogController.PROP_VALID) {
                setRevisionValid(Boolean.TRUE.equals(evt.getNewValue()));
            }
        }
    });
    panel.branchNameField.getDocument().addDocumentListener(this);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.setVisible(true);
    return okButton == dd.getValue();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CreateBranch.java

示例14: registerForMouseEvent

import javax.swing.JButton; //导入依赖的package包/类
public static void registerForMouseEvent(Component comp,
                                         MouseListener mouseListener) {
    if(comp instanceof JScrollPane) {
        JScrollPane pane = (JScrollPane) comp;
        comp = pane.getViewport().getView();
    }
    if(comp instanceof Container) {
        Container container = (Container) comp;
        Component[] components = container.getComponents();
        for(int i = 0; i < components.length; i++) {
            registerForMouseEvent(components[i], mouseListener);
        }
    }

    //No registration for XOpenTypedata that are themselves clickable.
    //No registration for JButton that are themselves clickable.
    if(comp != null &&
       (!(comp instanceof XOpenTypeViewer.XOpenTypeData) &&
        !(comp instanceof JButton)) )
        comp.addMouseListener(mouseListener);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:XDataViewer.java

示例15: initComponents

import javax.swing.JButton; //导入依赖的package包/类
private void initComponents() {
	this.setLayout(new BorderLayout());
	epochs = new JSpinner(new SpinnerNumberModel(10, 10, 50, 1));
	JPanel epochOption = new JPanel(new BorderLayout());
	JPanel flowTemp = new JPanel(new FlowLayout(FlowLayout.LEFT));
	epochs.setPreferredSize(new Dimension(70, 40));
	epochs.setFont(new Font(epochs.getFont().getName(), epochs.getFont().getStyle(), epochs.getFont().getSize() + 4));
	flowTemp.add(new JLabel("<html><body><h3>Select the maximum number of epochs: </h3></body></html> "));
	flowTemp.add(epochs);
	JButton setEpoch = new JButton(this.setEpoch);
	setEpoch.setPreferredSize(new Dimension(85, 35));
	flowTemp.add(setEpoch);
	epochOption.add(flowTemp, BorderLayout.CENTER);
	//JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	//btnPanel.add(setEpoch);
	//epochOption.add(btnPanel,BorderLayout.SOUTH);
	this.add(epochOption, BorderLayout.NORTH);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:19,代码来源:EpochPanel.java


注:本文中的javax.swing.JButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。