java setBounds 不能改变JRadioButton的位置大小,求指点
不论我setBounds()里面的参数怎么改,出来的单选框总是没有变化,怎么回事呢?求指点importjava.awt.Dimension;importjava.awt....
不论我 setBounds()里面的参数怎么改,出来的单选框总是没有变化,怎么回事呢?
求指点
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class landWindow extends JFrame{
JRadioButton adminButton=new JRadioButton("管理员");
JRadioButton keFu1Button=new JRadioButton("客服1");
JRadioButton keFu2Button=new JRadioButton("客服2");
JPanel JPLand;
landWindow(){
setTitle("登录窗口");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,400);
setVisible(true);
adminButton.setBounds(50, 80, 100, 100);
keFu1Button.setBounds(100, 80, 100, 100);
keFu2Button.setBounds(150, 80, 100, 100);
ButtonGroup land=new ButtonGroup();
land.add(adminButton);
land.add(keFu1Button);
land.add(keFu2Button);
JPLand=new JPanel();
this.add(JPLand);
JPLand.add(adminButton);
JPLand.add(keFu1Button);
JPLand.add(keFu2Button);
Toolkit toolkit=Toolkit.getDefaultToolkit();
Dimension screen=toolkit.getScreenSize();
int x=screen.width-this.getWidth()>>1;
int y=((screen.height-this.getHeight())>>1)-32;
this.setLocation(x, y);
}
public static void main(String[] args) {
landWindow landWindow=new landWindow();
}
} 展开
求指点
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class landWindow extends JFrame{
JRadioButton adminButton=new JRadioButton("管理员");
JRadioButton keFu1Button=new JRadioButton("客服1");
JRadioButton keFu2Button=new JRadioButton("客服2");
JPanel JPLand;
landWindow(){
setTitle("登录窗口");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,400);
setVisible(true);
adminButton.setBounds(50, 80, 100, 100);
keFu1Button.setBounds(100, 80, 100, 100);
keFu2Button.setBounds(150, 80, 100, 100);
ButtonGroup land=new ButtonGroup();
land.add(adminButton);
land.add(keFu1Button);
land.add(keFu2Button);
JPLand=new JPanel();
this.add(JPLand);
JPLand.add(adminButton);
JPLand.add(keFu1Button);
JPLand.add(keFu2Button);
Toolkit toolkit=Toolkit.getDefaultToolkit();
Dimension screen=toolkit.getScreenSize();
int x=screen.width-this.getWidth()>>1;
int y=((screen.height-this.getHeight())>>1)-32;
this.setLocation(x, y);
}
public static void main(String[] args) {
landWindow landWindow=new landWindow();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询