本文整理了Java中java.awt.Button.addKeyListener()
方法的一些代码示例,展示了Button.addKeyListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.addKeyListener()
方法的具体详情如下:
包路径:java.awt.Button
类名称:Button
方法名:addKeyListener
暂无
代码示例来源:origin: sc.fiji/Image_5D
public ChannelSelectorOverlay(final ChannelControl cControl) {
super(new BorderLayout());
this.cControl = cControl;
nChannels = cControl.nChannels;
// Panel with "All" and "None" Buttons in NORTH of this control.
allNonePanel = new Panel(new GridLayout(1, 2));
allButton = new Button("All");
allButton.addActionListener(this);
allNonePanel.add(allButton);
noneButton = new Button("None");
noneButton.addActionListener(this);
allNonePanel.add(noneButton);
add(allNonePanel, BorderLayout.NORTH);
addKeyListener(win);
allButton.addKeyListener(win);
noneButton.addKeyListener(win);
// Pass key hits on to ImageJ
addKeyListener(ij);
allButton.addKeyListener(ij);
noneButton.addKeyListener(ij);
addKeyListener(win);
allButton.addKeyListener(win);
noneButton.addKeyListener(win);
buildChannelSelector();
}
代码示例来源:origin: sc.fiji/TransformJ_
private Button addButton(String label) {
final Button b = new Button(" "+label+" ");
b.addActionListener(this);
b.addKeyListener(this);
panel.add(b);
return b;
}
代码示例来源:origin: net.imagej/ij
void addButton(String label) {
Button b = new Button(label);
b.addActionListener(this);
b.addKeyListener(IJ.getInstance());
b.addMouseListener(this);
if (label.equals(moreButtonLabel)) moreButton = b;
panel.add(b);
}
代码示例来源:origin: imagej/ImageJA
void addButton(String label) {
Button b = new Button(label);
b.addActionListener(this);
b.addKeyListener(IJ.getInstance());
b.addMouseListener(this);
if (label.equals(moreButtonLabel)) moreButton = b;
panel.add(b);
}
代码示例来源:origin: sc.fiji/fiji-lib
/**
* Add button to the dialog
* @param label button label
* @param listener listener to handle the action when pressing the button
*/
public void addButton(String label, ActionListener listener) {
if (isHeadless()) return;
Button button = new Button(label);
button.addActionListener(listener);
button.addKeyListener(this);
addComponent(button);
}
代码示例来源:origin: sc.fiji/fiji-lib
public void addFileField(String label, String defaultPath, int columns) {
addStringField(label, defaultPath, columns);
if (isHeadless()) return;
TextField text = (TextField)stringField.lastElement();
GridBagLayout layout = (GridBagLayout)getLayout();
GridBagConstraints constraints = layout.getConstraints(text);
Button button = new Button("Browse...");
FileListener listener = new FileListener("Browse for " + label, text);
button.addActionListener(listener);
button.addKeyListener(this);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
panel.add(text);
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
}
代码示例来源:origin: sc.fiji/bigdataviewer_fiji
public static void addSaveAsFileField( final GenericDialogPlus dialog, final String label, final String defaultPath, final int columns) {
dialog.addStringField( label, defaultPath, columns );
final TextField text = ( TextField ) dialog.getStringFields().lastElement();
final GridBagLayout layout = ( GridBagLayout ) dialog.getLayout();
final GridBagConstraints constraints = layout.getConstraints( text );
final Button button = new Button( "Browse..." );
final ChooseXmlFileListener listener = new ChooseXmlFileListener( text );
button.addActionListener( listener );
button.addKeyListener( dialog );
final Panel panel = new Panel();
panel.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) );
panel.add( text );
panel.add( button );
layout.setConstraints( panel, constraints );
dialog.add( panel );
}
代码示例来源:origin: sc.fiji/fiji-lib
public void addDirectoryOrFileField(String label, String defaultPath, int columns) {
addStringField(label, defaultPath, columns);
if (isHeadless()) return;
TextField text = (TextField)stringField.lastElement();
GridBagLayout layout = (GridBagLayout)getLayout();
GridBagConstraints constraints = layout.getConstraints(text);
Button button = new Button("Browse...");
DirectoryListener listener = new DirectoryListener("Browse for " + label, text, JFileChooser.FILES_AND_DIRECTORIES);
button.addActionListener(listener);
button.addKeyListener(this);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
panel.add(text);
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
}
代码示例来源:origin: sc.fiji/bigdataviewer_fiji
public static void addBrowseToCellVoyagerFolder( final GenericDialogPlus dialog, final String label, final String defaultPath, final int columns )
{
dialog.addStringField( label, defaultPath, columns );
final TextField text = ( TextField ) dialog.getStringFields().lastElement();
final GridBagLayout layout = ( GridBagLayout ) dialog.getLayout();
final GridBagConstraints constraints = layout.getConstraints( text );
final Button button = new Button( "Browse..." );
final ChooseCellVoyagerDirListener listener = new ChooseCellVoyagerDirListener( text );
button.addActionListener( listener );
button.addKeyListener( dialog );
final Panel panel = new Panel();
panel.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) );
panel.add( text );
panel.add( button );
layout.setConstraints( panel, constraints );
dialog.add( panel );
}
代码示例来源:origin: sc.fiji/fiji-lib
public void addDirectoryField(String label, String defaultPath, int columns) {
addStringField(label, defaultPath, columns);
if (isHeadless()) return;
TextField text = (TextField)stringField.lastElement();
GridBagLayout layout = (GridBagLayout)getLayout();
GridBagConstraints constraints = layout.getConstraints(text);
Button button = new Button("Browse...");
DirectoryListener listener = new DirectoryListener("Browse for " + label, text);
button.addActionListener(listener);
button.addKeyListener(this);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
panel.add(text);
panel.add(button);
layout.setConstraints(panel, constraints);
add(panel);
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static void addSaveAsFileField( final GenericDialogPlus dialog, final String label, final String defaultPath, final int columns)
{
dialog.addStringField( label, defaultPath, columns );
if ( isHeadless() )
return;
final TextField text = ( TextField ) dialog.getStringFields().lastElement();
final GridBagLayout layout = ( GridBagLayout ) dialog.getLayout();
final GridBagConstraints constraints = layout.getConstraints( text );
final Button button = new Button( "Browse..." );
final ChooseXmlFileListener listener = new ChooseXmlFileListener( text );
button.addActionListener( listener );
button.addKeyListener( dialog );
final Panel panel = new Panel();
panel.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) );
panel.add( text );
panel.add( button );
layout.setConstraints( panel, constraints );
dialog.add( panel );
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static void addSaveAsDirectoryField( final GenericDialogPlus dialog, final String label, final String defaultPath, final int columns)
{
dialog.addStringField( label, defaultPath, columns );
if ( isHeadless() )
return;
final TextField text = ( TextField ) dialog.getStringFields().lastElement();
final GridBagLayout layout = ( GridBagLayout ) dialog.getLayout();
final GridBagConstraints constraints = layout.getConstraints( text );
final Button button = new Button( "Browse..." );
final ChooseDirectoryListener listener = new ChooseDirectoryListener( text );
button.addActionListener( listener );
button.addKeyListener( dialog );
final Panel panel = new Panel();
panel.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) );
panel.add( text );
panel.add( button );
layout.setConstraints( panel, constraints );
dialog.add( panel );
}
代码示例来源:origin: net.imagej/ij
button = new Button(" OK ");
button.addActionListener(this);
button.addKeyListener(this);
c.insets = new Insets(2, 6, 6, 6);
c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.EAST;
代码示例来源:origin: sc.fiji/MTrackJ_
public void showDialog() {
yes = new Button(" Yes ");
yes.setFont(font);
yes.addActionListener(this);
yes.addKeyListener(this);
no = new Button(" No ");
no.setFont(font);
no.addActionListener(this);
no.addKeyListener(this);
Panel panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
panel.add(yes);
panel.add(no);
add("Center",panel);
panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.CENTER,0,5));
add("South",panel);
pack();
if (topleft != null) setLocation(topleft);
else GUI.center(this);
setResizable(true);
setVisible(true);
}
代码示例来源:origin: sc.fiji/TrakEM2_
yesB.addKeyListener(this);
noB.addKeyListener(this);
if (IJ.isMacintosh()) {
panel.add(noB);
代码示例来源:origin: sc.fiji/MTrackJ_
button.setFont(font);
button.addActionListener(this);
button.addKeyListener(this);
panel = new Panel();
panel.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
代码示例来源:origin: org.nakedobjects.plugins/dndviewer
public LoginDialog() {
super("Naked Objects Login");
AWTUtilities.addWindowIcon(this, "login-logo.png");
setLayout(new GridLayout(3, 2, 10, 10));
setResizable(false);
add(new Label("User name:", Label.LEFT));
add(user = new TextField());
user.addKeyListener(this);
add(new Label("Password:", Label.LEFT));
add(password = new TextField());
password.addKeyListener(this);
password.setEchoChar('*');
add(cancel = new Button(CANCEL_LABEL));
cancel.addActionListener(this);
cancel.addKeyListener(this);
add(login = new Button(LOGIN_LABEL));
login.addActionListener(this);
login.addKeyListener(this);
pack();
final int width = getSize().width; // getWidth();
final int height = getSize().height; // getHeight();
final Dimension screen = getToolkit().getScreenSize();
int x = (screen.width / 2) - (width / 2);
if ((screen.width / screen.height) >= 2) {
x = (screen.width / 4) - (width / 2);
}
final int y = (screen.height / 2) - (height / 2);
setLocation(x, y);
user.requestFocus();
}
代码示例来源:origin: org.nakedobjects/nos-viewer-dnd
public LoginDialog() {
super("Naked Objects Login");
AWTUtilities.addWindowIcon(this, "login-logo.png");
setLayout(new GridLayout(3, 2, 10, 10));
setResizable(false);
add(new Label("User name:", Label.LEFT));
add(user = new TextField());
user.addKeyListener(this);
add(new Label("Password:", Label.LEFT));
add(password = new TextField());
password.addKeyListener(this);
password.setEchoChar('*');
add(cancel = new Button(CANCEL_LABEL));
cancel.addActionListener(this);
cancel.addKeyListener(this);
add(login = new Button(LOGIN_LABEL));
login.addActionListener(this);
login.addKeyListener(this);
pack();
int width = getSize().width; // getWidth();
int height = getSize().height; // getHeight();
Dimension screen = getToolkit().getScreenSize();
int x = (screen.width / 2) - (width / 2);
if ((screen.width / screen.height) >= 2) {
x = (screen.width / 4) - (width / 2);
}
int y = (screen.height / 2) - (height / 2);
setLocation(x, y);
user.requestFocus();
}
代码示例来源:origin: org.nakedobjects/nos-viewer-dnd
public ShutdownDialog(final ViewerFrame owner) {
super(owner, "Naked Objects", true);
//AWTUtilities.addWindowIcon(this, "shutdown-logo.gif");
setLayout(new GridLayout(2, 3, 10, 10));
add(new Label("Exit Naked Objects?", Label.LEFT));
add(new Panel());
add(new Panel());
add(new Panel());
add(quit = new Button(QUIT_LABEL));
quit.addActionListener(this);
quit.addKeyListener(this);
add(cancel = new Button(CANCEL_LABEL));
cancel.addActionListener(this);
cancel.addKeyListener(this);
pack();
int width = getSize().width; // getWidth();
int height = getSize().height; // getHeight();
Dimension screen = owner.getSize();
Point point = owner.getLocation();
int x = point.x + (screen.width / 2) - (width / 2);
int y = point.y + (screen.height / 2) - (height / 2);
setLocation(x, y);
show();
quit.requestFocus();
addWindowListener(new WindowAdapter() {
public void windowClosing(final WindowEvent e) {
dispose();
}
});
}
代码示例来源:origin: org.nakedobjects.plugins/dndviewer
quit.addKeyListener(this);
cancel.addKeyListener(this);
内容来源于网络,如有侵权,请联系作者删除!