有人可以解释当 JFrame.setvisible 设置为 true 时我的 JTabbedPane 不显示的类我做错了什么吗?
是的,程序的main方法(这里就不放了)使用事件调度线程来启动ArionGUI。
这是我的 JFrame 代码:
import javax.swing.*;
public class ArionGUI extends JFrame {
public ArionGUI() {
// Set up GUI frame for Arion
JFrame arionFrame = new JFrame("Arion v 0.01");
// Add Arion Tabbed Pane
arionFrame.getContentPane().add(new ArionTabbedPane());
// Terminate the application when closed
arionFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
// Set the size of the frame
arionFrame.setSize(500, 500);
// Center window
arionFrame.setLocationRelativeTo(null);
// Prevent user from resizing window
arionFrame.setResizable(false);
// Make Arion frame visible on screen
arionFrame.setVisible(true);
}
}
这是我的 JTabbedPane 代码:
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JComponent;
public class ArionTabbedPane extends JComponent {
JTabbedPane arionTabbedPane;
public ArionTabbedPane() {
arionTabbedPane = new JTabbedPane(JTabbedPane.TOP);
arionTabbedPane.addTab("Characters", new JLabel("This is the characterz tab"));
arionTabbedPane.addTab("Miscellaneous", new JLabel("This is the miscellaneous tab"));
add(arionTabbedPane);
}
}