Jenkins
3 years ago
2 changed files with 80 additions and 8 deletions
@ -1,28 +1,100 @@ |
|||
package hauptmenue; |
|||
|
|||
import java.awt.Dimension; |
|||
import java.awt.event.ActionEvent; |
|||
import java.awt.event.ActionListener; |
|||
import java.awt.event.MouseAdapter; |
|||
import java.awt.event.MouseEvent; |
|||
|
|||
import javax.swing.JButton; |
|||
import javax.swing.JFrame; |
|||
|
|||
import Minesweeper.MinesweeperGame; |
|||
import TicTacToe.TicTacToeGame; |
|||
import solitaer.SolitaerGamePanel; |
|||
import solitaer.SolitaerMenue; |
|||
|
|||
public class GameWindow extends JFrame { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
private final SolitaerGamePanel gamePanel = new SolitaerGamePanel(); |
|||
|
|||
private SolitaerMenue smenue = new SolitaerMenue(gamePanel); |
|||
|
|||
public GameWindow() { |
|||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|||
gamePanel.setPreferredSize(new Dimension(1180, 780)); |
|||
this.setJMenuBar(smenue.getMenue()); |
|||
setSize(new Dimension(200, 125)); |
|||
setLayout(null); |
|||
|
|||
add(gamePanel); |
|||
pack(); |
|||
|
|||
|
|||
JButton soli = new JButton("Solitaer"); |
|||
JButton Tic = new JButton("TicTacToe"); |
|||
JButton Mine = new JButton("Minesweeper"); |
|||
|
|||
soli.addActionListener(new ActionListener() { |
|||
@Override |
|||
public void actionPerformed(ActionEvent e) { |
|||
soli.setVisible(false); |
|||
Tic.setVisible(false); |
|||
Mine.setVisible(false); |
|||
initSoli(); |
|||
} |
|||
}); |
|||
|
|||
Tic.addActionListener(new ActionListener() { |
|||
@Override |
|||
public void actionPerformed(ActionEvent e) { |
|||
soli.setVisible(false); |
|||
Tic.setVisible(false); |
|||
Mine.setVisible(false); |
|||
initTicTacToe(); |
|||
} |
|||
|
|||
}); |
|||
|
|||
Mine.addActionListener(new ActionListener() { |
|||
@Override |
|||
public void actionPerformed(ActionEvent e) { |
|||
soli.setVisible(false); |
|||
Tic.setVisible(false); |
|||
Mine.setVisible(false); |
|||
initMinesweeper(); |
|||
} |
|||
|
|||
|
|||
}); |
|||
soli.setBounds(0, 0, 200, 30); |
|||
Tic.setBounds(0, 30, 200, 30); |
|||
Mine.setBounds(0, 60, 200, 30); |
|||
add(soli); |
|||
add(Tic); |
|||
add(Mine); |
|||
|
|||
setVisible(true); |
|||
} |
|||
|
|||
private void initSoli() { |
|||
SolitaerGamePanel gamePanel = new SolitaerGamePanel(); |
|||
SolitaerMenue smenue = new SolitaerMenue(gamePanel); |
|||
gamePanel.setVisible(true); |
|||
gamePanel.setSize(new Dimension(1180, 780)); |
|||
setSize(new Dimension(1180, 780)); |
|||
//gamePanel.setPreferredSize(new Dimension(1180, 780)); |
|||
setJMenuBar(smenue.getMenue()); |
|||
add(gamePanel); |
|||
repaint(); |
|||
} |
|||
|
|||
public void initTicTacToe() { |
|||
TicTacToeGame ttt = new TicTacToeGame(); |
|||
setSize(ttt.width, ttt.height); |
|||
setLayout(null); |
|||
add(ttt); |
|||
} |
|||
|
|||
public void initMinesweeper() { |
|||
MinesweeperGame MsG = new MinesweeperGame(8,10); |
|||
setSize(MsG.WIDTH, MsG.HEIGTH); |
|||
setLayout(null); |
|||
add(MsG); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue