001: /*
002: * jaiGUI.java
003: *
004: * Created on 17 maj 2007, 00:52
005: */
006:
007: package jaimoves;
008:
009: import jaimoves.actor.Actor;
010:
011: /**
012: *
013: * @author emper
014: */
015: public class jaiGUI extends javax.swing.JFrame {
016:
017: private jaisimulation symulacja; // TUTAJ DEKLARUJESZ ZMIENNA
018: private Thread simulationThread;
019:
020: // private java.util.Timer dane;
021: /**
022: * Creates new jaiGUI jaiGUI
023: */
024: public jaiGUI() {
025: initComponents();
026:
027: symulacja = new jaisimulation();
028: // fTimer = new java.util.Timer ();
029: simulationThread = new Thread(new Runnable() {
030:
031: public void run() {
032: symulacja.start();
033: //Do something in a thread
034: }
035: });
036: simulationThread.start();
037: symulacja.setPause(true);
038: }
039:
040: /**
041: * This method is called from within the constructor to
042: * initialize the jaiGUI.
043: * WARNING: Do NOT modify this code. The content of this method is
044: * always regenerated by the Form Editor.
045: */
046: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
047: private void initComponents() {
048: jButton1 = new javax.swing.JButton();
049: jLabel2 = new javax.swing.JLabel();
050: jLabel3 = new javax.swing.JLabel();
051: jLabel4 = new javax.swing.JLabel();
052: xMasaLabel1 = new javax.swing.JLabel();
053: yMasaLabel1 = new javax.swing.JLabel();
054: zMasaLabel1 = new javax.swing.JLabel();
055: jLabel1 = new javax.swing.JLabel();
056: jLabel5 = new javax.swing.JLabel();
057: MasaLabel = new javax.swing.JLabel();
058: jLabel6 = new javax.swing.JLabel();
059: jLabel7 = new javax.swing.JLabel();
060: MasaTextHi = new javax.swing.JTextField();
061: MasaTextLo = new javax.swing.JTextField();
062: jButton2 = new javax.swing.JButton();
063: jButton3 = new javax.swing.JButton();
064: jMenuBar1 = new javax.swing.JMenuBar();
065: EditMenu = new javax.swing.JMenu();
066: MenuPozycja1 = new javax.swing.JMenuItem();
067: MenuPozycja2 = new javax.swing.JMenuItem();
068: MenuPozycja3 = new javax.swing.JMenuItem();
069:
070: setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
071: jButton1.setText("Start");
072: jButton1.addActionListener(new java.awt.event.ActionListener() {
073: public void actionPerformed(java.awt.event.ActionEvent evt) {
074: jButton1ActionPerformed(evt);
075: }
076: });
077:
078: jLabel2.setText("x=");
079:
080: jLabel3.setText("y=");
081:
082: jLabel4.setText("z=");
083:
084: xMasaLabel1.setAlignmentY(0.0F);
085: xMasaLabel1.setBorder(new javax.swing.border.SoftBevelBorder(
086: javax.swing.border.BevelBorder.RAISED));
087: xMasaLabel1.addKeyListener(new java.awt.event.KeyAdapter() {
088: public void keyTyped(java.awt.event.KeyEvent evt) {
089: xMasaLabel1KeyTyped(evt);
090: }
091: });
092:
093: yMasaLabel1.setAlignmentY(0.0F);
094: yMasaLabel1.setBorder(new javax.swing.border.SoftBevelBorder(
095: javax.swing.border.BevelBorder.RAISED));
096:
097: zMasaLabel1.setAlignmentY(0.0F);
098: zMasaLabel1.setBorder(new javax.swing.border.SoftBevelBorder(
099: javax.swing.border.BevelBorder.RAISED));
100:
101: jLabel1.setText("\u015arodek ci\u0119\u017cko\u015bci:");
102:
103: jLabel5.setText("Masa tu\u0142owia:");
104:
105: jLabel6.setText("Masa Hi:");
106:
107: jLabel7.setText("Masa Lo:");
108:
109: jButton2.setText("Zmie\u0144");
110: jButton2.addActionListener(new java.awt.event.ActionListener() {
111: public void actionPerformed(java.awt.event.ActionEvent evt) {
112: jButton2ActionPerformed(evt);
113: }
114: });
115:
116: jButton3.setText("jButton3");
117: jButton3.addActionListener(new java.awt.event.ActionListener() {
118: public void actionPerformed(java.awt.event.ActionEvent evt) {
119: jButton3ActionPerformed(evt);
120: }
121: });
122:
123: EditMenu.setLabel("Edycja");
124: MenuPozycja1.setLabel("Pozycja 1");
125: MenuPozycja1
126: .addActionListener(new java.awt.event.ActionListener() {
127: public void actionPerformed(
128: java.awt.event.ActionEvent evt) {
129: MenuPozycja1ActionPerformed(evt);
130: }
131: });
132:
133: EditMenu.add(MenuPozycja1);
134:
135: MenuPozycja2.setLabel("Pozycja 2");
136: MenuPozycja2
137: .addActionListener(new java.awt.event.ActionListener() {
138: public void actionPerformed(
139: java.awt.event.ActionEvent evt) {
140: MenuPozycja2ActionPerformed(evt);
141: }
142: });
143:
144: EditMenu.add(MenuPozycja2);
145:
146: MenuPozycja3.setLabel("Pozycja 3");
147: MenuPozycja3
148: .addActionListener(new java.awt.event.ActionListener() {
149: public void actionPerformed(
150: java.awt.event.ActionEvent evt) {
151: MenuPozycja3ActionPerformed(evt);
152: }
153: });
154:
155: EditMenu.add(MenuPozycja3);
156:
157: jMenuBar1.add(EditMenu);
158:
159: setJMenuBar(jMenuBar1);
160:
161: javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
162: getContentPane());
163: getContentPane().setLayout(layout);
164: layout
165: .setHorizontalGroup(layout
166: .createParallelGroup(
167: javax.swing.GroupLayout.Alignment.LEADING)
168: .addGroup(
169: layout
170: .createSequentialGroup()
171: .addContainerGap()
172: .addGroup(
173: layout
174: .createParallelGroup(
175: javax.swing.GroupLayout.Alignment.LEADING)
176: .addGroup(
177: layout
178: .createSequentialGroup()
179: .addGroup(
180: layout
181: .createParallelGroup(
182: javax.swing.GroupLayout.Alignment.LEADING)
183: .addComponent(
184: jButton1)
185: .addGroup(
186: layout
187: .createParallelGroup(
188: javax.swing.GroupLayout.Alignment.LEADING)
189: .addGroup(
190: layout
191: .createSequentialGroup()
192: .addComponent(
193: jLabel4)
194: .addPreferredGap(
195: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
196: .addComponent(
197: zMasaLabel1,
198: javax.swing.GroupLayout.DEFAULT_SIZE,
199: 62,
200: Short.MAX_VALUE))
201: .addGroup(
202: layout
203: .createSequentialGroup()
204: .addComponent(
205: jLabel3)
206: .addPreferredGap(
207: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
208: .addComponent(
209: yMasaLabel1,
210: javax.swing.GroupLayout.DEFAULT_SIZE,
211: 62,
212: Short.MAX_VALUE))
213: .addGroup(
214: layout
215: .createSequentialGroup()
216: .addComponent(
217: jLabel2)
218: .addPreferredGap(
219: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
220: .addComponent(
221: xMasaLabel1,
222: javax.swing.GroupLayout.DEFAULT_SIZE,
223: 62,
224: Short.MAX_VALUE))))
225: .addGap(
226: 74,
227: 74,
228: 74))
229: .addGroup(
230: layout
231: .createSequentialGroup()
232: .addComponent(
233: jLabel1)
234: .addGap(
235: 52,
236: 52,
237: 52)))
238: .addGroup(
239: layout
240: .createParallelGroup(
241: javax.swing.GroupLayout.Alignment.LEADING)
242: .addGroup(
243: layout
244: .createSequentialGroup()
245: .addComponent(
246: jLabel5)
247: .addPreferredGap(
248: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
249: .addComponent(
250: MasaLabel,
251: javax.swing.GroupLayout.PREFERRED_SIZE,
252: 64,
253: javax.swing.GroupLayout.PREFERRED_SIZE))
254: .addGroup(
255: layout
256: .createSequentialGroup()
257: .addGroup(
258: layout
259: .createParallelGroup(
260: javax.swing.GroupLayout.Alignment.LEADING)
261: .addComponent(
262: jLabel6)
263: .addComponent(
264: jLabel7))
265: .addPreferredGap(
266: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
267: .addGroup(
268: layout
269: .createParallelGroup(
270: javax.swing.GroupLayout.Alignment.LEADING,
271: false)
272: .addComponent(
273: MasaTextLo)
274: .addComponent(
275: MasaTextHi,
276: javax.swing.GroupLayout.DEFAULT_SIZE,
277: 53,
278: Short.MAX_VALUE)))
279: .addComponent(
280: jButton2)
281: .addGroup(
282: layout
283: .createSequentialGroup()
284: .addPreferredGap(
285: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
286: .addComponent(
287: jButton3)))
288: .addContainerGap(101,
289: Short.MAX_VALUE)));
290:
291: layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
292: new java.awt.Component[] { jLabel3, jLabel4 });
293:
294: layout
295: .setVerticalGroup(layout
296: .createParallelGroup(
297: javax.swing.GroupLayout.Alignment.LEADING)
298: .addGroup(
299: layout
300: .createSequentialGroup()
301: .addContainerGap()
302: .addGroup(
303: layout
304: .createParallelGroup(
305: javax.swing.GroupLayout.Alignment.LEADING,
306: false)
307: .addGroup(
308: layout
309: .createSequentialGroup()
310: .addGroup(
311: layout
312: .createParallelGroup(
313: javax.swing.GroupLayout.Alignment.BASELINE)
314: .addComponent(
315: jLabel5)
316: .addComponent(
317: MasaLabel,
318: javax.swing.GroupLayout.PREFERRED_SIZE,
319: 11,
320: javax.swing.GroupLayout.PREFERRED_SIZE))
321: .addPreferredGap(
322: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
323: .addGroup(
324: layout
325: .createParallelGroup(
326: javax.swing.GroupLayout.Alignment.BASELINE)
327: .addComponent(
328: jLabel6)
329: .addComponent(
330: MasaTextHi,
331: javax.swing.GroupLayout.PREFERRED_SIZE,
332: 20,
333: javax.swing.GroupLayout.PREFERRED_SIZE))
334: .addPreferredGap(
335: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
336: .addGroup(
337: layout
338: .createParallelGroup(
339: javax.swing.GroupLayout.Alignment.BASELINE)
340: .addComponent(
341: jLabel7)
342: .addComponent(
343: MasaTextLo,
344: javax.swing.GroupLayout.PREFERRED_SIZE,
345: javax.swing.GroupLayout.DEFAULT_SIZE,
346: javax.swing.GroupLayout.PREFERRED_SIZE))
347: .addPreferredGap(
348: javax.swing.LayoutStyle.ComponentPlacement.RELATED,
349: javax.swing.GroupLayout.DEFAULT_SIZE,
350: Short.MAX_VALUE)
351: .addComponent(
352: jButton2))
353: .addGroup(
354: layout
355: .createSequentialGroup()
356: .addComponent(
357: jButton1)
358: .addGap(
359: 30,
360: 30,
361: 30)
362: .addComponent(
363: jLabel1)
364: .addPreferredGap(
365: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
366: .addGroup(
367: layout
368: .createParallelGroup(
369: javax.swing.GroupLayout.Alignment.LEADING,
370: false)
371: .addComponent(
372: jLabel2,
373: javax.swing.GroupLayout.PREFERRED_SIZE,
374: 28,
375: javax.swing.GroupLayout.PREFERRED_SIZE)
376: .addGroup(
377: layout
378: .createSequentialGroup()
379: .addPreferredGap(
380: javax.swing.LayoutStyle.ComponentPlacement.RELATED,
381: 5,
382: Short.MAX_VALUE)
383: .addComponent(
384: xMasaLabel1,
385: javax.swing.GroupLayout.PREFERRED_SIZE,
386: 23,
387: javax.swing.GroupLayout.PREFERRED_SIZE)))))
388: .addPreferredGap(
389: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
390: .addGroup(
391: layout
392: .createParallelGroup(
393: javax.swing.GroupLayout.Alignment.TRAILING)
394: .addComponent(
395: jLabel3,
396: javax.swing.GroupLayout.DEFAULT_SIZE,
397: 28,
398: Short.MAX_VALUE)
399: .addComponent(
400: yMasaLabel1,
401: javax.swing.GroupLayout.PREFERRED_SIZE,
402: 19,
403: javax.swing.GroupLayout.PREFERRED_SIZE))
404: .addPreferredGap(
405: javax.swing.LayoutStyle.ComponentPlacement.RELATED)
406: .addGroup(
407: layout
408: .createParallelGroup(
409: javax.swing.GroupLayout.Alignment.TRAILING)
410: .addGroup(
411: layout
412: .createParallelGroup(
413: javax.swing.GroupLayout.Alignment.TRAILING,
414: false)
415: .addComponent(
416: zMasaLabel1,
417: javax.swing.GroupLayout.DEFAULT_SIZE,
418: javax.swing.GroupLayout.DEFAULT_SIZE,
419: Short.MAX_VALUE)
420: .addComponent(
421: jLabel4))
422: .addComponent(
423: jButton3))
424: .addContainerGap(74,
425: Short.MAX_VALUE)));
426:
427: layout.linkSize(javax.swing.SwingConstants.VERTICAL,
428: new java.awt.Component[] { jLabel3, jLabel4 });
429:
430: layout.linkSize(javax.swing.SwingConstants.VERTICAL,
431: new java.awt.Component[] { xMasaLabel1, yMasaLabel1,
432: zMasaLabel1 });
433:
434: pack();
435: }// </editor-fold>//GEN-END:initComponents
436:
437: private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
438: // TODO add your handling code here:
439: }//GEN-LAST:event_jButton3ActionPerformed
440:
441: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
442:
443: }//GEN-LAST:event_jButton2ActionPerformed
444:
445: private void xMasaLabel1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_xMasaLabel1KeyTyped
446: // TODO add your handling code here:
447: }//GEN-LAST:event_xMasaLabel1KeyTyped
448:
449: private void MenuPozycja3ActionPerformed(
450: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuPozycja3ActionPerformed
451: }//GEN-LAST:event_MenuPozycja3ActionPerformed
452:
453: private void MenuPozycja2ActionPerformed(
454: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuPozycja2ActionPerformed
455: }//GEN-LAST:event_MenuPozycja2ActionPerformed
456:
457: private void MenuPozycja1ActionPerformed(
458: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuPozycja1ActionPerformed
459: }//GEN-LAST:event_MenuPozycja1ActionPerformed
460:
461: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
462:
463: if (symulacja.getPause()) {
464: jButton1.setText("Stop");
465: symulacja.setPause(false);
466: } else {
467:
468: jButton1.setText("Start");
469: symulacja.setPause(true);
470: }
471:
472: // symulacja.notify();
473: }//GEN-LAST:event_jButton1ActionPerformed
474:
475: /**
476: * @param args the command line arguments
477: */
478: public static void main(String args[]) {
479: java.awt.EventQueue.invokeLater(new Runnable() {
480: public void run() {
481: new jaiGUI().setVisible(true);
482: };
483: });
484:
485: }
486:
487: // // Od�wierzanie danych co 500 milisekund
488:
489: // fTimer.schedule(new PaintHisTask() ,500); // NIE DZIA�A :(
490:
491: class PaintHistTask extends java.util.TimerTask {
492: public void run() {
493: xMasaLabel1.setText(String.valueOf(symulacja.getAktor()
494: .getCenterOfGravity().getX()));
495: yMasaLabel1.setText(String.valueOf(symulacja.getAktor()
496: .getCenterOfGravity().getY()));
497: zMasaLabel1.setText(String.valueOf(symulacja.getAktor()
498: .getCenterOfGravity().getZ()));
499: // float masa=symulacja.getAktor().getTummyHi().getMass()+symulacja.getAktor().getTummyLo().getMass();
500: // MasaLabel.setText(String.valueOf(masa));
501: }
502:
503: };
504:
505: // Variables declaration - do not modify//GEN-BEGIN:variables
506: private javax.swing.JMenu EditMenu;
507: private javax.swing.JLabel MasaLabel;
508: private javax.swing.JTextField MasaTextHi;
509: private javax.swing.JTextField MasaTextLo;
510: private javax.swing.JMenuItem MenuPozycja1;
511: private javax.swing.JMenuItem MenuPozycja2;
512: private javax.swing.JMenuItem MenuPozycja3;
513: private javax.swing.JButton jButton1;
514: private javax.swing.JButton jButton2;
515: private javax.swing.JButton jButton3;
516: private javax.swing.JLabel jLabel1;
517: private javax.swing.JLabel jLabel2;
518: private javax.swing.JLabel jLabel3;
519: private javax.swing.JLabel jLabel4;
520: private javax.swing.JLabel jLabel5;
521: private javax.swing.JLabel jLabel6;
522: private javax.swing.JLabel jLabel7;
523: private javax.swing.JMenuBar jMenuBar1;
524: private javax.swing.JLabel xMasaLabel1;
525: private javax.swing.JLabel yMasaLabel1;
526: private javax.swing.JLabel zMasaLabel1;
527: // End of variables declaration//GEN-END:variables
528:
529: }
|