PageRenderTime 164ms CodeModel.GetById 24ms app.highlight 40ms RepoModel.GetById 95ms app.codeStats 0ms

/src/mpv5/ui/frames/MPCalculator.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 306 lines | 234 code | 43 blank | 29 comment | 3 complexity | b44f7b3bdfc94f66d5cf3e252cb3163a MD5 | raw file
  1/*
  2 *  This file is part of YaBS.
  3 *
  4 *  YaBS is free software: you can redistribute it and/or modify
  5 *  it under the terms of the GNU General Public License as published by
  6 *  the Free Software Foundation, either version 3 of the License, or
  7 *  (at your option) any later version.
  8 *
  9 *  YaBS is distributed in the hope that it will be useful,
 10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *  GNU General Public License for more details.
 13 *
 14 *  You should have received a copy of the GNU General Public License
 15 *  along with YaBS.  If not, see <http://www.gnu.org/licenses/>.
 16 */
 17
 18package mpv5.ui.frames;
 19
 20import mpv5.globals.LocalSettings;
 21import mpv5.ui.misc.Position;
 22import mpv5.ui.misc.JCalc;
 23
 24
 25/**
 26 *
 27 *   
 28 */
 29public class MPCalculator extends javax.swing.JFrame {
 30
 31    private static MPCalculator calc;
 32
 33    /** Creates new form MPCalculator */
 34    private MPCalculator() {
 35        initComponents();
 36
 37        JCalc cal = new JCalc(jTextField1, jLabel1);
 38
 39        jButton1.addActionListener(cal.getNl());
 40        jButton2.addActionListener(cal.getNl());
 41        jButton3.addActionListener(cal.getNl());
 42        jButton5.addActionListener(cal.getNl());
 43        jButton6.addActionListener(cal.getNl());
 44        jButton7.addActionListener(cal.getNl());
 45        jButton9.addActionListener(cal.getNl());
 46        jButton10.addActionListener(cal.getNl());
 47        jButton11.addActionListener(cal.getNl());
 48        jButton13.addActionListener(cal.getNl());
 49        jButton14.addActionListener(cal.getNl());
 50
 51        jButton4.addActionListener(cal.getOl());
 52        jButton8.addActionListener(cal.getOl());
 53        jButton12.addActionListener(cal.getOl());
 54        jButton16.addActionListener(cal.getOl());
 55        jButton15.addActionListener(cal.getOl());
 56
 57        jButton17.addActionListener(cal.getFl());
 58
 59        new Position(this);
 60    }
 61
 62    public static MPCalculator instanceOf() {
 63
 64        if (calc == null) {
 65            calc = new MPCalculator();
 66            return calc;
 67        } else {
 68            return calc;
 69        }
 70    }
 71
 72    /** This method is called from within the constructor to
 73     * initialize the form.
 74     * WARNING: Do NOT modify this code. The content of this method is
 75     * always regenerated by the Form Editor.
 76     */
 77    @SuppressWarnings("unchecked")
 78// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 79private void initComponents() {
 80
 81jPanel1 = new javax.swing.JPanel();
 82jTextField1 = new javax.swing.JTextField();
 83jPanel2 = new javax.swing.JPanel();
 84jButton9 = new javax.swing.JButton();
 85jButton5 = new javax.swing.JButton();
 86jButton1 = new javax.swing.JButton();
 87jButton13 = new javax.swing.JButton();
 88jButton14 = new javax.swing.JButton();
 89jButton10 = new javax.swing.JButton();
 90jButton6 = new javax.swing.JButton();
 91jButton2 = new javax.swing.JButton();
 92jButton3 = new javax.swing.JButton();
 93jButton7 = new javax.swing.JButton();
 94jButton11 = new javax.swing.JButton();
 95jButton15 = new javax.swing.JButton();
 96jButton16 = new javax.swing.JButton();
 97jButton12 = new javax.swing.JButton();
 98jButton8 = new javax.swing.JButton();
 99jButton4 = new javax.swing.JButton();
100jButton17 = new javax.swing.JButton();
101jLabel1 = new javax.swing.JLabel();
102
103setTitle("MPCalculator");
104setResizable(false);
105
106jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Calculator"));
107
108jTextField1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 0, 18)); // NOI18N
109jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
110jTextField1.setText("0");
111
112jPanel2.setBackground(new java.awt.Color(204, 204, 204));
113jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
114
115jButton9.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
116jButton9.setText("7");
117
118jButton5.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
119jButton5.setText("4");
120
121jButton1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
122jButton1.setText("1");
123
124jButton13.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
125jButton13.setText("0");
126
127jButton14.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
128jButton14.setText(".");
129
130jButton10.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
131jButton10.setText("8");
132
133jButton6.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
134jButton6.setText("5");
135
136jButton2.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
137jButton2.setText("2");
138
139jButton3.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
140jButton3.setText("3");
141
142jButton7.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
143jButton7.setText("6");
144
145jButton11.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
146jButton11.setText("9");
147
148jButton15.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
149jButton15.setText("=");
150
151jButton16.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
152jButton16.setText("+");
153
154jButton12.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
155jButton12.setText("-");
156
157jButton8.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
158jButton8.setText("*");
159
160jButton4.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
161jButton4.setText("/");
162
163javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
164jPanel2.setLayout(jPanel2Layout);
165jPanel2Layout.setHorizontalGroup(
166jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167.addGroup(jPanel2Layout.createSequentialGroup()
168.addContainerGap()
169.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
170.addGroup(jPanel2Layout.createSequentialGroup()
171.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
172.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
173.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
174.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
175.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
176.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
177.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
178.addGroup(jPanel2Layout.createSequentialGroup()
179.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
180.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
181.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
182.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
183.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
184.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
185.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
186.addGroup(jPanel2Layout.createSequentialGroup()
187.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
188.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
189.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
190.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
191.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
192.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
193.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
194.addGroup(jPanel2Layout.createSequentialGroup()
195.addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
196.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
197.addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
198.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199.addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
200.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
201.addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
202.addContainerGap())
203);
204jPanel2Layout.setVerticalGroup(
205jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206.addGroup(jPanel2Layout.createSequentialGroup()
207.addContainerGap()
208.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
209.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
210.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
211.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
212.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
213.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
214.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
215.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
216.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
217.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
218.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
219.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
220.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
221.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
222.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
223.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
224.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
225.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
226.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
227.addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
228.addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
229.addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
230.addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
231.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
232);
233
234
235jButton17.setText("Clear");
236
237jLabel1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 0, 14)); // NOI18N
238jLabel1.setForeground(new java.awt.Color(102, 102, 102));
239jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
240
241javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
242jPanel1.setLayout(jPanel1Layout);
243jPanel1Layout.setHorizontalGroup(
244jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
245.addGroup(jPanel1Layout.createSequentialGroup()
246.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
247.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
248.addComponent(jButton17)
249.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 191, Short.MAX_VALUE)
250.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
251.addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
252.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
253.addContainerGap())
254);
255jPanel1Layout.setVerticalGroup(
256jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
257.addGroup(jPanel1Layout.createSequentialGroup()
258.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
259.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
260.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
261.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
262.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
263.addComponent(jButton17)
264.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
265);
266
267javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
268getContentPane().setLayout(layout);
269layout.setHorizontalGroup(
270layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
271.addGroup(layout.createSequentialGroup()
272.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
273.addGap(0, 0, 0))
274);
275layout.setVerticalGroup(
276layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
277.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
278);
279
280pack();
281}// </editor-fold>//GEN-END:initComponents
282// Variables declaration - do not modify//GEN-BEGIN:variables
283private javax.swing.JButton jButton1;
284private javax.swing.JButton jButton10;
285private javax.swing.JButton jButton11;
286private javax.swing.JButton jButton12;
287private javax.swing.JButton jButton13;
288private javax.swing.JButton jButton14;
289private javax.swing.JButton jButton15;
290private javax.swing.JButton jButton16;
291private javax.swing.JButton jButton17;
292private javax.swing.JButton jButton2;
293private javax.swing.JButton jButton3;
294private javax.swing.JButton jButton4;
295private javax.swing.JButton jButton5;
296private javax.swing.JButton jButton6;
297private javax.swing.JButton jButton7;
298private javax.swing.JButton jButton8;
299private javax.swing.JButton jButton9;
300private javax.swing.JLabel jLabel1;
301private javax.swing.JPanel jPanel1;
302private javax.swing.JPanel jPanel2;
303private javax.swing.JTextField jTextField1;
304// End of variables declaration//GEN-END:variables
305}
306