Menue Game Namen
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										24
									
								
								src/Tetris/Game.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/Tetris/Game.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
package Tetris;
 | 
			
		||||
 | 
			
		||||
import javax.swing.*;
 | 
			
		||||
 | 
			
		||||
public class Game {
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        Menue menue = new Menue();
 | 
			
		||||
 | 
			
		||||
        menue.getButton().addActionListener(new java.awt.event.ActionListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void actionPerformed(java.awt.event.ActionEvent evt) {
 | 
			
		||||
                String name = JOptionPane.showInputDialog(menue.getParent(),
 | 
			
		||||
                        "What is your name?", null);
 | 
			
		||||
                if(name == null){
 | 
			
		||||
                    name = "anon";
 | 
			
		||||
                }
 | 
			
		||||
                menue.getParent().setVisible(false);
 | 
			
		||||
                new GameGui(name);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        //String playername = menue.getName();
 | 
			
		||||
        //new GameGui(playername);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -8,8 +8,8 @@ public class GameGui {
 | 
			
		||||
    private JFrame frame;
 | 
			
		||||
 | 
			
		||||
    //Zhe Wang-Holkenbrink
 | 
			
		||||
    public GameGui(){
 | 
			
		||||
        frame = new JFrame("Tetris");
 | 
			
		||||
    public GameGui(String playername){
 | 
			
		||||
        frame = new JFrame("Tetris " + playername);
 | 
			
		||||
        JPanel panel = new JPanel();
 | 
			
		||||
        panel.setBorder(BorderFactory.createMatteBorder(500, 10, 10, 50,Color.black));
 | 
			
		||||
 | 
			
		||||
@@ -50,6 +50,6 @@ public class GameGui {
 | 
			
		||||
    }
 | 
			
		||||
    public static void main(String [] args)
 | 
			
		||||
    {
 | 
			
		||||
        new GameGui();
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,9 +7,42 @@ import java.awt.*;
 | 
			
		||||
 | 
			
		||||
public class Menue {
 | 
			
		||||
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    private JFrame parent;
 | 
			
		||||
 | 
			
		||||
    public JFrame getParent() {
 | 
			
		||||
        return parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setParent(JFrame parent) {
 | 
			
		||||
        this.parent = parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private JButton button;
 | 
			
		||||
 | 
			
		||||
    public JButton getButton() {
 | 
			
		||||
        return button;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setButton(JButton button) {
 | 
			
		||||
        this.button = button;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public Menue(){
 | 
			
		||||
        JFrame parent = new JFrame("Tetris Menü");
 | 
			
		||||
        JButton button = new JButton();
 | 
			
		||||
 | 
			
		||||
        parent = new JFrame("Tetris Menü");
 | 
			
		||||
        button = new JButton();
 | 
			
		||||
 | 
			
		||||
        button.setText("Namen Eingeben");
 | 
			
		||||
        button.setPreferredSize(new Dimension(400,500));
 | 
			
		||||
@@ -18,13 +51,6 @@ public class Menue {
 | 
			
		||||
        parent.pack();
 | 
			
		||||
        parent.setVisible(true);
 | 
			
		||||
 | 
			
		||||
        button.addActionListener(new java.awt.event.ActionListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void actionPerformed(java.awt.event.ActionEvent evt) {
 | 
			
		||||
                String name = JOptionPane.showInputDialog(parent,
 | 
			
		||||
                        "What is your name?", null);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    public static void main(final String[] args) {
 | 
			
		||||
        new Menue();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user