PageRenderTime 45ms CodeModel.GetById 13ms RepoModel.GetById 1ms 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
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  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. package mpv5.ui.frames;
  18. import mpv5.globals.LocalSettings;
  19. import mpv5.ui.misc.Position;
  20. import mpv5.ui.misc.JCalc;
  21. /**
  22. *
  23. *
  24. */
  25. public class MPCalculator extends javax.swing.JFrame {
  26. private static MPCalculator calc;
  27. /** Creates new form MPCalculator */
  28. private MPCalculator() {
  29. initComponents();
  30. JCalc cal = new JCalc(jTextField1, jLabel1);
  31. jButton1.addActionListener(cal.getNl());
  32. jButton2.addActionListener(cal.getNl());
  33. jButton3.addActionListener(cal.getNl());
  34. jButton5.addActionListener(cal.getNl());
  35. jButton6.addActionListener(cal.getNl());
  36. jButton7.addActionListener(cal.getNl());
  37. jButton9.addActionListener(cal.getNl());
  38. jButton10.addActionListener(cal.getNl());
  39. jButton11.addActionListener(cal.getNl());
  40. jButton13.addActionListener(cal.getNl());
  41. jButton14.addActionListener(cal.getNl());
  42. jButton4.addActionListener(cal.getOl());
  43. jButton8.addActionListener(cal.getOl());
  44. jButton12.addActionListener(cal.getOl());
  45. jButton16.addActionListener(cal.getOl());
  46. jButton15.addActionListener(cal.getOl());
  47. jButton17.addActionListener(cal.getFl());
  48. new Position(this);
  49. }
  50. public static MPCalculator instanceOf() {
  51. if (calc == null) {
  52. calc = new MPCalculator();
  53. return calc;
  54. } else {
  55. return calc;
  56. }
  57. }
  58. /** This method is called from within the constructor to
  59. * initialize the form.
  60. * WARNING: Do NOT modify this code. The content of this method is
  61. * always regenerated by the Form Editor.
  62. */
  63. @SuppressWarnings("unchecked")
  64. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  65. private void initComponents() {
  66. jPanel1 = new javax.swing.JPanel();
  67. jTextField1 = new javax.swing.JTextField();
  68. jPanel2 = new javax.swing.JPanel();
  69. jButton9 = new javax.swing.JButton();
  70. jButton5 = new javax.swing.JButton();
  71. jButton1 = new javax.swing.JButton();
  72. jButton13 = new javax.swing.JButton();
  73. jButton14 = new javax.swing.JButton();
  74. jButton10 = new javax.swing.JButton();
  75. jButton6 = new javax.swing.JButton();
  76. jButton2 = new javax.swing.JButton();
  77. jButton3 = new javax.swing.JButton();
  78. jButton7 = new javax.swing.JButton();
  79. jButton11 = new javax.swing.JButton();
  80. jButton15 = new javax.swing.JButton();
  81. jButton16 = new javax.swing.JButton();
  82. jButton12 = new javax.swing.JButton();
  83. jButton8 = new javax.swing.JButton();
  84. jButton4 = new javax.swing.JButton();
  85. jButton17 = new javax.swing.JButton();
  86. jLabel1 = new javax.swing.JLabel();
  87. setTitle("MPCalculator");
  88. setResizable(false);
  89. jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Calculator"));
  90. jTextField1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 0, 18)); // NOI18N
  91. jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
  92. jTextField1.setText("0");
  93. jPanel2.setBackground(new java.awt.Color(204, 204, 204));
  94. jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  95. jButton9.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  96. jButton9.setText("7");
  97. jButton5.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  98. jButton5.setText("4");
  99. jButton1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  100. jButton1.setText("1");
  101. jButton13.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  102. jButton13.setText("0");
  103. jButton14.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  104. jButton14.setText(".");
  105. jButton10.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  106. jButton10.setText("8");
  107. jButton6.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  108. jButton6.setText("5");
  109. jButton2.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  110. jButton2.setText("2");
  111. jButton3.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  112. jButton3.setText("3");
  113. jButton7.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  114. jButton7.setText("6");
  115. jButton11.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  116. jButton11.setText("9");
  117. jButton15.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  118. jButton15.setText("=");
  119. jButton16.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  120. jButton16.setText("+");
  121. jButton12.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  122. jButton12.setText("-");
  123. jButton8.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  124. jButton8.setText("*");
  125. jButton4.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
  126. jButton4.setText("/");
  127. javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  128. jPanel2.setLayout(jPanel2Layout);
  129. jPanel2Layout.setHorizontalGroup(
  130. jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  131. .addGroup(jPanel2Layout.createSequentialGroup()
  132. .addContainerGap()
  133. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  134. .addGroup(jPanel2Layout.createSequentialGroup()
  135. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  136. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  137. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  138. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  139. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  140. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  141. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
  142. .addGroup(jPanel2Layout.createSequentialGroup()
  143. .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  144. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  145. .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  146. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  147. .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  148. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  149. .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
  150. .addGroup(jPanel2Layout.createSequentialGroup()
  151. .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  152. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  153. .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  154. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  155. .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  156. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  157. .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
  158. .addGroup(jPanel2Layout.createSequentialGroup()
  159. .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  160. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  161. .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  162. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  163. .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
  164. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  165. .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
  166. .addContainerGap())
  167. );
  168. jPanel2Layout.setVerticalGroup(
  169. jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  170. .addGroup(jPanel2Layout.createSequentialGroup()
  171. .addContainerGap()
  172. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  173. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  174. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  175. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  176. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
  177. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  178. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  179. .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  180. .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  181. .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  182. .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
  183. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  184. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  185. .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  186. .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  187. .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  188. .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
  189. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  190. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  191. .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  192. .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  193. .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
  194. .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
  195. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  196. );
  197. jButton17.setText("Clear");
  198. jLabel1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 0, 14)); // NOI18N
  199. jLabel1.setForeground(new java.awt.Color(102, 102, 102));
  200. jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  201. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  202. jPanel1.setLayout(jPanel1Layout);
  203. jPanel1Layout.setHorizontalGroup(
  204. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  205. .addGroup(jPanel1Layout.createSequentialGroup()
  206. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  207. .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
  208. .addComponent(jButton17)
  209. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 191, Short.MAX_VALUE)
  210. .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
  211. .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
  212. .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  213. .addContainerGap())
  214. );
  215. jPanel1Layout.setVerticalGroup(
  216. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  217. .addGroup(jPanel1Layout.createSequentialGroup()
  218. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
  219. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  220. .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  221. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  222. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  223. .addComponent(jButton17)
  224. .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
  225. );
  226. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  227. getContentPane().setLayout(layout);
  228. layout.setHorizontalGroup(
  229. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  230. .addGroup(layout.createSequentialGroup()
  231. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
  232. .addGap(0, 0, 0))
  233. );
  234. layout.setVerticalGroup(
  235. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  236. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  237. );
  238. pack();
  239. }// </editor-fold>//GEN-END:initComponents
  240. // Variables declaration - do not modify//GEN-BEGIN:variables
  241. private javax.swing.JButton jButton1;
  242. private javax.swing.JButton jButton10;
  243. private javax.swing.JButton jButton11;
  244. private javax.swing.JButton jButton12;
  245. private javax.swing.JButton jButton13;
  246. private javax.swing.JButton jButton14;
  247. private javax.swing.JButton jButton15;
  248. private javax.swing.JButton jButton16;
  249. private javax.swing.JButton jButton17;
  250. private javax.swing.JButton jButton2;
  251. private javax.swing.JButton jButton3;
  252. private javax.swing.JButton jButton4;
  253. private javax.swing.JButton jButton5;
  254. private javax.swing.JButton jButton6;
  255. private javax.swing.JButton jButton7;
  256. private javax.swing.JButton jButton8;
  257. private javax.swing.JButton jButton9;
  258. private javax.swing.JLabel jLabel1;
  259. private javax.swing.JPanel jPanel1;
  260. private javax.swing.JPanel jPanel2;
  261. private javax.swing.JTextField jTextField1;
  262. // End of variables declaration//GEN-END:variables
  263. }