mirror of
https://github.com/lov3b/Schack.git
synced 2024-11-10 07:00:11 +01:00
Inital meny med local IP dialog
This commit is contained in:
parent
d9311a38db
commit
623310de3e
@ -1,7 +1,18 @@
|
||||
package schack;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -16,9 +27,46 @@ public class Schack extends JFrame {
|
||||
setAlwaysOnTop(true);
|
||||
setResizable(false);
|
||||
setContentPane(new Board());
|
||||
|
||||
// Create menu
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
JMenu gameMenu = new JMenu("Game");
|
||||
JMenu connectMenu = new JMenu("Connect");
|
||||
JMenuItem connectToOpponent = new JMenuItem("Connect to opponent");
|
||||
JMenuItem showLocalIP = new JMenuItem("Show IP");
|
||||
JMenuItem askForRemi = new JMenuItem("Ask for remi");
|
||||
JMenuItem surrender = new JMenuItem("Surrender");
|
||||
|
||||
// Actions
|
||||
connectToOpponent.addActionListener((ActionEvent ae) -> {
|
||||
System.out.println("Connecting (TODO)");
|
||||
});
|
||||
showLocalIP.addActionListener((ActionEvent ae) -> {
|
||||
try {
|
||||
String localIp = InetAddress.getLocalHost().toString();
|
||||
JOptionPane.showMessageDialog(this, "Local IP: " + localIp);
|
||||
} catch (UnknownHostException ex) {
|
||||
JOptionPane.showMessageDialog(this, "Could not get local IP");
|
||||
}
|
||||
});
|
||||
askForRemi.addActionListener((ActionEvent ae) -> {
|
||||
System.out.println("I BEG FOR LE MERCY! (TODO)");
|
||||
});
|
||||
surrender.addActionListener((ActionEvent ae) -> {
|
||||
System.out.println("I'M FRENCH! (TODO)");
|
||||
});
|
||||
|
||||
// Add the menu stuff
|
||||
setJMenuBar(menuBar);
|
||||
menuBar.add(gameMenu);
|
||||
menuBar.add(connectMenu);
|
||||
connectMenu.add(connectToOpponent);
|
||||
connectMenu.add(showLocalIP);
|
||||
gameMenu.add(askForRemi);
|
||||
gameMenu.add(surrender);
|
||||
pack();
|
||||
setVisible(true);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user