001: package net.xoetrope.samples.counterexample.ide;
002:
003: import java.awt.Color;
004: import java.awt.Dimension;
005: import java.awt.Panel;
006: import java.awt.Rectangle;
007: import java.awt.SystemColor;
008: import java.awt.event.ActionEvent;
009: import javax.swing.BorderFactory;
010: import javax.swing.ImageIcon;
011: import javax.swing.JButton;
012: import javax.swing.JLabel;
013: import javax.swing.JPanel;
014: import javax.swing.JScrollPane;
015: import javax.swing.JTextArea;
016: import javax.swing.JTextField;
017:
018: public class BoilerPlate extends Panel {
019: JLabel jLabel1 = new JLabel();
020: JPanel jPanel1 = new JPanel();
021: JPanel jPanel2 = new JPanel();
022: JPanel jPanel3 = new JPanel();
023: JButton okBtn = new JButton();
024: JButton cancelBtn = new JButton();
025: JTextField WidthEdit = new JTextField();
026: JLabel jLabel2 = new JLabel();
027: JTextField HeightEdit = new JTextField();
028: JButton jButton1 = new JButton();
029: JLabel jLabel3 = new JLabel();
030: JLabel jLabel4 = new JLabel();
031: JLabel AreaText = new JLabel();
032: JTextArea jTextArea1 = new JTextArea();
033: ImageIcon imageIcon1 = new ImageIcon();
034: JScrollPane jScrollPane1 = new JScrollPane();
035:
036: public BoilerPlate() {
037: try {
038: jbInit();
039: } catch (Exception e) {
040: e.printStackTrace();
041: }
042: }
043:
044: private void jbInit() throws Exception {
045: jLabel1.setFont(new java.awt.Font("SansSerif", 1, 24));
046: jLabel1.setForeground(Color.red);
047: jLabel1.setText("Area Calculator");
048: jLabel1.setBounds(new Rectangle(12, 22, 213, 23));
049: this .setBackground(Color.white);
050: this .setLayout(null);
051: jPanel1.setBackground(Color.white);
052: jPanel1.setBorder(BorderFactory.createEtchedBorder());
053: jPanel1.setBounds(new Rectangle(12, 68, 228, 303));
054: jPanel1.setLayout(null);
055: jPanel2.setBackground(Color.white);
056: jPanel2.setBorder(BorderFactory.createEtchedBorder());
057: jPanel2.setBounds(new Rectangle(248, 67, 233, 303));
058: jPanel2.setLayout(null);
059: jPanel3.setBackground(Color.white);
060: jPanel3.setBorder(BorderFactory.createLineBorder(Color.black));
061: jPanel3.setBounds(new Rectangle(12, 378, 470, 47));
062: jPanel3.setLayout(null);
063: okBtn.setBackground(SystemColor.control);
064: okBtn.setBounds(new Rectangle(336, 11, 49, 25));
065: okBtn.setText("OK");
066: okBtn.addActionListener(new BoilerPlate_okBtn_actionAdapter(
067: this ));
068: cancelBtn.setBackground(SystemColor.control);
069: cancelBtn.setBounds(new Rectangle(392, 11, 67, 25));
070: cancelBtn.setText("Cancel");
071: cancelBtn
072: .addActionListener(new BoilerPlate_cancelBtn_actionAdapter(
073: this ));
074: WidthEdit.setText("10");
075: WidthEdit.setBounds(new Rectangle(160, 180, 57, 21));
076: jLabel2.setText("Height");
077: jLabel2.setBounds(new Rectangle(27, 212, 34, 15));
078: HeightEdit.setText("10");
079: HeightEdit.setBounds(new Rectangle(160, 205, 57, 21));
080: jButton1.setBounds(new Rectangle(114, 230, 103, 25));
081: jButton1.setText("Calculate");
082: jButton1
083: .addActionListener(new BoilerPlate_jButton1_actionAdapter(
084: this ));
085: jLabel3.setText("Width");
086: jLabel3.setBounds(new Rectangle(27, 190, 34, 15));
087: jLabel4.setText("Area");
088: jLabel4.setBounds(new Rectangle(27, 269, 34, 15));
089: AreaText.setBackground(Color.white);
090: AreaText.setForeground(Color.red);
091: AreaText.setText("100");
092: AreaText.setBounds(new Rectangle(183, 264, 34, 15));
093: jTextArea1.setFont(new java.awt.Font("SansSerif", 0, 16));
094: jTextArea1.setForeground(new Color(0, 0, 176));
095: jTextArea1
096: .setMaximumSize(new Dimension(2147483647, 2147483647));
097: jTextArea1.setPreferredSize(new Dimension(60, 170));
098: jTextArea1
099: .setText("Once upon a time there was a simple programmer who wished to calculate "
100: + "the area of a room, but being a very slow mathematician he decide "
101: + "to create a calculator. Here is what he did.");
102: jTextArea1.setColumns(20);
103: jTextArea1.setLineWrap(true);
104: jTextArea1.setRows(10);
105: jTextArea1.setWrapStyleWord(true);
106: jTextArea1.setBounds(new Rectangle(8, 5, 208, 291));
107: jScrollPane1.getViewport().setBackground(Color.pink);
108: jScrollPane1.setBounds(new Rectangle(10, 8, 209, 152));
109: this .add(jPanel1, null);
110: jPanel1.add(jTextArea1, null);
111: this .add(jPanel2, null);
112: this .add(jPanel3, null);
113: jPanel3.add(cancelBtn, null);
114: jPanel3.add(okBtn, null);
115: this .add(jLabel1, null);
116: jPanel2.add(AreaText, null);
117: jPanel2.add(jLabel4, null);
118: jPanel2.add(jButton1, null);
119: jPanel2.add(WidthEdit, null);
120: jPanel2.add(HeightEdit, null);
121: jPanel2.add(jLabel3, null);
122: jPanel2.add(jLabel2, null);
123: jPanel2.add(jScrollPane1, null);
124: }
125:
126: void jButton1_actionPerformed(ActionEvent e) {
127: int width = Integer.parseInt(WidthEdit.getText());
128: int height = Integer.parseInt(HeightEdit.getText());
129:
130: AreaText.setText(Integer.toString(width * height));
131: }
132:
133: void cancelBtn_actionPerformed(ActionEvent e) {
134: WidthEdit.setText("10");
135: HeightEdit.setText("10");
136: }
137:
138: void okBtn_actionPerformed(ActionEvent e) {
139: System.exit(0);
140: }
141:
142: }
143:
144: class BoilerPlate_jButton1_actionAdapter implements
145: java.awt.event.ActionListener {
146: BoilerPlate adaptee;
147:
148: BoilerPlate_jButton1_actionAdapter(BoilerPlate adaptee) {
149: this .adaptee = adaptee;
150: }
151:
152: public void actionPerformed(ActionEvent e) {
153: adaptee.jButton1_actionPerformed(e);
154: }
155: }
156:
157: class BoilerPlate_cancelBtn_actionAdapter implements
158: java.awt.event.ActionListener {
159: BoilerPlate adaptee;
160:
161: BoilerPlate_cancelBtn_actionAdapter(BoilerPlate adaptee) {
162: this .adaptee = adaptee;
163: }
164:
165: public void actionPerformed(ActionEvent e) {
166: adaptee.cancelBtn_actionPerformed(e);
167: }
168: }
169:
170: class BoilerPlate_okBtn_actionAdapter implements
171: java.awt.event.ActionListener {
172: BoilerPlate adaptee;
173:
174: BoilerPlate_okBtn_actionAdapter(BoilerPlate adaptee) {
175: this .adaptee = adaptee;
176: }
177:
178: public void actionPerformed(ActionEvent e) {
179: adaptee.okBtn_actionPerformed(e);
180: }
181: }
|