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

📄 shufflefields.java

📁 Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套 代码
💻 JAVA
字号:
import javax.swing.*;import java.awt.*;public class ShuffleFields {	private TextField topField, midField, bottomField;	/**	post:	topField, midField and bottomField are instantiated 	 *			and added to f 	 */	public ShuffleFields( JFrame f )   {		Label directions;		directions = new Label("Please type in the text fields.");		directions.setBounds(50, 100, 500, 30);		directions.setForeground(Color.blue);		f.add(directions);		topField = new TextField();		topField.setBounds(250, 150, 100, 30);		topField.repaint();		f.add(topField, 0);		midField = new TextField();		midField.setBounds(250, 200, 100, 30);		midField.repaint();		f.add(midField, 0);		bottomField = new TextField();		bottomField.setBounds(250, 250, 100, 30);		bottomField.repaint();		f.add(bottomField, 0);	}	/** post:	topField.getText() == midField.getText()@pre	 *			and  midField.getText() == bottomField.getText()@pre	 *			and  bottomField.getText() == topField.getText()@pre 	 */	public void rotateUp()   {		String topFieldAtPre = topField.getText();		topField.setText( midField.getText() );		midField.setText( bottomField.getText() );		bottomField.setText( topFieldAtPre );	}		/** post:	topField.getText() == midField.getText()@pre	 *			and  bottomField.getText() == midField.getText()@pre 	 */	public void copyMiddle()   {		topField.setText( midField.getText() );		bottomField.setText( midField.getText() );	}		/** post:	bottomField.getText() == midField.getText()@pre	 *			and  midField.getText() == topField.getText()@pre	 *			and  topField.getText() == bottomField.getText()@pre 	 */	public void rotateDown()   {		String bottomFieldAtPre;		bottomFieldAtPre = bottomField.getText();		bottomField.setText( midField.getText() );		midField.setText( topField.getText() );		topField.setText( bottomFieldAtPre );	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -