本文整理了Java中javax.swing.JButton.setBounds()
方法的一些代码示例,展示了JButton.setBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setBounds()
方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setBounds
暂无
代码示例来源:origin: stackoverflow.com
public void createOptions()
{
options = new JPanel();
options.setLayout(null);
JLabel labelOptions = new JLabel("Change Company Name:");
labelOptions.setBounds(120, 10, 150, 20);
options.add(labelOptions);
newTitle = new JTextField("Some Title");
newTitle.setBounds(80, 40, 225, 20);
options.add(newTitle);
// myTitle = new JTextField("My Title...");
// myTitle.setBounds(80, 40, 225, 20);
// myTitle.add(labelOptions);
JButton newName = new JButton("Set New Name");
newName.setBounds(60, 80, 150, 20);
newName.addActionListener(this);
options.add(newName);
JButton Exit = new JButton("Exit");
Exit.setBounds(250, 80, 80, 20);
Exit.addActionListener(this);
options.add(Exit);
}
代码示例来源:origin: wildfly/wildfly
err_msg.setForeground(Color.red);
err_msg.setVisible(false);
get.setBounds(new Rectangle(10, 250, 60, 30));
set.setBounds(new Rectangle(80, 250, 60, 30));
quit.setBounds(new Rectangle(150, 250, 60, 30));
get_all.setBounds(new Rectangle(220, 250, 60, 30));
delete.setBounds(new Rectangle(290, 250, 80, 30));
get.addActionListener(this);
set.addActionListener(this);
quit.addActionListener(this);
get_all.addActionListener(this);
delete.addActionListener(this);
代码示例来源:origin: stackoverflow.com
JButton addBtn = new JButton("+");
addBtn.setBounds(x_pos, y_pos, 30, 25);
addBtn.setBorder(new RoundedBorder(10)); //10 is the radius
addBtn.setForeground(Color.BLUE);
代码示例来源:origin: FudanNLP/fnlp
panel.add(jspOut);
button=new JButton("发送");
button.addActionListener(new ButtonListener());
button.setBounds(width*4/5+sp, height*5/6+sp*2, width*1/5-sp*2, height*1/6);
panel.add(button);
代码示例来源:origin: magefree/mage
jButtonSort = new JButton();
int w = getDlgParams().rect.width - 75;
int h = getDlgParams().rect.height - 75;
jButtonSort.setBounds(new Rectangle(w / 2 + 150, h - 30, 78, 22));
jButtonSort.setText("Sort");
jButtonSort.setVisible(false);
代码示例来源:origin: Slowpoke101/FTBLaunch
public void addUpdateJREButton (final String webLink, String unlocMessage) {
btnInstallJava.setText(I18N.getLocaleString(unlocMessage));
btnInstallJava.addActionListener(new ActionListener() {
@Override
public void actionPerformed (ActionEvent arg0) {
OSUtils.browse(webLink);
}
});
btnInstallJava.setBounds(345, 210, 150, 28);
fitterPane.add(btnInstallJava);
}
代码示例来源:origin: nodebox/nodebox
public InterruptibleProgressDialog(Frame owner, String title) {
super(owner, title);
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
setAlwaysOnTop(true);
JButton cancelButton = new JButton("Cancel");
cancelButton.setBounds(270, 50, 80, 32);
getContentPane().add(cancelButton);
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
if (thread != null)
thread.interrupt();
}
});
}
代码示例来源:origin: magefree/mage
public static JXPanel getDescription(CardView card, int width, int height) {
JXPanel descriptionPanel = new JXPanel();
//descriptionPanel.setAlpha(.8f);
descriptionPanel.setBounds(0, 0, width, height);
descriptionPanel.setVisible(false);
descriptionPanel.setLayout(null);
//descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
JButton j = new JButton("");
j.setBounds(0, 0, width, height);
j.setBackground(Color.black);
j.setLayout(null);
JLabel cardText = new JLabel();
cardText.setBounds(5, 5, width - 10, height - 10);
cardText.setForeground(Color.white);
cardText.setFont(cardNameFont);
cardText.setVerticalAlignment(SwingConstants.TOP);
j.add(cardText);
TextLines textLines = GuiDisplayUtil.getTextLinesfromCardView(card);
cardText.setText(getRulefromCardView(card, textLines).toString());
descriptionPanel.add(j);
return descriptionPanel;
}
代码示例来源:origin: stackoverflow.com
JButton btnCalender = new JButton("Calendar", new ImageIcon(
"./src/Calendar_0.jpg"));
btnCalender.setBorder(BorderFactory.createEmptyBorder());
btnCalender.setContentAreaFilled(false);
btnCalender.setBounds(244, 177, 129, 36);
btnCalender.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
frmOptions.getContentPane().add(btnCalender);
frmOptions.setDefaultCloseOperation(3);
frmOptions.pack();
frmOptions.setLocationRelativeTo(null);
frmOptions.setVisible(true);
代码示例来源:origin: magefree/mage
image = ImageHelper.getImageFromResources("/info/cheat.png");
resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
cheat = new JButton();
cheat.setIcon(new ImageIcon(resized));
cheat.setToolTipText("Cheat button");
cheat.addActionListener(e -> btnCheatActionPerformed(e));
zonesPanel.add(commandZone);
cheat.setBounds(28, 0, 25, 21);
zonesPanel.add(cheat);
experience.setOpaque(false);
btnPlayer = new JButton();
btnPlayer.setText("Player");
btnPlayer.setVisible(false);
btnPlayer.setToolTipText("Player");
btnPlayer.addActionListener(e -> SessionHandler.sendPlayerUUID(gameId, playerId));
代码示例来源:origin: stackoverflow.com
...
button.setBounds(100, 60, 100, 30);
button.setToolTipText("A button component");
JButton button2 = new JButton("Odd");
button2.setBounds(100, 60, 100, 30);
...
代码示例来源:origin: stackoverflow.com
int x = 340;
for (char c = 'A'; c <= 'Z'; ++c, x += 10) {
JButton button = new JButton(Character.toString(c));
final char lower = Character.toLowercase(c);
button.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
game.checkGuess(lower);
}
});
button.setBounds(x, 250, 5, 5);
button.setVisible(true);
this.add(button);
}
代码示例来源:origin: stackoverflow.com
//Create and add media control buttons
JButton btnPlay = new JButton("Play");
btnPlay.setBounds(10, 116, 89, 23);
panel.add(btnPlay);
JButton btnLoop = new JButton("Loop");
btnLoop.setBounds(109, 116, 89, 23);
panel.add(btnLoop);
JButton btnStop = new JButton("Stop");
btnStop.setBounds(208, 116, 89, 23);
panel.add(btnStop);
代码示例来源:origin: stackoverflow.com
ArrayList<JButton> buttons = new ArrayList<JButton>();
public JButton buttons(int coord, int coord1, int number) {
JButton box = new JButton("");
box.setFont(new Font("Tahoma", Font.PLAIN, 60));
box.setBounds(coord, coord1, 100, 100);
contentPane.add(box);
box.addActionListener(this);
box.setActionCommand(Integer.toString(number));
buttons.add(box);//Add it here
return box;
}
代码示例来源:origin: stackoverflow.com
for (int i = 0; i < 1; i++) {
for (int j = 0; j <1; j++) {
JButton b = new JButton("button");
b.setBounds(500, 500, 100, 20);
this.add(b);
}
}
this.repaint();
this.validate()
代码示例来源:origin: stackoverflow.com
JButton btnNewButton_1 = new JButton("New");
btnNewButton_1.setBackground(Color.LIGHT_GRAY);
btnNewButton_1.setBounds(236, 228, 89, 23);
frame.getContentPane().add(btnNewButton_1);
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//actions here
}
});
代码示例来源:origin: stackoverflow.com
Rectangle cell = table.getCellRect(....);
JButton button = new JButton(...);
button.setBounds( cell );
table.add( button );
table.repaint();
代码示例来源:origin: lingfengsan/MillionHero
/**
*
* @param panel 增加获取答案按钮
*/
private static void addRunButton(JPanel panel) {
final JButton runButton = new JButton("获取答案");
runButton.setBounds(160, 170, 120, 25);
panel.add(runButton);
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
String result = COMMON_PATTERN.run();
System.out.println(result);
resultTextArea.setText(result);
} catch (UnsupportedEncodingException e1) {
logger.error(e1.getMessage());
}
}
};
runButton.addActionListener(listener);
}
代码示例来源:origin: stackoverflow.com
JButton startButton = new JButton("Click Me To Start!");
// startButton.setBounds(300, 50,140, 50 );
startButton.setBounds(BUTTON_LOCATION_X
, BUTTON_LOCATION_Y,
BUTTON_SIZE_X,
BUTTON_SIZE_Y );
contentPane.add(startButton);
代码示例来源:origin: lingfengsan/MillionHero
/**
*
* @param panel 增加设置完成按钮
*/
private static void addSetFinishButton(JPanel panel) {
final JButton setFinishButton = new JButton("设置完成");
setFinishButton.setBounds(40, 170, 120, 25);
panel.add(setFinishButton);
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Config.setAdbPath(adbPathText.getText());
Config.setPhotoPath(imagePathText.getText());
try {
Utils.storeConfig();
} catch (IOException e1) {
logger.error("存储配置信息失败");
}
Utils utils = new Utils(Config.getAdbPath(), Config.getPhotoPath());
COMMON_PATTERN.setUtils(utils);
COMMON_PATTERN.setPatterSelection(patternSelection);
COMMON_PATTERN.setSearchSelection(searchSelection);
}
};
setFinishButton.addActionListener(listener);
}
内容来源于网络,如有侵权,请联系作者删除!