📄 shufflefields.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 + -