javax.swing.JButton.setBounds()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(229)

本文整理了Java中javax.swing.JButton.setBounds()方法的一些代码示例,展示了JButton.setBounds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.setBounds()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:setBounds

JButton.setBounds介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. public void createOptions()
  2. {
  3. options = new JPanel();
  4. options.setLayout(null);
  5. JLabel labelOptions = new JLabel("Change Company Name:");
  6. labelOptions.setBounds(120, 10, 150, 20);
  7. options.add(labelOptions);
  8. newTitle = new JTextField("Some Title");
  9. newTitle.setBounds(80, 40, 225, 20);
  10. options.add(newTitle);
  11. // myTitle = new JTextField("My Title...");
  12. // myTitle.setBounds(80, 40, 225, 20);
  13. // myTitle.add(labelOptions);
  14. JButton newName = new JButton("Set New Name");
  15. newName.setBounds(60, 80, 150, 20);
  16. newName.addActionListener(this);
  17. options.add(newName);
  18. JButton Exit = new JButton("Exit");
  19. Exit.setBounds(250, 80, 80, 20);
  20. Exit.addActionListener(this);
  21. options.add(Exit);
  22. }

代码示例来源:origin: wildfly/wildfly

  1. err_msg.setForeground(Color.red);
  2. err_msg.setVisible(false);
  3. get.setBounds(new Rectangle(10, 250, 60, 30));
  4. set.setBounds(new Rectangle(80, 250, 60, 30));
  5. quit.setBounds(new Rectangle(150, 250, 60, 30));
  6. get_all.setBounds(new Rectangle(220, 250, 60, 30));
  7. delete.setBounds(new Rectangle(290, 250, 80, 30));
  8. get.addActionListener(this);
  9. set.addActionListener(this);
  10. quit.addActionListener(this);
  11. get_all.addActionListener(this);
  12. delete.addActionListener(this);

代码示例来源:origin: stackoverflow.com

  1. JButton addBtn = new JButton("+");
  2. addBtn.setBounds(x_pos, y_pos, 30, 25);
  3. addBtn.setBorder(new RoundedBorder(10)); //10 is the radius
  4. addBtn.setForeground(Color.BLUE);

代码示例来源:origin: FudanNLP/fnlp

  1. panel.add(jspOut);
  2. button=new JButton("发送");
  3. button.addActionListener(new ButtonListener());
  4. button.setBounds(width*4/5+sp, height*5/6+sp*2, width*1/5-sp*2, height*1/6);
  5. panel.add(button);

代码示例来源:origin: magefree/mage

  1. jButtonSort = new JButton();
  2. int w = getDlgParams().rect.width - 75;
  3. int h = getDlgParams().rect.height - 75;
  4. jButtonSort.setBounds(new Rectangle(w / 2 + 150, h - 30, 78, 22));
  5. jButtonSort.setText("Sort");
  6. jButtonSort.setVisible(false);

代码示例来源:origin: Slowpoke101/FTBLaunch

  1. public void addUpdateJREButton (final String webLink, String unlocMessage) {
  2. btnInstallJava.setText(I18N.getLocaleString(unlocMessage));
  3. btnInstallJava.addActionListener(new ActionListener() {
  4. @Override
  5. public void actionPerformed (ActionEvent arg0) {
  6. OSUtils.browse(webLink);
  7. }
  8. });
  9. btnInstallJava.setBounds(345, 210, 150, 28);
  10. fitterPane.add(btnInstallJava);
  11. }

代码示例来源:origin: nodebox/nodebox

  1. public InterruptibleProgressDialog(Frame owner, String title) {
  2. super(owner, title);
  3. setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
  4. setAlwaysOnTop(true);
  5. JButton cancelButton = new JButton("Cancel");
  6. cancelButton.setBounds(270, 50, 80, 32);
  7. getContentPane().add(cancelButton);
  8. cancelButton.addActionListener(new ActionListener() {
  9. public void actionPerformed(ActionEvent actionEvent) {
  10. if (thread != null)
  11. thread.interrupt();
  12. }
  13. });
  14. }

