I have a Main.java
, here i would only start ( set visible true ) my JFrame
window.
But it only opens a little window without anything.
Then I would press the Highscorebutten, then a other JFrame
(highscore) should be shown.
What should I do?
(this isn't the full code)
Main
public class Main {
private static MyWindow window = null;
public static void main(String[] args) {
window = new MyWindow();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Frame sichtbar machen
window.setVisible(true);
}
FWindow
public class FWindow extends JFrame{
private JFrame Menue;
public FWindow() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
Menue = new JFrame();
Menue.setBounds(100, 100, 469, 741);
Menue.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Menue.getContentPane().setLayout(null);
JPanel pMenue = new JPanel();
pMenue.setLayout(null);
JLabel lblHighscore = new JLabel();
lblHighscore.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
Highscore highscore = new Highscore();
getContentPane().add(highscore);
System.out.println();
highscore.setVisible(true);
}
});
//........
Highscore
public class Highscore extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JTable table;
TableModel model;
public Highscore() {
table = new JTable(model);
table.setShowGrid(false);
table.setShowHorizontalLines(false);
table.setShowVerticalLines(false);
table.setForeground(Color.WHITE);
table.setBackground(new Color(113,197,208));
table.setFont(new Font("Comic Sans MS", Font.PLAIN, 30));
table.setRowHeight(40);
table.setAutoCreateRowSorter(true);
table.setModel(new DefaultTableModel(
new Object[][] {
//.....
},
new String[] {
"1", "2", "3"
}
){
});
.......