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

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

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

JButton.setLocation介绍

暂无

代码示例

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

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

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

@Override
public void doLayout() {
  // Position transform and show source buttons
  buttonPanel.setLocation(cardXOffset, cardYOffset);
  buttonPanel.setSize(cardWidth, cardHeight);
  int x = cardWidth / 20;
  int y = cardHeight / 10;
  if (dayNightButton != null) {
    dayNightButton.setLocation(x, y);
    y += 25;
    y += 5;
  }
  if (showCopySourceButton != null) {
    showCopySourceButton.setLocation(x, y);
  }
}

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

private void setTypeIcon(BufferedImage bufferedImage, String toolTipText) {
  iconPanel = new JPanel();
  iconPanel.setLayout(null);
  iconPanel.setOpaque(false);
  add(iconPanel);
  typeButton = new JButton("");
  typeButton.setLocation(2, 2);
  typeButton.setSize(25, 25);
  iconPanel.setVisible(true);
  typeButton.setIcon(new ImageIcon(bufferedImage));
  if (toolTipText != null) {
    typeButton.setToolTipText(toolTipText);
  }
  iconPanel.add(typeButton);
}

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

public MageFloatPane() {
  UI.setHTMLEditorKit(this);
  setEditable(false);
  setBackground(Color.white);
  JButton jb = new JButton("Done");
  jb.setLocation(50, 50);
  jb.setSize(100, 50);
  add(jb);
}

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

private Random d = new Random();
private JButton button = new JButton("Button");

button.addMouseListener(new MouseAdapter(){
  @Override
  public void mouseEntered(MouseEvent e) {
     int a = d.nextInt(200);
     int b = d.nextInt(200);
     button.setLocation(a, b);
  }
});

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

private void initResetDefaultsButton() {
  JButton defaultsButton = initButton("Reset Default Colors (D)", SMALL_BUTTON_SIZE, 1);
  defaultsButton.setLocation(0, 0);
  resetToDefaultAction = new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      setDefaultColors();
    }
  };
  defaultsButton.addActionListener(resetToDefaultAction);
}

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

public void createButton(int x, int y, String s) {
  try {
    JButton btn1 = new JButton(s);
    jPanel1.add(btn1);
    btn1.setLocation(x, y);
    btn1.setSize(50, 50);
    btn1.setVisible(true);
  } catch (Exception e) {
    e.printStackTrace();
    System.out.println(e);
  }
}

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

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

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

public static JButton button(String name, int size1, int size2, int loc1, int loc2) {
  JButton button = new JButton(name);
  button.setSize(size1, size2);
  button.setLocation(loc1, loc2);
  return button;
}

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

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

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

private void initSwapColorsButton() {
  JButton swapButton = initButton("Swap Colors (X)", SMALL_BUTTON_SIZE, 1);
  swapButton.setLocation(SMALL_BUTTON_SIZE, 0);
  swapColorsAction = new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      swapColors();
    }
  };
  swapButton.addActionListener(swapColorsAction);
}

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

public class Testing {

    public static void main(String[] args) {
        JFrame frame = new JFrame("hi");

        for (int i = 0; i < 10; i++) {
            JButton a = new JButton();
            a.setSize(20,20);
            a.setLocation(20*i, 0);
            frame.getContentPane().add(a);

        }
        frame.setLayout(null);
        frame.pack();
        frame.setVisible(true);
    }

}

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

JButton scoreButton =new JButton("add");
scoreButton.setSize(100, 50);
scoreButton.setLocation(100,50);
scoreButton.setBackground(Color.red);
scoreButton.addActionListener(this);
MyPanel.add(scoreButton);

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

int buttonHeight = 10;
int buttonWidth = 10;
for (int i = 0; i < 10; i++) {
  JButton button = new Button("Button " + i);
  button.setSize(buttonWidth, buttonHeight);
  button.setLocation(10 + i * buttonWidth, 10);
  getContentPane().add(button);
}

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

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

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

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

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

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

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

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

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

@ScriptFunction
@Override
public void setLeft(int aValue) {
  if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
    MarginLayout.ajustLeft(this, aValue);
  }
  super.setLocation(aValue, getTop());
}

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

@ScriptFunction
@Override
public void setTop(int aValue) {
  if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
    MarginLayout.ajustTop(this, aValue);
  }
  super.setLocation(getLeft(), aValue);
}

相关文章

JButton类方法