Simple single-color 8x8x8 LED Cube with AVRs
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

frame.java 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5. import java.io.File;
  6. import com.sun.j3d.utils.universe.*;
  7. import com.sun.j3d.utils.geometry.*;
  8. import javax.media.j3d.*;
  9. import javax.vecmath.*;
  10. /*
  11. * frame.java
  12. *
  13. *
  14. * Copyright 2011 Thomas Buck <xythobuz@me.com>
  15. * Copyright 2011 Max Nuding <max.nuding@gmail.com>
  16. * Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
  17. *
  18. * This file is part of LED-Cube.
  19. *
  20. * LED-Cube is free software: you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation, either version 3 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * LED-Cube is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License
  31. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  32. */
  33. public class frame extends JFrame implements ListSelectionListener {
  34. // Anfang Variablen
  35. private GraphicsConfiguration gConfig = SimpleUniverse.getPreferredConfiguration();
  36. private Canvas3D cubeCanvas = new Canvas3D(gConfig);
  37. SimpleUniverse universe;
  38. Transform3D transform3d;
  39. TransformGroup transroot;
  40. BranchGroup branchgroup;
  41. // Anfang Attribute
  42. private JButton editA = new JButton();
  43. private JButton editB = new JButton();
  44. private JButton editC = new JButton();
  45. private JButton editD = new JButton();
  46. private JButton editE = new JButton();
  47. private JButton editF = new JButton();
  48. private JButton editG = new JButton();
  49. private JButton editH = new JButton();
  50. private DefaultListModel frameListModel = new DefaultListModel();
  51. private JList frameList = new JList();
  52. private JScrollPane frameListScrollPane = new JScrollPane(frameList);
  53. private JButton frameUp = new JButton();
  54. private JButton frameDown = new JButton();
  55. private JButton frameAdd = new JButton();
  56. private JButton frameRemove = new JButton();
  57. private JButton frame = new JButton();
  58. private JList animList = new JList();
  59. private DefaultListModel animModel = new DefaultListModel();
  60. private JScrollPane animScrollPane = new JScrollPane(animList);
  61. private JButton animUp = new JButton();
  62. private JButton animDown = new JButton();
  63. private JButton animAdd = new JButton();
  64. private JButton animRemove = new JButton();
  65. private JTextField animPath = new JTextField();
  66. private JButton load = new JButton();
  67. private JButton save = new JButton();
  68. private JButton saveAs = new JButton();
  69. private JComboBox jComboBox1 = new JComboBox();
  70. private JButton upload = new JButton();
  71. private JButton download = new JButton();
  72. private JLabel jLabel4 = new JLabel();
  73. private JTextField frameRemaining = new JTextField();
  74. // Ende Attribute
  75. private cubeWorker worker = new cubeWorker();
  76. private boolean fileSelected = false;
  77. // Ende Variablen
  78. private int saveExitDialog() {
  79. String[] Optionen = {"Yes", "No"};
  80. int Auswahl = JOptionPane.showOptionDialog(this, "Do you want to save your changes?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
  81. if (Auswahl == JOptionPane.YES_OPTION) {
  82. worker.saveState(animPath.getText());
  83. return 1;
  84. } else {
  85. return 0;
  86. }
  87. }
  88. private void errorMessage(String s) {
  89. String[] Optionen = {"OK"};
  90. JOptionPane.showOptionDialog(this, s, "Error!", JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE, null, Optionen, Optionen[0]);
  91. }
  92. public void valueChanged(ListSelectionEvent evt) {
  93. if ((!evt.getValueIsAdjusting()) && (evt.getSource() != animList) && (evt.getSource() != frameList)) {
  94. DefaultListModel model = (DefaultListModel)((JList)evt.getSource()).getModel();
  95. int anim = animList.getSelectedIndex();
  96. int max;
  97. if(evt.getSource() == animList){
  98. max = worker.numOfAnimations();
  99. System.out.println(max);
  100. } else {
  101. max = worker.numOfFrames(animList.getSelectedIndex());
  102. }
  103. if (anim == -1){
  104. anim = 0;
  105. }
  106. model.clear();
  107. for (int i = 0; i < max; i++) {
  108. if(evt.getSource() == animList){
  109. model.add(i, worker.getAnimationName(i));
  110. } else {
  111. model.add(i, worker.getFrameName(anim, i));
  112. }
  113. }
  114. frameList.setModel(model);
  115. }
  116. }
  117. public frame(String title) {
  118. // Frame-Initialisierung
  119. super(title);
  120. String[] sPorts = worker.getSerialPorts();
  121. for(int i = 0; i < sPorts.length; i++){
  122. jComboBox1.addItem(sPorts[i]);
  123. }
  124. for(int i = 0; i < worker.numOfAnimations(); i++){
  125. animModel.addElement(worker.getAnimationName(i));
  126. }
  127. addWindowListener(new WindowAdapter() {
  128. public void windowClosing(WindowEvent evt) {
  129. if (worker.changedStateSinceSave()) {
  130. saveExitDialog();
  131. }
  132. System.exit(0);
  133. }
  134. });
  135. int frameWidth = 661;
  136. int frameHeight = 417;
  137. setSize(frameWidth, frameHeight);
  138. Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
  139. int x = (d.width - getSize().width) / 2;
  140. int y = (d.height - getSize().height) / 2 ;
  141. setLocation(x, y);
  142. Container cp = getContentPane();
  143. cp.setLayout(null);
  144. // Anfang Komponenten
  145. //----- 3D-----
  146. //-------------
  147. cubeCanvas.setBounds(8, 8, 250, 250);
  148. cp.add(cubeCanvas);
  149. ColorCube cube1 = new ColorCube(0.3);
  150. universe = new SimpleUniverse(cubeCanvas);
  151. universe.getViewingPlatform().setNominalViewingTransform();
  152. transform3d = new Transform3D();
  153. transroot = new TransformGroup(transform3d);
  154. transform3d.rotZ (Math.toRadians(30));
  155. transroot.addChild(cube1);
  156. transform3d.setTranslation(new Vector3d(2,2,2));
  157. branchgroup = new BranchGroup();
  158. branchgroup.addChild(transroot);
  159. universe.addBranchGraph(branchgroup);
  160. //-------------
  161. editA.setBounds(264, 8, 107, 25);
  162. editA.setText("Layer A");
  163. editA.setFont(new Font("Dialog", Font.PLAIN, 13));
  164. cp.add(editA);
  165. editA.addActionListener(new ActionListener() {
  166. public void actionPerformed(ActionEvent evt) {
  167. editA_ActionPerformed(evt);
  168. }
  169. });
  170. editB.setBounds(264, 40, 107, 25);
  171. editB.setText("Layer B");
  172. editB.setFont(new Font("Dialog", Font.PLAIN, 13));
  173. cp.add(editB);
  174. editB.addActionListener(new ActionListener() {
  175. public void actionPerformed(ActionEvent evt) {
  176. editB_ActionPerformed(evt);
  177. }
  178. });
  179. editC.setBounds(264, 72, 107, 25);
  180. editC.setText("Layer C");
  181. editC.setFont(new Font("Dialog", Font.PLAIN, 13));
  182. cp.add(editC);
  183. editC.addActionListener(new ActionListener() {
  184. public void actionPerformed(ActionEvent evt) {
  185. editC_ActionPerformed(evt);
  186. }
  187. });
  188. editD.setBounds(264, 104, 107, 25);
  189. editD.setText("Layer D");
  190. editD.setFont(new Font("Dialog", Font.PLAIN, 13));
  191. cp.add(editD);
  192. editD.addActionListener(new ActionListener() {
  193. public void actionPerformed(ActionEvent evt) {
  194. editD_ActionPerformed(evt);
  195. }
  196. });
  197. editE.setBounds(264, 136, 107, 25);
  198. editE.setText("Layer E");
  199. editE.setFont(new Font("Dialog", Font.PLAIN, 13));
  200. cp.add(editE);
  201. editE.addActionListener(new ActionListener() {
  202. public void actionPerformed(ActionEvent evt) {
  203. editE_ActionPerformed(evt);
  204. }
  205. });
  206. editF.setBounds(264, 168, 107, 25);
  207. editF.setText("Layer F");
  208. editF.setFont(new Font("Dialog", Font.PLAIN, 13));
  209. cp.add(editF);
  210. editF.addActionListener(new ActionListener() {
  211. public void actionPerformed(ActionEvent evt) {
  212. editF_ActionPerformed(evt);
  213. }
  214. });
  215. editG.setBounds(264, 200, 107, 25);
  216. editG.setText("Layer G");
  217. editG.setFont(new Font("Dialog", Font.PLAIN, 13));
  218. cp.add(editG);
  219. editG.addActionListener(new ActionListener() {
  220. public void actionPerformed(ActionEvent evt) {
  221. editG_ActionPerformed(evt);
  222. }
  223. });
  224. editH.setBounds(264, 232, 107, 25);
  225. editH.setText("Layer H");
  226. editH.setFont(new Font("Dialog", Font.PLAIN, 13));
  227. cp.add(editH);
  228. editH.addActionListener(new ActionListener() {
  229. public void actionPerformed(ActionEvent evt) {
  230. editH_ActionPerformed(evt);
  231. }
  232. });
  233. frameListScrollPane.setBounds(384, 8, 145, 249);
  234. frameList.setModel(frameListModel);
  235. //frameListModel.addElement();
  236. cp.add(frameListScrollPane);
  237. frameUp.setBounds(544, 8, 107, 33);
  238. frameUp.setText("Move up");
  239. frameUp.setFont(new Font("Dialog", Font.PLAIN, 13));
  240. cp.add(frameUp);
  241. frameUp.addActionListener(new ActionListener() {
  242. public void actionPerformed(ActionEvent evt) {
  243. frameUp_ActionPerformed(evt);
  244. }
  245. });
  246. frameDown.setBounds(544, 152, 107, 33);
  247. frameDown.setText("Move down");
  248. frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
  249. cp.add(frameDown);
  250. frameDown.addActionListener(new ActionListener() {
  251. public void actionPerformed(ActionEvent evt) {
  252. frameDown_ActionPerformed(evt);
  253. }
  254. });
  255. frameAdd.setBounds(544, 56, 107, 33);
  256. frameAdd.setText("Add");
  257. frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
  258. cp.add(frameAdd);
  259. frameAdd.addActionListener(new ActionListener() {
  260. public void actionPerformed(ActionEvent evt) {
  261. frameAdd_ActionPerformed(evt);
  262. }
  263. });
  264. frameRemove.setBounds(544, 104, 107, 33);
  265. frameRemove.setText("Remove");
  266. frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
  267. cp.add(frameRemove);
  268. frameRemove.addActionListener(new ActionListener() {
  269. public void actionPerformed(ActionEvent evt) {
  270. frameRemove_ActionPerformed(evt);
  271. }
  272. });
  273. animScrollPane.setBounds(8, 264, 209, 121);
  274. animList.setModel(animModel);
  275. //jList2Model.addElement("");
  276. cp.add(animScrollPane);
  277. animUp.setBounds(224, 264, 99, 25);
  278. animUp.setText("Move up");
  279. animUp.setFont(new Font("Dialog", Font.PLAIN, 13));
  280. cp.add(animUp);
  281. animUp.addActionListener(new ActionListener() {
  282. public void actionPerformed(ActionEvent evt) {
  283. animUp_ActionPerformed(evt);
  284. }
  285. });
  286. animDown.setBounds(224, 360, 99, 25);
  287. animDown.setText("Move down");
  288. animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
  289. cp.add(animDown);
  290. animDown.addActionListener(new ActionListener() {
  291. public void actionPerformed(ActionEvent evt) {
  292. animDown_ActionPerformed(evt);
  293. }
  294. });
  295. animAdd.setBounds(224, 296, 99, 25);
  296. animAdd.setText("Add");
  297. animAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
  298. cp.add(animAdd);
  299. animAdd.addActionListener(new ActionListener() {
  300. public void actionPerformed(ActionEvent evt) {
  301. animAdd_ActionPerformed(evt);
  302. }
  303. });
  304. animRemove.setBounds(224, 328, 99, 25);
  305. animRemove.setText("Remove");
  306. animRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
  307. cp.add(animRemove);
  308. animRemove.addActionListener(new ActionListener() {
  309. public void actionPerformed(ActionEvent evt) {
  310. animRemove_ActionPerformed(evt);
  311. }
  312. });
  313. animPath.setBounds(344, 264, 305, 24);
  314. animPath.setEditable(false);
  315. animPath.setText("Load/Save an animation file...");
  316. animPath.setFont(new Font("Dialog", Font.PLAIN, 13));
  317. cp.add(animPath);
  318. load.setBounds(344, 296, 100, 25);
  319. load.setText("Load");
  320. load.setFont(new Font("Dialog", Font.PLAIN, 13));
  321. cp.add(load);
  322. load.addActionListener(new ActionListener() {
  323. public void actionPerformed(ActionEvent evt) {
  324. load_ActionPerformed(evt);
  325. }
  326. });
  327. save.setBounds(454, 296, 100, 25);
  328. save.setText("Save");
  329. save.setFont(new Font("Dialog", Font.PLAIN, 13));
  330. cp.add(save);
  331. save.addActionListener(new ActionListener() {
  332. public void actionPerformed(ActionEvent evt) {
  333. save_ActionPerformed(evt);
  334. }
  335. });
  336. saveAs.setBounds(564, 296, 90, 25);
  337. saveAs.setText("Save As");
  338. saveAs.setFont(new Font("Dialog", Font.PLAIN, 13));
  339. cp.add(saveAs);
  340. saveAs.addActionListener(new ActionListener() {
  341. public void actionPerformed(ActionEvent evt) {
  342. saveAs_ActionPerformed(evt);
  343. }
  344. });
  345. jComboBox1.setBounds(344, 328, 305, 24);
  346. jComboBox1.setFont(new Font("Dialog", Font.PLAIN, 13));
  347. cp.add(jComboBox1);
  348. upload.setBounds(344, 360, 147, 25);
  349. upload.setText("Upload");
  350. upload.setFont(new Font("Dialog", Font.PLAIN, 13));
  351. cp.add(upload);
  352. upload.addActionListener(new ActionListener() {
  353. public void actionPerformed(ActionEvent evt) {
  354. upload_ActionPerformed(evt);
  355. }
  356. });
  357. download.setBounds(504, 360, 147, 25);
  358. download.setText("Download");
  359. download.setFont(new Font("Dialog", Font.PLAIN, 13));
  360. cp.add(download);
  361. download.addActionListener(new ActionListener() {
  362. public void actionPerformed(ActionEvent evt) {
  363. download_ActionPerformed(evt);
  364. }
  365. });
  366. jLabel4.setBounds(536, 208, 112, 20);
  367. jLabel4.setText("Frames remaining:");
  368. jLabel4.setFont(new Font("Dialog", Font.PLAIN, 13));
  369. cp.add(jLabel4);
  370. frameRemaining.setBounds(536, 232, 113, 24);
  371. frameRemaining.setEditable(false);
  372. frameRemaining.setText("2048");
  373. frameRemaining.setFont(new Font("Dialog", Font.PLAIN, 13));
  374. cp.add(frameRemaining);
  375. animList.setFont(new Font("Dialog", Font.PLAIN, 13));
  376. frameList.setFont(new Font("Dialog", Font.PLAIN, 13));
  377. // Ende Komponenten
  378. animList.addListSelectionListener(this);
  379. setResizable(false);
  380. setVisible(true);
  381. }
  382. // Anfang Methoden
  383. // Anfang Ereignisprozeduren
  384. public void editA_ActionPerformed(ActionEvent evt) {
  385. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(0));
  386. }
  387. public void editB_ActionPerformed(ActionEvent evt) {
  388. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(1));
  389. }
  390. public void editC_ActionPerformed(ActionEvent evt) {
  391. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(2));
  392. }
  393. public void editD_ActionPerformed(ActionEvent evt) {
  394. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(3));
  395. }
  396. public void editE_ActionPerformed(ActionEvent evt) {
  397. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(4));
  398. }
  399. public void editF_ActionPerformed(ActionEvent evt) {
  400. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(5));
  401. }
  402. public void editG_ActionPerformed(ActionEvent evt) {
  403. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(6));
  404. }
  405. public void editH_ActionPerformed(ActionEvent evt) {
  406. // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(7));
  407. }
  408. public void frameUp_ActionPerformed(ActionEvent evt) {
  409. int i = frameList.getSelectedIndex();
  410. if ((i > 0) && (frameListModel.getSize() >= 2)) {
  411. Object tmp = frameListModel.get(i);
  412. frameListModel.set(i, frameListModel.get(i - 1));
  413. frameListModel.set(i - 1, tmp);
  414. frameList.setSelectedIndex(i - 1);
  415. worker.moveFrame(worker.UP, animList.getSelectedIndex(), frameList.getSelectedIndex());
  416. }
  417. }
  418. public void frameDown_ActionPerformed(ActionEvent evt) {
  419. int i = frameList.getSelectedIndex();
  420. if ((i >= 0) && (frameListModel.getSize() >= 2) && (i < (frameListModel.getSize() - 1))) {
  421. Object tmp = frameListModel.get(i);
  422. frameListModel.set(i, frameListModel.get(i + 1));
  423. frameListModel.set(i + 1, tmp);
  424. frameList.setSelectedIndex(i + 1);
  425. worker.moveFrame(worker.DOWN, animList.getSelectedIndex(), frameList.getSelectedIndex());
  426. }
  427. }
  428. public void frameAdd_ActionPerformed(ActionEvent evt) {
  429. if(animList.getSelectedIndex() == -1){
  430. errorMessage("Please select an animation!");
  431. } else {
  432. worker.addFrame(animList.getSelectedIndex());
  433. frameRemaining.setText(Integer.toString(worker.framesRemaining()));
  434. int n = worker.numOfFrames(animList.getSelectedIndex()) - 1;
  435. if (n < 0) {
  436. n = 0;
  437. }
  438. frameListModel.add(n, worker.getFrameName(animList.getSelectedIndex(), n));
  439. frameList.setModel(frameListModel);
  440. }
  441. }
  442. public void frameRemove_ActionPerformed(ActionEvent evt) {
  443. worker.removeFrame(animList.getSelectedIndex(), frameList.getSelectedIndex());
  444. frameRemaining.setText(Integer.toString(worker.framesRemaining()));
  445. frameListModel.removeElementAt(frameList.getSelectedIndex());
  446. frameList.setModel(frameListModel);
  447. }
  448. public void animUp_ActionPerformed(ActionEvent evt) {
  449. int i = animList.getSelectedIndex();
  450. if ((i > 0) && (animModel.getSize() >= 2)) {
  451. Object tmp = animModel.get(i);
  452. animModel.set(i, animModel.get(i - 1));
  453. animModel.set(i - 1, tmp);
  454. animList.setSelectedIndex(i - 1);
  455. worker.moveAnimation(worker.UP, animList.getSelectedIndex());
  456. }
  457. }
  458. public void animDown_ActionPerformed(ActionEvent evt) {
  459. int i = animList.getSelectedIndex();
  460. if ((i >= 0) && (animModel.getSize() >= 2) && (i < (animModel.getSize() - 1))) {
  461. Object tmp = animModel.get(i);
  462. animModel.set(i, animModel.get(i + 1));
  463. animModel.set(i + 1, tmp);
  464. animList.setSelectedIndex(i + 1);
  465. worker.moveAnimation(worker.DOWN, animList.getSelectedIndex());
  466. }
  467. }
  468. public void animAdd_ActionPerformed(ActionEvent evt) {
  469. if(worker.addAnimation() == -1){
  470. errorMessage("Could not add animation!");
  471. } else {
  472. int n = worker.numOfAnimations() - 1;
  473. if (n < 0) {
  474. n = 0;
  475. }
  476. animModel.clear();
  477. System.out.println(n);
  478. animModel.addElement(worker.getAnimationName(n));
  479. animList.setModel(animModel);
  480. }
  481. }
  482. public void animRemove_ActionPerformed(ActionEvent evt) {
  483. worker.removeAnimation(animList.getSelectedIndex());
  484. animModel.removeElementAt(animList.getSelectedIndex());
  485. animList.setModel(animModel);
  486. }
  487. public void load_ActionPerformed(ActionEvent evt) {
  488. JFileChooser fc = new JFileChooser();
  489. int ret = fc.showOpenDialog(this);
  490. if (ret == JFileChooser.APPROVE_OPTION) {
  491. File file = fc.getSelectedFile();
  492. if (fileSelected == false) {
  493. fileSelected = true;
  494. }
  495. animPath.setText(file.getPath());
  496. worker.loadState(animPath.getText());
  497. }
  498. }
  499. public void save_ActionPerformed(ActionEvent evt) {
  500. if (fileSelected == false) {
  501. JFileChooser fc = new JFileChooser();
  502. int ret = fc.showSaveDialog(this);
  503. if (ret == JFileChooser.APPROVE_OPTION) {
  504. File file = fc.getSelectedFile();
  505. fileSelected = true;
  506. animPath.setText(file.getPath());
  507. worker.saveState(animPath.getText());
  508. }
  509. } else {
  510. worker.saveState(animPath.getText());
  511. }
  512. }
  513. public void saveAs_ActionPerformed(ActionEvent evt) {
  514. JFileChooser fc;
  515. if (fileSelected == true) {
  516. fc = new JFileChooser(new File(animPath.getText()).getParentFile());
  517. } else {
  518. fc = new JFileChooser();
  519. }
  520. int ret = fc.showSaveDialog(this);
  521. if (ret == JFileChooser.APPROVE_OPTION) {
  522. File file = fc.getSelectedFile();
  523. if (fileSelected == false) {
  524. fileSelected = true;
  525. }
  526. animPath.setText(file.getPath());
  527. worker.saveState(animPath.getText());
  528. }
  529. }
  530. public void upload_ActionPerformed(ActionEvent evt) {
  531. if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
  532. errorMessage("No serial port selected...");
  533. } else {
  534. worker.uploadState((String)jComboBox1.getSelectedItem());
  535. }
  536. }
  537. public void download_ActionPerformed(ActionEvent evt) {
  538. if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
  539. errorMessage("No serial port selected...");
  540. } else {
  541. worker.downloadState((String)jComboBox1.getSelectedItem());
  542. }
  543. }
  544. // Ende Ereignisprozeduren
  545. public static void main(String[] args) {
  546. new frame("Cube Control");
  547. }
  548. // Ende Methoden
  549. }