swing: 程序运行后只显示一个jframe,只有将窗口最小化再最大化后才会显示jframe上的内容,该怎么解决呢?
[b]问题补充:[/b]
能说得再具体点不?
[b]问题补充:[/b]
uiupdate是哪里的类?
[b]问题补充:[/b]
[code="java"]package print;
import java.awt.*;
import java.util.List;
import javax.swing.*;
public class MyFrame {
private static final int WIDTH = 700;
private static final int HEIGHT = 500;
JPanel mainpanel = null; //在框架上添加的主面板
JPanel downpanel = null; //在主面板的下面的一个面板
public static UpRightPanel rightPanel ;
public MyFrame(){
JFrame jf = new JFrame();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(WIDTH, HEIGHT);
jf.setVisible(true);
jf.setResizable(false);
//设置顶层框架居中显示
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenWidth = screenSize.width;
int screenHeight = screenSize.height;
int x = (screenWidth - WIDTH)/2;
int y = (screenHeight - HEIGHT)/2;
jf.setLocation(x, y);
GridLayout lay = new GridLayout(2,1);
//jf.setLayout(lay);
mainpanel = new JPanel();
mainpanel.setBackground(new Color(220,220,200));
jf.add(mainpanel);
mainpanel.setLayout(new FlowLayout(FlowLayout.LEFT));
UpLeftPanel upanel = new UpLeftPanel();
mainpanel.add(upanel);
UpCenterPanel centerPanel = new UpCenterPanel();
mainpanel.add(centerPanel);
UpRightPanel rightPanel = new UpRightPanel();
mainpanel.add(rightPanel);
DownPanel downPanel = new DownPanel();
mainpanel.add(downPanel);
}
public MyFrame(List stus){
JFrame jf = new JFrame();
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(WIDTH, HEIGHT);
jf.setVisible(true);
jf.setResizable(false);
//设置顶层框架居中显示
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenWidth = screenSize.width;
int screenHeight = screenSize.height;
int x = (screenWidth - WIDTH)/2;
int y = (screenHeight - HEIGHT)/2;
jf.setLocation(x, y);
GridLayout lay = new GridLayout(2,1);
//jf.setLayout(lay);
mainpanel = new JPanel();
mainpanel.setBackground(new Color(220,220,200));
jf.add(mainpanel);
mainpanel.setLayout(new FlowLayout(FlowLayout.LEFT));
//左上方的面板
UpLeftPanel upanel = new UpLeftPanel();
mainpanel.add(upanel);
//中上方的面板
UpCenterPanel centerPanel = new UpCenterPanel(stus);
mainpanel.add(centerPanel);
//右上方的面板类
rightPanel = new UpRightPanel();
mainpanel.add(rightPanel);
DownPanel downPanel = new DownPanel();
mainpanel.add(downPanel);
}
}
[/code]