代码示例来源:origin: magefree/mage

  1. public static JXPanel getDescription(CardView card, int width, int height) {
  2. JXPanel descriptionPanel = new JXPanel();
  3. //descriptionPanel.setAlpha(.8f);
  4. descriptionPanel.setBounds(0, 0, width, height);
  5. descriptionPanel.setVisible(false);
  6. descriptionPanel.setLayout(null);
  7. //descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
  8. JButton j = new JButton("");
  9. j.setBounds(0, 0, width, height);
  10. j.setBackground(Color.black);
  11. j.setLayout(null);
  12. JLabel cardText = new JLabel();
  13. cardText.setBounds(5, 5, width - 10, height - 10);
  14. cardText.setForeground(Color.white);
  15. cardText.setFont(cardNameFont);
  16. cardText.setVerticalAlignment(SwingConstants.TOP);
  17. j.add(cardText);
  18. TextLines textLines = GuiDisplayUtil.getTextLinesfromCardView(card);
  19. cardText.setText(getRulefromCardView(card, textLines).toString());
  20. descriptionPanel.add(j);
  21. return descriptionPanel;
  22. }

代码示例来源:origin: stackoverflow.com

  1. JButton btnCalender = new JButton("Calendar", new ImageIcon(
  2. "./src/Calendar_0.jpg"));
  3. btnCalender.setBorder(BorderFactory.createEmptyBorder());
  4. btnCalender.setContentAreaFilled(false);
  5. btnCalender.setBounds(244, 177, 129, 36);
  6. btnCalender.addActionListener(new ActionListener() {
  7. public void actionPerformed(ActionEvent e) {
  8. }
  9. });
  10. frmOptions.getContentPane().add(btnCalender);
  11. frmOptions.setDefaultCloseOperation(3);
  12. frmOptions.pack();
  13. frmOptions.setLocationRelativeTo(null);
  14. frmOptions.setVisible(true);

代码示例来源:origin: magefree/mage

  1. image = ImageHelper.getImageFromResources("/info/cheat.png");
  2. resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
  3. cheat = new JButton();
  4. cheat.setIcon(new ImageIcon(resized));
  5. cheat.setToolTipText("Cheat button");
  6. cheat.addActionListener(e -> btnCheatActionPerformed(e));
  7. zonesPanel.add(commandZone);
  8. cheat.setBounds(28, 0, 25, 21);
  9. zonesPanel.add(cheat);
  10. experience.setOpaque(false);
  11. btnPlayer = new JButton();
  12. btnPlayer.setText("Player");
  13. btnPlayer.setVisible(false);
  14. btnPlayer.setToolTipText("Player");
  15. btnPlayer.addActionListener(e -> SessionHandler.sendPlayerUUID(gameId, playerId));

代码示例来源:origin: stackoverflow.com

  1. ...
  2. button.setBounds(100, 60, 100, 30);
  3. button.setToolTipText("A button component");
  4. JButton button2 = new JButton("Odd");
  5. button2.setBounds(100, 60, 100, 30);
  6. ...

代码示例来源:origin: stackoverflow.com

  1. int x = 340;
  2. for (char c = 'A'; c <= 'Z'; ++c, x += 10) {
  3. JButton button = new JButton(Character.toString(c));
  4. final char lower = Character.toLowercase(c);
  5. button.addActionListener(new ActionListener() {
  6. @Override public void actionPerformed(ActionEvent e) {
  7. game.checkGuess(lower);
  8. }
  9. });
  10. button.setBounds(x, 250, 5, 5);
  11. button.setVisible(true);
  12. this.add(button);
  13. }

代码示例来源:origin: stackoverflow.com

  1. //Create and add media control buttons
  2. JButton btnPlay = new JButton("Play");
  3. btnPlay.setBounds(10, 116, 89, 23);
  4. panel.add(btnPlay);
  5. JButton btnLoop = new JButton("Loop");
  6. btnLoop.setBounds(109, 116, 89, 23);
  7. panel.add(btnLoop);
  8. JButton btnStop = new JButton("Stop");
  9. btnStop.setBounds(208, 116, 89, 23);
  10. panel.add(btnStop);

代码示例来源:origin: stackoverflow.com

  1. ArrayList<JButton> buttons = new ArrayList<JButton>();
  2. public JButton buttons(int coord, int coord1, int number) {
  3. JButton box = new JButton("");
  4. box.setFont(new Font("Tahoma", Font.PLAIN, 60));
  5. box.setBounds(coord, coord1, 100, 100);
  6. contentPane.add(box);
  7. box.addActionListener(this);
  8. box.setActionCommand(Integer.toString(number));
  9. buttons.add(box);//Add it here
  10. return box;
  11. }

代码示例来源:origin: stackoverflow.com

  1. for (int i = 0; i < 1; i++) {
  2. for (int j = 0; j <1; j++) {
  3. JButton b = new JButton("button");
  4. b.setBounds(500, 500, 100, 20);
  5. this.add(b);
  6. }
  7. }
  8. this.repaint();
  9. this.validate()

代码示例来源:origin: stackoverflow.com

  1. JButton btnNewButton_1 = new JButton("New");
  2. btnNewButton_1.setBackground(Color.LIGHT_GRAY);
  3. btnNewButton_1.setBounds(236, 228, 89, 23);
  4. frame.getContentPane().add(btnNewButton_1);
  5. btnNewButton_1.addActionListener(new ActionListener() {
  6. public void actionPerformed(ActionEvent e) {
  7. //actions here
  8. }
  9. });

代码示例来源:origin: stackoverflow.com

  1. Rectangle cell = table.getCellRect(....);
  2. JButton button = new JButton(...);
  3. button.setBounds( cell );
  4. table.add( button );
  5. table.repaint();

代码示例来源:origin: lingfengsan/MillionHero

  1. /**
  2. *
  3. * @param panel 增加获取答案按钮
  4. */
  5. private static void addRunButton(JPanel panel) {
  6. final JButton runButton = new JButton("获取答案");
  7. runButton.setBounds(160, 170, 120, 25);
  8. panel.add(runButton);
  9. ActionListener listener = new ActionListener() {
  10. @Override
  11. public void actionPerformed(ActionEvent e) {
  12. try {
  13. String result = COMMON_PATTERN.run();
  14. System.out.println(result);
  15. resultTextArea.setText(result);
  16. } catch (UnsupportedEncodingException e1) {
  17. logger.error(e1.getMessage());
  18. }
  19. }
  20. };
  21. runButton.addActionListener(listener);
  22. }

代码示例来源:origin: stackoverflow.com

  1. JButton startButton = new JButton("Click Me To Start!");
  2. // startButton.setBounds(300, 50,140, 50 );
  3. startButton.setBounds(BUTTON_LOCATION_X
  4. , BUTTON_LOCATION_Y,
  5. BUTTON_SIZE_X,
  6. BUTTON_SIZE_Y );
  7. contentPane.add(startButton);

代码示例来源:origin: lingfengsan/MillionHero

  1. /**
  2. *
  3. * @param panel 增加设置完成按钮
  4. */
  5. private static void addSetFinishButton(JPanel panel) {
  6. final JButton setFinishButton = new JButton("设置完成");
  7. setFinishButton.setBounds(40, 170, 120, 25);
  8. panel.add(setFinishButton);
  9. ActionListener listener = new ActionListener() {
  10. @Override
  11. public void actionPerformed(ActionEvent e) {
  12. Config.setAdbPath(adbPathText.getText());
  13. Config.setPhotoPath(imagePathText.getText());
  14. try {
  15. Utils.storeConfig();
  16. } catch (IOException e1) {
  17. logger.error("存储配置信息失败");
  18. }
  19. Utils utils = new Utils(Config.getAdbPath(), Config.getPhotoPath());
  20. COMMON_PATTERN.setUtils(utils);
  21. COMMON_PATTERN.setPatterSelection(patternSelection);
  22. COMMON_PATTERN.setSearchSelection(searchSelection);
  23. }
  24. };
  25. setFinishButton.addActionListener(listener);
  26. }

相关文章

JButton类方法