/src/mpv5/ui/frames/MPCalculator.java
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
- /*
- * This file is part of YaBS.
- *
- * YaBS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * YaBS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with YaBS. If not, see <http://www.gnu.org/licenses/>.
- */
- package mpv5.ui.frames;
- import mpv5.globals.LocalSettings;
- import mpv5.ui.misc.Position;
- import mpv5.ui.misc.JCalc;
- /**
- *
- *
- */
- public class MPCalculator extends javax.swing.JFrame {
- private static MPCalculator calc;
- /** Creates new form MPCalculator */
- private MPCalculator() {
- initComponents();
- JCalc cal = new JCalc(jTextField1, jLabel1);
- jButton1.addActionListener(cal.getNl());
- jButton2.addActionListener(cal.getNl());
- jButton3.addActionListener(cal.getNl());
- jButton5.addActionListener(cal.getNl());
- jButton6.addActionListener(cal.getNl());
- jButton7.addActionListener(cal.getNl());
- jButton9.addActionListener(cal.getNl());
- jButton10.addActionListener(cal.getNl());
- jButton11.addActionListener(cal.getNl());
- jButton13.addActionListener(cal.getNl());
- jButton14.addActionListener(cal.getNl());
- jButton4.addActionListener(cal.getOl());
- jButton8.addActionListener(cal.getOl());
- jButton12.addActionListener(cal.getOl());
- jButton16.addActionListener(cal.getOl());
- jButton15.addActionListener(cal.getOl());
- jButton17.addActionListener(cal.getFl());
- new Position(this);
- }
- public static MPCalculator instanceOf() {
- if (calc == null) {
- calc = new MPCalculator();
- return calc;
- } else {
- return calc;
- }
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
- jPanel1 = new javax.swing.JPanel();
- jTextField1 = new javax.swing.JTextField();
- jPanel2 = new javax.swing.JPanel();
- jButton9 = new javax.swing.JButton();
- jButton5 = new javax.swing.JButton();
- jButton1 = new javax.swing.JButton();
- jButton13 = new javax.swing.JButton();
- jButton14 = new javax.swing.JButton();
- jButton10 = new javax.swing.JButton();
- jButton6 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jButton7 = new javax.swing.JButton();
- jButton11 = new javax.swing.JButton();
- jButton15 = new javax.swing.JButton();
- jButton16 = new javax.swing.JButton();
- jButton12 = new javax.swing.JButton();
- jButton8 = new javax.swing.JButton();
- jButton4 = new javax.swing.JButton();
- jButton17 = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- setTitle("MPCalculator");
- setResizable(false);
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Calculator"));
- jTextField1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 0, 18)); // NOI18N
- jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
- jTextField1.setText("0");
- jPanel2.setBackground(new java.awt.Color(204, 204, 204));
- jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
- jButton9.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton9.setText("7");
- jButton5.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton5.setText("4");
- jButton1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton1.setText("1");
- jButton13.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton13.setText("0");
- jButton14.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton14.setText(".");
- jButton10.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton10.setText("8");
- jButton6.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton6.setText("5");
- jButton2.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton2.setText("2");
- jButton3.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton3.setText("3");
- jButton7.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton7.setText("6");
- jButton11.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton11.setText("9");
- jButton15.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton15.setText("=");
- jButton16.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton16.setText("+");
- jButton12.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton12.setText("-");
- jButton8.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton8.setText("*");
- jButton4.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 1, 14)); // NOI18N
- jButton4.setText("/");
- javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout.setHorizontalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap())
- );
- jPanel2Layout.setVerticalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- jButton17.setText("Clear");
- jLabel1.setFont(new java.awt.Font(LocalSettings.getProperty("defaultfont"), 0, 14)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(102, 102, 102));
- jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
- .addComponent(jButton17)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 191, Short.MAX_VALUE)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
- .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap())
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton17)
- .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, 0))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton10;
- private javax.swing.JButton jButton11;
- private javax.swing.JButton jButton12;
- private javax.swing.JButton jButton13;
- private javax.swing.JButton jButton14;
- private javax.swing.JButton jButton15;
- private javax.swing.JButton jButton16;
- private javax.swing.JButton jButton17;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JButton jButton5;
- private javax.swing.JButton jButton6;
- private javax.swing.JButton jButton7;
- private javax.swing.JButton jButton8;
- private javax.swing.JButton jButton9;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JTextField jTextField1;
- // End of variables declaration//GEN-END:variables
- }