📄 main.java
字号:
/*
* Main.java
*
* Created on 2007年11月20日, 下午7:26
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package exp4;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author Administrator
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new FrameInOut();
}
}
class closewindow extends WindowAdapter{
public void windowClosing(WindowEvent e)
{
Frame frm=(Frame)(e.getSource());
frm.dispose();
System.exit(0);
}
}
class FrameInOut extends Frame implements ActionListener{
Label prompt1,prompt2;
TextField input,output;
Button btn1,btn2;
FrameInOut(){
super("字符倒转");
prompt1=new Label("请输入字符串:");
prompt2=new Label(" 结果: ");
input=new TextField(10);
output=new TextField(10);
btn1=new Button("确定");
btn2=new Button("关闭");
setLayout(new FlowLayout());
add(prompt1);
add(input);
add(prompt2);
add(output);
add(btn1);
add(btn2);
addWindowListener(new closewindow());
btn1.addActionListener(this);
btn2.addActionListener(this);
setSize(230,150);
show();
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==btn1){
String s=input.getText();
int i=0;
String ss="";
for(int count=s.length()-1;count>=0;count--){
ss+=s.charAt(count);}
output.setText(ss);
}
else{
dispose();
System.exit(0);}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -