我正在嘗試創建一個用戶界面。在你把所有東西都搬到了私人空間,然後把我的JFrame
顯示爲空白。出於某種原因,我只能看到基本的灰色窗口,但在此之前,一切正常。不要在我的框架內看到任何東西
public class Aboutus_GUI extends JFrame {
private JPanel contentPane;
private JLabel join;
private JLabel Names;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Aboutus_GUI frame = new Aboutus_GUI();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
* @throws MalformedURLException
*/
public Aboutus_GUI() throws MalformedURLException {
setBackground(Color.WHITE);
setTitle("About Us");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 727, 651);
JPanel contentPane = new JPanel();
contentPane.setBackground(Color.WHITE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
join = new JLabel();
join.setIcon(new ImageIcon("src/GUI_final/about_us.jpg"));
join.setBounds(0, -267, 701, 770);
contentPane.add(join);
Names = new JLabel();
Names.setIcon(new ImageIcon("src/GUI_final/names.jpg"));
Names.setLocation(10, 276);
Names.setSize(887, 492);
contentPane.add(Names);
}
public JPanel getContentPane() {
return contentPane;
}
public void setContentPane(JPanel contentPane) {
this.contentPane = contentPane;
}
public JLabel getJoin() {
return join;
}
public void setJoin(JLabel join) {
this.join = join;
}
public JLabel getNames() {
return Names;
}
public void setNames(JLabel names) {
Names = names;
}
}
是您最近添加getContentPane方法的更改之一嗎?我問,因爲這覆蓋了JFrame類中的方法。這可能是問題所在。 – BPS