JAVA WindowBuilder 制作的简易粗暴的计算器,适合初学者。 package 计算器; import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.J Button; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.LayoutStyle.ComponentPlacement; public class 计算器5 extends JFrame { private JPanel contentPane; private JTextField textField; private double v1, v2, value; private char operator; private boolean reop = false; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { 计算器5 frame = new 计算器5(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } Button; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.LayoutStyle.ComponentPlacement; public class 计算器5 extends JFrame { private JPanel contentPane; private JTextField textField; private double v1, v2, value; private char operator; private boolean reop = false; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { 计算器5 frame = new 计算器5(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }