www.pudn.com > fanzhuanzifuchuan.rar > test1.java, change:2005-12-27,size:2019b


//BorderLayoutTest.java 
 
import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 
import javax.swing.border.*; 
import javax.swing.event.*; 
 
public class test1 
{   
public static void main(String[] args) 
{   
    cloneFrame frame = new cloneFrame(); 
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    frame.show(); 
} 
} 
 
class cloneFrame extends JFrame 
{ 
public cloneFrame() 
{ 
    setTitle("机试程序"); 
    setSize(600, 400); 
   
    JPanel buttonPanel = new JPanel(); 
    buttonPanel.setBackground(new Color(56,43,85)); 
          Button1 = new JButton("点击复制反转字符串"); 
     Button1.addActionListener(new turnListener()); 
     buttonPanel.add(Button1); 
 
    JPanel textPanel = new JPanel(); 
      textPanel.setBackground(new Color(100,100,100)); 
 
   
     field1 = new JTextField("姓名:老孙;学号:2004132028", 20); 
     field2 = new JTextField("反转", 20); 
     field2.setEditable(false); 
     textPanel.add(field1); 
     textPanel.add(field2); 
    
     JPanel tuPanel = new JPanel(); 
     JLabel label = new JLabel(new ImageIcon("006.gif")); 
     tuPanel.add(label); 
     tuPanel.setBackground(new Color(100,100,100)); 
   
    Container contentPane = getContentPane(); 
    contentPane.add(buttonPanel, BorderLayout.SOUTH); 
    contentPane.add(textPanel, BorderLayout.NORTH); 
    contentPane.add(tuPanel, BorderLayout.CENTER); 
    contentPane.setBackground(new Color(100,100,100)); 
} 
 
 
private class turnListener 
    implements ActionListener 
{ 
    public void actionPerformed(ActionEvent event) 
    { 
     String gets = field1.getText(); 
    
      int i = gets.length(); 
          StringBuffer buffer = new StringBuffer(i); 
          for(int j=i-1;j>=0;j--) 
          { 
              buffer.append(gets.charAt(j)); 
          } 
         
          String gets2 = buffer.toString(); 
          field2.setText(gets2); 
    
   
    } 
} 
 
      private JButton Button1; 
private JTextField field1; 
private JTextField field2; 
}