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

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

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

JButton.setLocation介绍

暂无

代码示例

代码示例来源:origin: kiegroup/optaplanner

  1. panelWidth = x + taskButton.getWidth();
  2. taskButton.setLocation(x, y);
  3. add(taskButton);

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

  1. @Override
  2. public void doLayout() {
  3. // Position transform and show source buttons
  4. buttonPanel.setLocation(cardXOffset, cardYOffset);
  5. buttonPanel.setSize(cardWidth, cardHeight);
  6. int x = cardWidth / 20;
  7. int y = cardHeight / 10;
  8. if (dayNightButton != null) {
  9. dayNightButton.setLocation(x, y);
  10. y += 25;
  11. y += 5;
  12. }
  13. if (showCopySourceButton != null) {
  14. showCopySourceButton.setLocation(x, y);
  15. }
  16. }

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

  1. private void setTypeIcon(BufferedImage bufferedImage, String toolTipText) {
  2. iconPanel = new JPanel();
  3. iconPanel.setLayout(null);
  4. iconPanel.setOpaque(false);
  5. add(iconPanel);
  6. typeButton = new JButton("");
  7. typeButton.setLocation(2, 2);
  8. typeButton.setSize(25, 25);
  9. iconPanel.setVisible(true);
  10. typeButton.setIcon(new ImageIcon(bufferedImage));
  11. if (toolTipText != null) {
  12. typeButton.setToolTipText(toolTipText);
  13. }
  14. iconPanel.add(typeButton);
  15. }

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

  1. public MageFloatPane() {
  2. UI.setHTMLEditorKit(this);
  3. setEditable(false);
  4. setBackground(Color.white);
  5. JButton jb = new JButton("Done");
  6. jb.setLocation(50, 50);
  7. jb.setSize(100, 50);
  8. add(jb);
  9. }

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

  1. private Random d = new Random();
  2. private JButton button = new JButton("Button");
  3. button.addMouseListener(new MouseAdapter(){
  4. @Override
  5. public void mouseEntered(MouseEvent e) {
  6. int a = d.nextInt(200);
  7. int b = d.nextInt(200);
  8. button.setLocation(a, b);
  9. }
  10. });

代码示例来源:origin: lbalazscs/Pixelitor

  1. private void initResetDefaultsButton() {
  2. JButton defaultsButton = initButton("Reset Default Colors (D)", SMALL_BUTTON_SIZE, 1);
  3. defaultsButton.setLocation(0, 0);
  4. resetToDefaultAction = new AbstractAction() {
  5. @Override
  6. public void actionPerformed(ActionEvent e) {
  7. setDefaultColors();
  8. }
  9. };
  10. defaultsButton.addActionListener(resetToDefaultAction);
  11. }

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

  1. public void createButton(int x, int y, String s) {
  2. try {
  3. JButton btn1 = new JButton(s);
  4. jPanel1.add(btn1);
  5. btn1.setLocation(x, y);
  6. btn1.setSize(50, 50);
  7. btn1.setVisible(true);
  8. } catch (Exception e) {
  9. e.printStackTrace();
  10. System.out.println(e);
  11. }
  12. }

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

  1. public static JButton button(String name, int size1, int size2, int loc1, int loc2) {
  2. JButton l=new JButton(name);
  3. l.setSize(size1, size2);
  4. l.setLocation(loc1, loc2);
  5. return l;
  6. }

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

  1. public static JButton button(String name, int size1, int size2, int loc1, int loc2) {
  2. JButton button = new JButton(name);
  3. button.setSize(size1, size2);
  4. button.setLocation(loc1, loc2);
  5. return button;
  6. }

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

  1. JFrame frame = new JFrame();
  2. JPanel menuPanel = new JPanel();
  3. JButton Button1 = new JButton("<BUTTON NAME 1>");
  4. Button1.setSize(80, 30);
  5. Button1.setLocation(4, 4);
  6. JButton Button2 = new JButton("<BUTTON NAME 2>");
  7. Button2.setSize(80, 30);
  8. Button2.setLocation(90, 4);

代码示例来源:origin: lbalazscs/Pixelitor

  1. private void initSwapColorsButton() {
  2. JButton swapButton = initButton("Swap Colors (X)", SMALL_BUTTON_SIZE, 1);
  3. swapButton.setLocation(SMALL_BUTTON_SIZE, 0);
  4. swapColorsAction = new AbstractAction() {
  5. @Override
  6. public void actionPerformed(ActionEvent e) {
  7. swapColors();
  8. }
  9. };
  10. swapButton.addActionListener(swapColorsAction);
  11. }

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

  1. public class Testing {
  2. public static void main(String[] args) {
  3. JFrame frame = new JFrame("hi");
  4. for (int i = 0; i < 10; i++) {
  5. JButton a = new JButton();
  6. a.setSize(20,20);
  7. a.setLocation(20*i, 0);
  8. frame.getContentPane().add(a);
  9. }
  10. frame.setLayout(null);
  11. frame.pack();
  12. frame.setVisible(true);
  13. }
  14. }

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

  1. JButton scoreButton =new JButton("add");
  2. scoreButton.setSize(100, 50);
  3. scoreButton.setLocation(100,50);
  4. scoreButton.setBackground(Color.red);
  5. scoreButton.addActionListener(this);
  6. MyPanel.add(scoreButton);

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

  1. int buttonHeight = 10;
  2. int buttonWidth = 10;
  3. for (int i = 0; i < 10; i++) {
  4. JButton button = new Button("Button " + i);
  5. button.setSize(buttonWidth, buttonHeight);
  6. button.setLocation(10 + i * buttonWidth, 10);
  7. getContentPane().add(button);
  8. }

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

  1. JButton j=new JButton("START");
  2. j.setSize(100,50);
  3. j.setLocation(imageLabel.getWidth()/2-j.getWidth()/2, imageLabel.getHeight()/2-j.getHeight()/2);
  4. //then add Button into imageLabel
  5. imageLabel.add(j);

代码示例来源:origin: lbalazscs/Pixelitor

  1. private void initFGButton() {
  2. fgButton = initButton("Set Foreground Color", BIG_BUTTON_SIZE, 2);
  3. fgButton.addActionListener(e -> fgButtonPressed());
  4. fgButton.setLocation(0, SMALL_BUTTON_VERTICAL_SPACE);
  5. fgButton.setComponentPopupMenu(createPopupMenu(true));
  6. }

代码示例来源:origin: lbalazscs/Pixelitor

  1. private void initBGButton() {
  2. bgButton = initButton("Set Background Color", BIG_BUTTON_SIZE, 1);
  3. bgButton.addActionListener(e -> bgButtonPressed());
  4. bgButton.setLocation(BIG_BUTTON_SIZE / 2, SMALL_BUTTON_VERTICAL_SPACE + BIG_BUTTON_SIZE / 2);
  5. bgButton.setComponentPopupMenu(createPopupMenu(false));
  6. }

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

  1. private void initButton(String name, int y, Class<? extends Action> actionClass) {
  2. ImageIcon icon = ModelerUtil.buildIcon("welcome/welcome-screen-"+name+"-btn.png");
  3. ImageIcon hoverIcon = ModelerUtil.buildIcon("welcome/welcome-screen-"+name+"-btn-hover.png");
  4. JButton button = createButton(icon, hoverIcon);
  5. button.setLocation(24, y); // 24px - button left & right padding
  6. button.addActionListener(Application
  7. .getInstance()
  8. .getActionManager()
  9. .getAction(actionClass));
  10. buttonsPanel.add(button);
  11. }

代码示例来源:origin: com.eas.platypus/platypus-js-forms

  1. @ScriptFunction
  2. @Override
  3. public void setLeft(int aValue) {
  4. if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
  5. MarginLayout.ajustLeft(this, aValue);
  6. }
  7. super.setLocation(aValue, getTop());
  8. }

代码示例来源:origin: com.eas.platypus/platypus-js-forms

  1. @ScriptFunction
  2. @Override
  3. public void setTop(int aValue) {
  4. if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
  5. MarginLayout.ajustTop(this, aValue);
  6. }
  7. super.setLocation(getLeft(), aValue);
  8. }

相关文章

JButton类方法