📄 interfacelab.java
字号:
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class InterfaceLab {
public static void main(String[] args){
final int SIZE = 375;
ShapeGenerator.ShapeType[] types = {
ShapeGenerator.ShapeType.LINE,
ShapeGenerator.ShapeType.CIRCLE,
ShapeGenerator.ShapeType.SQUARE
};
JFrame app = new JFrame("Interface Lab");
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ShapesPanel panel = new ShapesPanel(SIZE);
app.add( panel);
app.setSize(SIZE, SIZE);
app.setVisible(true);
Object[] possibleValues = { "Line", "Circle", "Square", "QUIT" };
while( true ) {
int selection = JOptionPane.showOptionDialog(null,
"What kind of shape do you want to use",
"Interface Lab",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, //do not use a custom Icon
possibleValues, //the titles of buttons
possibleValues[0]); //default button title
System.out.println(" " + selection);
if(selection > 2)
System.exit(0);
panel.createShapes( types[selection] );
panel.sortShapes1();
for(int num = 1; num <= panel.SHAPE_NUMBER; num++){
JOptionPane.showMessageDialog( null, "Erasing Shape: #" + num,
"Erasing Info Box",
JOptionPane.INFORMATION_MESSAGE );
panel.eraseShape( num );
}
panel.sortShapes2();
for(int num = 1; num <= panel.SHAPE_NUMBER; num++){
JOptionPane.showMessageDialog( null, "Showing Shape: #" + num,
"Showing Info Box",
JOptionPane.INFORMATION_MESSAGE );
panel.showShape( num );
}
}
} // end of main method
} // end of InterfaceLab class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -