⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interfacelab.java

📁 能够画线条、圆和长方形的Java程序
💻 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 + -