重置按钮怎么写

1. jbuilder里实现重置按钮怎么写代码 //关键代码:Java做图形很麻烦,很多东西都要自己手动写 public void jButton1_actionPerformed(ActionEvent e) { txt1.setText("您好");//设置文本框2 txt2.setText("");//设置文本框1 RadMan.setSelected(true);//设置单选按钮 cnkRead.setSelected(true);//设置复选框 cbo1.setSelectedIndex(0);//设置下拉列表框 cnkRead.setSelected(false);//设置复选框 cnkSning.setSelected(false);//设置复选框 }///////全部代码 Frame1.java package untitled1; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import java.awt.*; import javax.swing.JCheckBox; import javax.swing.JRadioButton; import javax.swing.JComboBox; import javax.swing.JButton; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; public class Frame1 extends JFrame { JPanel contentPane; JTextField txt1 = new JTextField(); JTextField txt2 = new JTextField(); JCheckBox cnkSning = new JCheckBox(); JRadioButton RadMan = new JRadioButton(); JComboBox cbo1 = new JComboBox(); JButton jButton1 = new JButton(); JRadioButton RadWoMan = new JRadioButton(); JCheckBox cnkRead = new JCheckBox(); ButtonGroup buttonGroup1 = new ButtonGroup(); ButtonGroup buttonGroup2 = new ButtonGroup(); public Frame1() { try { setDefaultCloseOperation(EXIT_ON_CLOSE); jbInit(); } catch (Exception exception) { exception.printStackTrace(); } } /** * Component initialization. * * @throws java.lang.Exception */ private void jbInit() throws Exception { contentPane = (JPanel) getContentPane(); contentPane.setLayout(null); setSize(new Dimension(400, 300)); setTitle("Frame Title"); txt1.setText("您好"); txt1.setBounds(new Rectangle(28, 20, 350, 25)); txt2.setText(""); txt2.setBounds(new Rectangle(29, 63, 345, 24)); cnkSning.setText("唱歌"); cnkSning.setBounds(new Rectangle(172, 134, 84, 25)); RadMan.setText(" 男"); RadMan.setSelected(true); RadMan.setBounds(new Rectangle(31, 105, 92, 27)); cbo1.setBounds(new Rectangle(32, 179, 346, 26)); jButton1.setBounds(new Rectangle(31, 222, 344, 31)); jButton1.setText("jButton1"); jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this)); RadWoMan.setText("女"); RadWoMan.setBounds(new Rectangle(35, 142, 79, 19)); cnkRead.setText("阅读"); cnkRead.setBounds(new Rectangle(172, 105, 84, 25)); contentPane.add(txt1, null); contentPane.add(txt2); contentPane.add(RadMan); contentPane.add(jButton1); contentPane.add(cbo1); contentPane.add(RadWoMan); contentPane.add(cnkRead); contentPane.add(cnkSning); cbo1.addItem("初中"); cbo1.addItem("高中"); cbo1.addItem("大学"); buttonGroup1.add(RadMan); buttonGroup1.add(RadWoMan); } //重置事件监听方法,点击重置所有项 public void jButton1_actionPerformed(ActionEvent e) { txt1.setText("您好");//设置文本框2 txt2.setText("");//设置文本框1 RadMan.setSelected(true);//设置单选按钮 cnkRead.setSelected(true);//设置复选框 cbo1.setSelectedIndex(0);//设置下拉列表框 cnkRead.setSelected(false);//设置复选框 cnkSning.setSelected(false);//设置复选框 } public static void main(String[] arge){ (new Frame1()).show();//弹出窗体 } } class Frame1_jButton1_actionAdapter implements ActionListener { private Frame1 adaptee; Frame1_jButton1_actionAdapter(Frame1 adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); } } 。
2. c语言编写程序中重置的按钮要怎么设置 Windows 窗体程序是基于消息机制的,所有控件,它的本质都是一个窗体,都是使用 CreateWindows 函数来创建,不过类名,则需要指定为系统预先注册的控件类,比如,你要创建一个按钮控件,就要这样子 CreateWindows( "BUTTON","按钮标题" ),CreateWindows 这个函数你应该用了不少了吧,其余的参数可以参考 MSDN,但是类名我们指定了 “BUTTON”,说明我们要创建一个按钮,每个按钮都有一个唯一的 ID,通过你的消息处理函数,可以知道哪个按钮发生了什么事件,详细讲的话,非常多,你可以参考 MSDN,或者《Windows 程序设计》这本书。