本文整理汇总了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();
}
});
}
示例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();
}
示例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);
}
}
}
示例4: keyReleased
import javax.swing.JButton; //导入依赖的package包/类
public void keyReleased(KeyEvent e)
{
if ( e.getKeyChar() == '\n' )
{
((JButton)e.getSource()).doClick();
}
}
示例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$
}
示例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);
}
示例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"));
}
示例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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}