Java tutorial
/* * Created by JFormDesigner on Tue Sep 09 19:56:23 EEST 2014 */ package main.java; import java.awt.*; import java.awt.event.*; import java.io.IOException; import java.text.SimpleDateFormat; import javax.swing.*; import org.json.simple.parser.ParseException; import main.dao.impl.daoImplements; import main.data.information; import main.etc.IdTransaction.getTransaction; import main.etc.parser.parserStatus; import main.java.payClass.check.check; import main.java.payClass.getstatus.getstatus; import main.java.payClass.pay.pay; import main.java.table.tableData; /** * @author BOHDAN Korinnyi */ public class gui { public gui() { initComponents(); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.setResizable(false); test.setVisible(true); } private String getNumber() { String number = textField2.getText(); try { if (number.matches("^\\d+")) { if (number.length() == 10) { return number; } } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return null; } private String getMoney() { String money = textField1.getText(); try { if (money.matches("^\\d+")) { return money; } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return null; } private void payActionPerformed(ActionEvent e) { // TODO add your code here } private void historyActionPerformed(ActionEvent e) { // TODO add your code here } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - BOHDAN Korinnyi test = new JFrame(); label1 = new JLabel(); textField1 = new JTextField(); label2 = new JLabel(); textField2 = new JTextField(); label3 = new JLabel(); label4 = new JLabel(); textField3 = new JTextField(); textField4 = new JTextField(); button1 = new JButton(); button2 = new JButton(); label5 = new JLabel(); label6 = new JLabel(); //======== test ======== { test.setTitle("Pay mobile account"); Container testContentPane = test.getContentPane(); testContentPane.setLayout(null); //---- label1 ---- label1.setText("\u0421\u0443\u043c\u0430"); label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 4f)); testContentPane.add(label1); label1.setBounds(new Rectangle(new Point(35, 30), label1.getPreferredSize())); //---- textField1 ---- textField1.setColumns(10); testContentPane.add(textField1); textField1.setBounds(150, 30, 105, textField1.getPreferredSize().height); //---- label2 ---- label2.setText("\u041d\u043e\u043c\u0435\u0440"); label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 4f)); testContentPane.add(label2); label2.setBounds(new Rectangle(new Point(35, 60), label2.getPreferredSize())); //---- textField2 ---- textField2.setText("0674060606"); textField2.setFont(textField2.getFont().deriveFont(textField2.getFont().getSize() + 2f)); testContentPane.add(textField2); textField2.setBounds(150, 60, 105, textField2.getPreferredSize().height); //---- label3 ---- label3.setText("\u041b\u043e\u0433\u0456\u043d"); label3.setFont(label3.getFont().deriveFont(label3.getFont().getSize() + 4f)); testContentPane.add(label3); label3.setBounds(new Rectangle(new Point(35, 95), label3.getPreferredSize())); //---- label4 ---- label4.setText("\u041f\u0430\u0440\u043e\u043b\u044c"); label4.setFont(label4.getFont().deriveFont(label4.getFont().getSize() + 4f)); testContentPane.add(label4); label4.setBounds(new Rectangle(new Point(35, 125), label4.getPreferredSize())); testContentPane.add(textField3); textField3.setBounds(150, 95, 105, textField3.getPreferredSize().height); testContentPane.add(textField4); textField4.setBounds(150, 125, 105, 20); //---- button1 ---- button1.setText("\u041e\u043f\u043b\u0430\u0442\u0438\u0442\u0438"); button1.setFont(button1.getFont().deriveFont(button1.getFont().getStyle() | Font.BOLD, button1.getFont().getSize() + 2f)); button1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String strTemp = textField1.getText(); int cash = Integer.parseInt(strTemp); if (cash < 1) { JOptionPane.showMessageDialog(null, " '", "", JOptionPane.OK_OPTION); textField1.setText("0"); } else if (textField3.getText().equals("test4") && textField4.getText().equals("12345")) { check c = new check(); pay p = new pay(); getstatus g = new getstatus(); try { c.connection(c.PaymentCollectionRequest("38" + getNumber(), getMoney())); g.connection(c.PaymentStatusRequest()); p.connection(c.PaymentCollectionRequest("38" + getNumber(), getMoney())); g.connection(c.PaymentStatusRequest()); information i = new information(); daoImplements h = new daoImplements(); long curTime = System.currentTimeMillis(); String curStringDate = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(curTime); i.setIdTransaction(getTransaction.setGetTransaction()); i.setData(curStringDate); i.setNumber(Integer.parseInt(getNumber())); i.setSuma(Integer.parseInt(getMoney())); i.setStatus(parserStatus.getStatusParsing()); h.addInfo(i); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, " ", "", JOptionPane.OK_OPTION); System.exit(0); } } }); testContentPane.add(button1); button1.setBounds(150, 155, 115, 25); //---- button2 ---- button2.setText("\u0406\u0441\u0442\u043e\u0440\u0456\u044f"); button2.setFont(button2.getFont().deriveFont(button2.getFont().getStyle() | Font.BOLD, button2.getFont().getSize() + 2f)); button2.setActionCommand("\u0406\u0441\u0442\u043e\u0440\u0456\u044f"); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tableData t = new tableData(); } }); testContentPane.add(button2); button2.setBounds(15, 155, 115, 25); //---- label5 ---- label5.setText( "\u0422\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0441\u0435\u0440\u0432\u0456\u0441 \u043f\u043e\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043c\u043e\u0431\u0456\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0445\u0443\u043d\u043a\u0443"); label5.setFont(label5.getFont().deriveFont(label5.getFont().getStyle() & ~Font.ITALIC)); testContentPane.add(label5); label5.setBounds(15, 0, 255, 20); //---- label6 ---- label6.setText("38"); label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() + 4f)); testContentPane.add(label6); label6.setBounds(new Rectangle(new Point(130, 60), label6.getPreferredSize())); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < testContentPane.getComponentCount(); i++) { Rectangle bounds = testContentPane.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = testContentPane.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; testContentPane.setMinimumSize(preferredSize); testContentPane.setPreferredSize(preferredSize); } test.pack(); test.setLocationRelativeTo(test.getOwner()); } // JFormDesigner - End of component initialization //GEN-END:initComponents } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // Generated using JFormDesigner Evaluation license - BOHDAN Korinnyi private JFrame test; private JLabel label1; private JTextField textField1; private JLabel label2; private JTextField textField2; private JLabel label3; private JLabel label4; private JTextField textField3; private JTextField textField4; private JButton button1; private JButton button2; private JLabel label5; private JLabel label6; // JFormDesigner - End of variables declaration //GEN-END:variables }