From da6cf36c9dc7c81cb7389535b2ee3a236a4587e5 Mon Sep 17 00:00:00 2001 From: "DozorovaA.A" Date: Wed, 30 Nov 2022 10:43:15 +0400 Subject: [PATCH] add logic --- .vs/slnx.sqlite | Bin 114688 -> 114688 bytes .../src/FormArmoredVehicleConfig.form | 87 ++++--- .../src/FormArmoredVehicleConfig.java | 220 +++++++++++++----- ArmoredVehicle/src/FormMapWithSetMachine.java | 2 +- 4 files changed, 226 insertions(+), 83 deletions(-) diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 5592d4285ab07c76020047d9e2c6993b91836c27..245cfd22c12f5b8d745795bb349562e314c3814c 100644 GIT binary patch delta 2561 zcmcJQdr(x@9mntQ+&%ZX4?qYku!t-RC@KxHWupQT#31HDv>I_z8b&sjDC`Potw{@+ z+7&p}VD2BMW}?ANIz(bHcGVlBMvUTH5r{&FP18p@Q(Hlec3P&%^em^Qk4@UYI(K(I zzu)(F@9*4u&YACNZkC&y<@O{P+m>7mWBZ=2$$`6}b2%UVD1K+!Uua>}BuM}jB)6!H z4D4`yQsD?4>3%#Kl0(*>PaUe04spE0VTOvX{|1^qLC5XV)H zD;yti3~~%`^mAP1=;OG=agpN!$9ax(9A`PsaGbuM^Atxf$4QP89Pe`+=jbs8|I`8_ zp{H)x5Zo}H9rNFJD_rs7n;c^tqoJ{}xMnD&H~_wR+A6I?^JuzyS>2|VtI^7UvQ1g9 z6e`j3U*(VFx8&#LCGs>Gq+w~V6qLRr<>PTYg7@H;@RK;fGGulIU=SfuH=7z@IhZ#N z!Xa$7Z-jbW87&mUOhHLkEb?)Am)sy%$SLZGx?LKOwnz_27+=RB{1aS@i*T&vmgRzF zmt~b@xp{L)TCUwV^8HMGp8q9EEN07|f(w--g5jeYx(@E!vRw zmbOW&&~i1W@~HKi^%vF_Yo&FTRnyPvZNiwaKk|~Jg^hHr2@l9_$cULs7Sj7o@G5Rd zi*dEi(&*&?B$`?KpcmVe&4Nu(Js!4Y0nAzxazM-@d9?CH$V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w;srVt zT}!oqt)=SxaxK*jtlF>irL?q`YCcx^A*YBosDYE$sm%&!9nyuZN-mtU#SZabu0=gy!3|tS*2Y52gZy*IxVVX1e!!;#MozQ$B7YG zYnH3T5!orP0fZyc)1lvuK(h!<=tM|_o!EqsAnZusodmTlgb3RMWA7#sVO!w2x9zdQ z<`_Pew6ykmyq#6^6PKrS5b0*0|fjd56^`zjzN)ld@K*M#vwT-nqNaaot|Eox1-D3>F(_95uU>RWeW13-}p1G3KY)xq_M%6Z+yV; zkzw4h*N~$8Nf}p;DYZ(9Vv+C3*W{;Vk6a|j>Oa+A*Pqn)=xg*5(xP-#nvgoAhs00B zDbXXY5Z)JlAq)#GLWPi^Th#qZH=%n{=hErX6l4>_6XJi1j48dx>oSmi}WLela Q1gU(sWDf2A4vdq30$ACYaR2}S diff --git a/ArmoredVehicle/src/FormArmoredVehicleConfig.form b/ArmoredVehicle/src/FormArmoredVehicleConfig.form index 106c6d6..7511c4b 100644 --- a/ArmoredVehicle/src/FormArmoredVehicleConfig.form +++ b/ArmoredVehicle/src/FormArmoredVehicleConfig.form @@ -76,34 +76,45 @@ - - - - - - - - - - + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + @@ -120,10 +131,9 @@ - - - + + @@ -140,9 +150,19 @@ - + + + + + + + + + + + @@ -257,7 +277,7 @@ - + @@ -479,6 +499,21 @@ + + + + + + + + + + + + + + + diff --git a/ArmoredVehicle/src/FormArmoredVehicleConfig.java b/ArmoredVehicle/src/FormArmoredVehicleConfig.java index 5524039..9fa8fef 100644 --- a/ArmoredVehicle/src/FormArmoredVehicleConfig.java +++ b/ArmoredVehicle/src/FormArmoredVehicleConfig.java @@ -1,3 +1,13 @@ + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.function.Consumer; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; + /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template @@ -8,14 +18,63 @@ * @author Alena */ public class FormArmoredVehicleConfig extends javax.swing.JFrame { - + DrawingArmoredVehicle _machine; + Consumer EventAddMachine; + public boolean DialogResult = false; /** * Creates new form FormArmoredVehicleConfig */ public FormArmoredVehicleConfig() { initComponents(); - } + MouseAdapter drag = new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + @Override + public void mouseReleased(MouseEvent e) { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + Drop((JComponent) e.getSource()); + } + }; + MouseAdapter defCursor = new MouseAdapter() { + @Override + public void mouseExited(MouseEvent e) { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + }; + panelDraw.addMouseListener(defCursor); + LabelColor.addMouseListener(defCursor); + LabelDopColor.addMouseListener(defCursor); + //labelSetRoller.addMouseListener(defCursor); + + PanelRed.addMouseListener(drag); + PanelBlack.addMouseListener(drag); + PanelGray.addMouseListener(drag); + PanelOrange.addMouseListener(drag); + PanelYellow.addMouseListener(drag); + PanelPink.addMouseListener(drag); + PanelGreen.addMouseListener(drag); + PanelBlue.addMouseListener(drag); + + LabelSimple.addMouseListener(drag); + LabelModify.addMouseListener(drag); + LabelFirstRoller.addMouseListener(drag); + LabelSecondRoller.addMouseListener(drag); + + buttonAdd.addActionListener(e -> { + EventAddMachine.accept(_machine); + DialogResult = true; + dispose(); + }); + + buttonCancel.addActionListener(e -> dispose()); + } +public void AddEvent(Consumer ev) { EventAddMachine = ev; } + public DrawingArmoredVehicle getSelectedCar() { + return _machine; + } /** * 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 @@ -44,10 +103,15 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { PanelGreen = new javax.swing.JPanel(); PanelBlue = new javax.swing.JPanel(); PanelYellow = new javax.swing.JPanel(); + label2 = new java.awt.Label(); + label1 = new java.awt.Label(); LabelCountRollers = new javax.swing.JLabel(); ComboBoxCountRollers = new javax.swing.JComboBox<>(); LabelModify = new javax.swing.JLabel(); LabelSimple = new javax.swing.JLabel(); + LabelFirstRoller = new javax.swing.JLabel(); + LabelSecondRoller = new javax.swing.JLabel(); + LabelSimpleRollers = new javax.swing.JLabel(); panelObject = new java.awt.Panel(); LabelDopColor = new javax.swing.JLabel(); LabelColor = new javax.swing.JLabel(); @@ -221,7 +285,7 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { .addComponent(PanelGreen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(PanelBlue, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(PanelYellow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(0, 62, Short.MAX_VALUE)) + .addContainerGap(33, Short.MAX_VALUE)) ); label1.setText("label1"); @@ -236,6 +300,12 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { LabelSimple.setText("Простой"); LabelSimple.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + LabelFirstRoller.setText("Первый тип"); + + LabelSecondRoller.setText("Второй тип"); + + LabelSimpleRollers.setText("Простые"); + javax.swing.GroupLayout panelParamsLayout = new javax.swing.GroupLayout(panelParams); panelParams.setLayout(panelParamsLayout); panelParamsLayout.setHorizontalGroup( @@ -243,28 +313,36 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { .addGroup(panelParamsLayout.createSequentialGroup() .addContainerGap() .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(labelParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(panelParamsLayout.createSequentialGroup() + .addComponent(checkboxGun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(148, 148, 148) + .addComponent(LabelModify, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(panelParamsLayout.createSequentialGroup() .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(labelSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(labelWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(SpinnerWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(SpinnerSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(panelParamsLayout.createSequentialGroup() - .addComponent(LabelCountRollers) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(ComboBoxCountRollers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(checkboxTower, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(checkboxGun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelParamsLayout.createSequentialGroup() + .addComponent(labelParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(panelParamsLayout.createSequentialGroup() + .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(labelSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(labelWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(SpinnerWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(SpinnerSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(panelParamsLayout.createSequentialGroup() + .addComponent(LabelCountRollers) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(ComboBoxCountRollers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(panelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(panelParamsLayout.createSequentialGroup() - .addGap(115, 115, 115) - .addComponent(LabelModify, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(panelParamsLayout.createSequentialGroup() + .addComponent(LabelFirstRoller) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(LabelSecondRoller)) + .addComponent(checkboxTower, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(LabelSimpleRollers))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelParamsLayout.createSequentialGroup() @@ -275,10 +353,9 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { panelParamsLayout.setVerticalGroup( panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelParamsLayout.createSequentialGroup() - .addContainerGap() - .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(panelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelParamsLayout.createSequentialGroup() + .addGap(34, 34, 34) .addComponent(labelParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -291,8 +368,16 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(LabelCountRollers) - .addComponent(ComboBoxCountRollers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(40, 40, 40))) + .addComponent(ComboBoxCountRollers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(panelParamsLayout.createSequentialGroup() + .addContainerGap() + .addComponent(panelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(LabelFirstRoller) + .addComponent(LabelSecondRoller) + .addComponent(LabelSimpleRollers)) + .addGap(12, 12, 12) .addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelParamsLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -402,39 +487,59 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { pack(); }// //GEN-END:initComponents - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(FormArmoredVehicleConfig.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(FormArmoredVehicleConfig.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(FormArmoredVehicleConfig.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(FormArmoredVehicleConfig.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + + public void Drop(JComponent droppedItem) { + if (droppedItem == null) { + return; } - // - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new FormArmoredVehicleConfig().setVisible(true); + Color color = Color.WHITE; + Color dopColor = Color.BLACK; + if (droppedItem instanceof JPanel panel) { + if (_machine == null) + return; + if (LabelColor.getMousePosition() != null) { + //_machine.SetColor(panel.getBackground()); + color = panel.getBackground(); } - }); + if (LabelDopColor.getMousePosition() != null && _machine instanceof DrawingTank tank) { + //tank.SetDopColor(panel.getBackground()); + dopColor = panel.getBackground(); + } + } + if (droppedItem instanceof JLabel label && panelDraw.getMousePosition() != null) { + int speed = (int)SpinnerSpeed.getValue(); + int weight = (int)SpinnerWeight.getValue(); + int rollers = Integer.parseInt((String) ComboBoxCountRollers.getSelectedItem()); + boolean tower = checkboxTower.getState(); + boolean gun = checkboxGun.getState(); + + if (label == LabelSimple) { + //try { pictureBox.remove(_machine); } catch (Exception ex) { } + _machine = new DrawingArmoredVehicle(speed, weight, color); + } else if (label == LabelModify) { + //try { pictureBox.remove(_machine); } catch (Exception ex) { } + _machine = new DrawingTank(speed, weight, color, dopColor, tower, gun); + } + + if (_machine!=null) { + _machine.SetPosition(panelDraw.getWidth() - 200, panelDraw.getHeight() - 150, panelDraw.getWidth(), panelDraw.getHeight()); + // pictureBox.add(_machine, BorderLayout.CENTER); + revalidate(); + } + + } else if (droppedItem instanceof JLabel label /*&& labelSetRoller.getMousePosition() != null*/ && _machine!=null) { + if (label == LabelSimpleRollers) { + _machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle, new Roller(color)); + //_machine.SetRollers((int)rollerSpinner.getValue(), new Roller(color)); + } else if (label == LabelFirstRoller) { + //_machine.SetRollers((int)rollerSpinner.getValue(), new DrawingFirstRoller(color)); + _machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle, new DrawingFirstRoller(color)); + } else if (label == LabelSecondRoller) { + //_machine.SetRollers((int)rollerSpinner.getValue(), new DrawingSecondRoller(color)); + _machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle, new DrawingSecondRoller(color)); + } + } + } // Variables declaration - do not modify//GEN-BEGIN:variables @@ -442,8 +547,11 @@ public class FormArmoredVehicleConfig extends javax.swing.JFrame { private javax.swing.JLabel LabelColor; private javax.swing.JLabel LabelCountRollers; private javax.swing.JLabel LabelDopColor; + private javax.swing.JLabel LabelFirstRoller; private javax.swing.JLabel LabelModify; + private javax.swing.JLabel LabelSecondRoller; private javax.swing.JLabel LabelSimple; + private javax.swing.JLabel LabelSimpleRollers; private javax.swing.JPanel PanelBlack; private javax.swing.JPanel PanelBlue; private javax.swing.JPanel PanelGray; diff --git a/ArmoredVehicle/src/FormMapWithSetMachine.java b/ArmoredVehicle/src/FormMapWithSetMachine.java index 7634ee2..05de396 100644 --- a/ArmoredVehicle/src/FormMapWithSetMachine.java +++ b/ArmoredVehicle/src/FormMapWithSetMachine.java @@ -301,7 +301,7 @@ private Image img; JOptionPane.showMessageDialog(null, "Не выбрана карта"); return; } - FormMachineConfig form = new FormMachineConfig(); + FormArmoredVehicleConfig form = new FormArmoredVehicleConfig(); form.setVisible(true); form.addWindowListener(new WindowAdapter() { @Override