第一个:games.javaimportjava.awt.*;importjavax.swing.*;publicclassgames{publicvoidgo(){JFramewin=newJFrame("games");ContainercontentPane=win.getContentPane();contentPane.s...
第一个:games.java
import java.awt.*;
import javax.swing.*;
public class games
{
public void go()
{
JFrame win = new JFrame("games");
Container contentPane = win.getContentPane();
contentPane.setLayout(new GridLayout(5,1));
JLabel labOne = new JLabel("..大学2014级..学堂",JLabel.CENTER);
JLabel labTwo = new JLabel("计算机取向",JLabel.CENTER);
JLabel labThree = new JLabel("... 制作",JLabel.CENTER);
JLabel labFour = new JLabel("let's play a game!",JLabel.CENTER);
JButton queding = new JButton("start!");
contentPane.add(labOne);
contentPane.add(labTwo);
contentPane.add(labThree);
contentPane.add(labFour);
contentPane.add(queding);
win.setSize(200,200);
win.setVisible(true);
}
public static void main(String[]args)
{
games fe = new games();
fe.go();
}
}
第二个:Test.java
import javax.swing.JFrame;
import javax.swing.JOptionPane;
@SuppressWarnings("serial")
public class Test extends JFrame
{
public static void main(String[] args)
{
while(true)
{
String information = JOptionPane.showInputDialog("请输入您的名字:");
JOptionPane.showMessageDialog(null, "你刚才输入的是"+information);
}
}
}
展开