GUI 在 java eclipse 中不显示
我的 GUI 窗口正在打开,但没有显示任何内容。 通过打印出我的 mainPanel 和 graphPanel,我可以推断它没有采用我的边框值。
我是 GUI 新手,有人可以帮助我吗?
public class MainGUI extends JFrame{
public static void main(String [] args){
JFrame frame = new MainGUI("Title");
frame.setVisible(true);
}
public MainGUI(String title){
super(title);
JPanel mainPanel = new JPanel();
JPanel graphPanel = new JPanel();
int w = 200;
int h = 200;
System.out.println(mainPanel);
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 45, 50, 20)); //Create panel Border
System.out.println(mainPanel);
graphPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
graphPanel.setLayout(new GridLayout(1, 1));
System.out.println(graphPanel);
....
....
My GUI window is opening but nothing is being displayed.
By printing out my mainPanel and graphPanel, I can deduce that it's not taking my border values.
I'm new to GUI, can someone help me out.
public class MainGUI extends JFrame{
public static void main(String [] args){
JFrame frame = new MainGUI("Title");
frame.setVisible(true);
}
public MainGUI(String title){
super(title);
JPanel mainPanel = new JPanel();
JPanel graphPanel = new JPanel();
int w = 200;
int h = 200;
System.out.println(mainPanel);
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 45, 50, 20)); //Create panel Border
System.out.println(mainPanel);
graphPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
graphPanel.setLayout(new GridLayout(1, 1));
System.out.println(graphPanel);
....
....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论