Java.io help!!!

Reply

Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Java.io help!!!

 
0
  #1
Mar 5th, 2005
Hi:

I'm writing my own programming language and I wanted to be able to save the code. When I compile i get this error message:

"cml.java": cannot resolve symbol: constructor cml (int[],int[],java.lang.String)in class cml at line 439, column 13

Here's the code:
  1. //Cinnamon Machine Language Compiler
  2.  
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5.  
  6. import java.awt.*;
  7. import java.awt.event.*;
  8.  
  9. import java.io.*;
  10.  
  11.  
  12. public class cml extends JFrame {
  13.  
  14. public String resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***";
  15.  
  16. JTextArea result = new JTextArea(resultS,20,10);
  17. JTextField inputCode = new JTextField("CODE");
  18.  
  19. public Icon icn = new ImageIcon("icn.gif");
  20. public Icon icn2 = new ImageIcon("icn2.gif");
  21.  
  22. public JPopupMenu popupMenu;
  23.  
  24. private ObjectOutputStream output;
  25. private ObjectInputStream input;
  26.  
  27. JButton done = new JButton("Done with this C.M.L. line.",icn2);
  28. JButton next = new JButton("Compile.", icn);
  29. JButton reset = new JButton("Reset the compiler.");
  30. JButton help = new JButton("Help me.");
  31. JButton colors = new JButton("Color Scheme.");
  32. JButton save = new JButton("Save...");
  33. JButton open = new JButton("Open...");
  34.  
  35. Color coloring = Color.GREEN;
  36.  
  37. public int [] coder = new int[99];
  38. public int [] coder2 = new int[99];
  39.  
  40. public int i = -1;
  41. public int accum = 0;
  42. public int operand = 0;
  43. public int opCode = 0;
  44. public int x = 0;
  45. public int lines = 0;
  46.  
  47. public int code;
  48. public int in;
  49.  
  50. public final String codes = result.getText();
  51.  
  52. public final int[] Scoder = coder;
  53. public final int[] Scoder2 = coder2;
  54.  
  55. public UIManager.LookAndFeelInfo looks[];
  56.  
  57. public cml(){
  58. //create frame
  59. super("Cinnamon Machine Language (C.M.L.) Compiler");
  60. setSize(750,450);
  61. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  62. setVisible(true);
  63. //done creating frame
  64.  
  65. Container content = getContentPane();
  66. content.setBackground(Color.GRAY);
  67.  
  68. FlowLayout flowManager = new FlowLayout();
  69. content.setLayout(flowManager);
  70.  
  71. reset();
  72.  
  73. popupMenu = new JPopupMenu();
  74. popupMenu.add(save);
  75. popupMenu.add(open);
  76.  
  77. addMouseListener(
  78. new MouseAdapter(){
  79. public void mousePressed(MouseEvent event){
  80. checkForTriggerEvent(event);
  81. }
  82. public void mouseReleased(MouseEvent event){
  83. checkForTriggerEvent(event);
  84. }
  85. private void checkForTriggerEvent(MouseEvent event){
  86. if(event.isPopupTrigger()){
  87. popupMenu.show(
  88. event.getComponent(), event.getX(), event.getY() );
  89. }
  90. }
  91. }
  92. );
  93.  
  94.  
  95. save.addActionListener(
  96.  
  97. new ActionListener() {
  98.  
  99. public void actionPerformed(ActionEvent event) {
  100.  
  101. if(output != null) addRecord();
  102.  
  103. openFile();
  104.  
  105. }
  106. }
  107.  
  108. );
  109.  
  110.  
  111. open.addActionListener(
  112.  
  113. new ActionListener() {
  114.  
  115. public void actionPerformed(ActionEvent event) {
  116.  
  117. openTheFile();
  118.  
  119. }
  120. }
  121.  
  122. );
  123.  
  124.  
  125. addWindowListener(
  126. new WindowAdapter(){
  127. public void windowClosing(WindowEvent event){
  128. closeFile();
  129. }
  130. }
  131. );
  132.  
  133.  
  134.  
  135. content.add(result);
  136. result.setEditable(false);
  137. result.setBackground(coloring);
  138.  
  139.  
  140. content.add(next);
  141. next.setForeground(Color.RED);
  142.  
  143.  
  144. next.addActionListener(
  145.  
  146. new ActionListener() {
  147.  
  148. public void actionPerformed(ActionEvent event) {
  149.  
  150. resultS+="\n\n*** Program loading completed ***\n"+
  151. "*** Program execution begins ***";
  152.  
  153. result.setText(resultS);
  154.  
  155. compile();
  156.  
  157. }
  158. }
  159.  
  160. );
  161.  
  162.  
  163.  
  164. content.add(inputCode);
  165. inputCode.setForeground(Color.BLACK);
  166.  
  167. inputCode.addKeyListener(
  168.  
  169. new KeyListener(){
  170.  
  171. public void keyTyped(KeyEvent event){}
  172. public void keyReleased(KeyEvent event){}
  173.  
  174. public void keyPressed(KeyEvent event) {
  175.  
  176. char key = event.getKeyChar();
  177. if(key=='|'){
  178. JOptionPane.showMessageDialog(null,"In the event that a suspect violates\n"+
  179. "his/her shareware rights and this code is\n"+
  180. "stolen, this section of code can be used in\n"+
  181. "court to prove that the suspect is indeed\n"+
  182. "guilty. Please do not plagarise.\n\n\n"+
  183. "Oh yes, if you're smart enough to take\n"+
  184. "this section of code out, don't think\n"+
  185. "you've escaped because more of these are\n"+
  186. "planted on CML.java.",
  187. "Shareware Rights Violation = Imprisonment",
  188. JOptionPane.ERROR_MESSAGE);
  189. }
  190.  
  191. }
  192. }
  193.  
  194. );
  195.  
  196.  
  197.  
  198.  
  199. content.add(done);
  200. done.setForeground(Color.BLUE);
  201.  
  202. done.addActionListener(
  203.  
  204. new ActionListener()
  205. {
  206.  
  207. public void actionPerformed(ActionEvent event){
  208. try{
  209. code = Integer.parseInt(inputCode.getText());
  210.  
  211. resultS += "\n" + lines + " = " + code;
  212. result.setText(resultS);
  213. lines++;
  214. wtd();
  215. }
  216. catch(Exception e){
  217. JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+
  218. "language statement.\n\n"+
  219. "Exception: \n"+e, "ERROR",
  220. JOptionPane.ERROR_MESSAGE);
  221. reset();
  222.  
  223. }
  224.  
  225. }
  226. }
  227.  
  228. );
  229.  
  230. content.add(reset);
  231. reset.setBackground(Color.GRAY);
  232. reset.setForeground(Color.WHITE);
  233.  
  234.  
  235. reset.addActionListener(
  236.  
  237. new ActionListener()
  238. {
  239.  
  240. public void actionPerformed(ActionEvent event){
  241.  
  242. reset();
  243.  
  244. resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***";
  245.  
  246. result.setText(resultS);
  247.  
  248. inputCode.setText("CODE");
  249.  
  250. }
  251. }
  252.  
  253. );
  254.  
  255. content.add(help);
  256. help.setBackground(Color.GRAY);
  257. help.setForeground(Color.WHITE);
  258.  
  259. help.addActionListener(
  260.  
  261. new ActionListener()
  262. {
  263.  
  264. public void actionPerformed(ActionEvent event){
  265.  
  266. JOptionPane.showMessageDialog(null,
  267. "To learn CML got to: http://www.freewebs.com/pcssuck/index2.htm\n"+
  268. "If you're having trouble with the actual compiler and not the\n"+
  269. "language, email our team at code.rocket@gmail.com.\n\n\n"+
  270. "This language was created by a 7th grader named Ian\n"+
  271. "Cinnamon who followed MIT/UCLA's programming language \ndevelopment"+
  272. " course.\n\n\nC.M.L. (Cinnamon Machine Language) copyright 2004.\n"+
  273. "This compiler is shareware - please do not violate your rights.",
  274. "Help Me!",JOptionPane.ERROR_MESSAGE);
  275.  
  276. }
  277. }
  278.  
  279. );
  280.  
  281. content.add(colors);
  282. colors.setBackground(Color.GRAY);
  283. colors.setForeground(Color.WHITE);
  284.  
  285. colors.addActionListener(
  286.  
  287. new ActionListener()
  288. {
  289.  
  290. public void actionPerformed(ActionEvent event){
  291.  
  292. coloring = JColorChooser.showDialog(cml.this, "Choose a Color.", coloring);
  293.  
  294. if(coloring==null) coloring = Color.GREEN;
  295.  
  296. result.setBackground(coloring);
  297.  
  298. }
  299. }
  300.  
  301. );
  302.  
  303. looks = UIManager.getInstalledLookAndFeels();
  304.  
  305. try{
  306. UIManager.setLookAndFeel( looks[2].getClassName() );
  307. SwingUtilities.updateComponentTreeUI( this );
  308. }
  309. catch(Exception e){
  310. e.printStackTrace();
  311. }
  312.  
  313.  
  314. setContentPane(content);
  315.  
  316. }
  317.  
  318. private void openTheFile(){
  319. JFileChooser fileChooser = new JFileChooser();
  320. fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  321.  
  322. int result = fileChooser.showOpenDialog(this);
  323.  
  324. if(result==JFileChooser.CANCEL_OPTION) return;
  325.  
  326. File fileName = fileChooser.getSelectedFile();
  327.  
  328. if(fileName==null || fileName.getName().equals(""))
  329. JOptionPane.showMessageDialog(this, "Invalid File Name",
  330. "Invalid File Name", JOptionPane.ERROR_MESSAGE);
  331.  
  332. else{
  333.  
  334. try{
  335. input=new ObjectInputStream(
  336. new FileInputStream(fileName));
  337. }
  338. catch(IOException ion){
  339. JOptionPane.showMessageDialog(this, "Error Opening File",
  340. "Error", JOptionPane.ERROR_MESSAGE);
  341. }
  342.  
  343. }
  344. }
  345.  
  346.  
  347. private void openFile(){
  348.  
  349. JFileChooser fileChooser = new JFileChooser();
  350. fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
  351.  
  352. int result = fileChooser.showSaveDialog(this);
  353.  
  354. if(result == JFileChooser.CANCEL_OPTION)
  355. return;
  356.  
  357. File fileName = fileChooser.getSelectedFile();
  358.  
  359. if( fileName==null || fileName.getName().equals( "" ) )
  360. JOptionPane.showMessageDialog(this, "Invalid File Name",
  361. "Invalid File Name", JOptionPane.ERROR_MESSAGE);
  362. else{
  363. try{
  364. output = new ObjectOutputStream(
  365. new FileOutputStream( fileName ) );
  366. readRecord();
  367. }
  368. catch(IOException e){
  369. JOptionPane.showMessageDialog(this, "Error Opening File",
  370. "Error", JOptionPane.ERROR_MESSAGE);
  371. }
  372. }
  373.  
  374. }
  375.  
  376. public String getResult(){
  377. return result.getText();
  378. }
  379. public int[] getCoder(){
  380. return coder;
  381. }
  382. public int[] getCoder2(){
  383. return coder2;
  384. }
  385.  
  386.  
  387. public void readRecord(){
  388.  
  389. cml record;
  390.  
  391. try{
  392. record = (cml) input.readObject();
  393. coder = getCoder();
  394. coder2 = getCoder2();
  395. result.setText( getResult() );
  396. }
  397. catch(EOFException end){
  398. JOptionPane.showMessageDialog(this, "Error:\n"+end,
  399. "Error", JOptionPane.ERROR_MESSAGE);
  400. }
  401. catch(ClassNotFoundException classNotFound){
  402. JOptionPane.showMessageDialog(this, "Unable to create object.",
  403. "Class Not Found", JOptionPane.ERROR_MESSAGE);
  404. }
  405. catch(IOException ioException){
  406. JOptionPane.showMessageDialog(this, "Error during read from file.",
  407. "Read Error", JOptionPane.ERROR_MESSAGE);
  408. }
  409.  
  410. }
  411.  
  412.  
  413. private void closeFile(){
  414. try{
  415. input.close();
  416. output.close();
  417. System.exit( 0 );
  418. }
  419. catch(IOException io){
  420. JOptionPane.showMessageDialog(this, "Error closing file",
  421. "Error", JOptionPane.ERROR_MESSAGE);
  422. System.exit( 1 );
  423. }
  424. }
  425.  
  426. public void addRecord(){
  427.  
  428.  
  429. cml cql;
  430.  
  431. for(int s = 0; s < 99; s++) {
  432. Scoder[s] = coder[s];
  433. }
  434. for(int a = 0; a < 99; a++) {
  435. Scoder2[a] = coder2[a];
  436. }
  437.  
  438. try{
  439. cql = new cml(getCoder(), getCoder2(), getResult());
  440.  
  441. output.writeObject(cql);
  442. output.flush();
  443.  
  444. reset();
  445. }
  446. catch(NumberFormatException fe){
  447. JOptionPane.showMessageDialog(this, "Error: \n"+fe,
  448. "NumberFormatException",
  449. JOptionPane.ERROR_MESSAGE);
  450. }
  451. catch(IOException ioe){
  452. JOptionPane.showMessageDialog(this, "Error: \n"+ioe+"\n\n"+
  453. "Error writing to file",
  454. "IOException", JOptionPane.ERROR_MESSAGE);
  455. }
  456. closeFile();
  457.  
  458. }
  459.  
  460.  
  461. void reset(){
  462.  
  463. i = -1;
  464. accum = 0;
  465. operand = 0;
  466. opCode = 0;
  467. x = 0;
  468. lines = 0;
  469.  
  470. code = 0;
  471. in = 0;
  472.  
  473.  
  474.  
  475. for(int g = 0; g < 99; g++){
  476.  
  477. coder[g] = 0;
  478.  
  479. coder2[g] = 0;
  480.  
  481. }
  482.  
  483. }
  484.  
  485.  
  486. void wtd(){
  487. try{
  488. opCode = code / 100;
  489. operand = code % 100;
  490.  
  491. coder[lines] = code;
  492. x++;
  493.  
  494. inputCode.setText("CODE");
  495. }
  496. catch(Exception e){
  497. JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+
  498. "language statement.\n\n"+
  499. "Exception: \n"+e, "ERROR",
  500. JOptionPane.ERROR_MESSAGE);
  501. reset();
  502. }
  503.  
  504. }
  505.  
  506.  
  507. void compile(){
  508. for(in = 0; in<lines; in++){
  509.  
  510. int pcode = coder[in];
  511.  
  512. if (pcode/100 == 10) {
  513.  
  514. read();
  515.  
  516. }
  517. else if (pcode/100 == 11) {
  518.  
  519. write();
  520.  
  521. }
  522. else if (pcode/100 == 20) {
  523.  
  524. load();
  525.  
  526. }
  527. else if (pcode/100 == 21) {
  528.  
  529. store();
  530.  
  531. }
  532. else if (pcode/100 == 30) {
  533.  
  534. add();
  535.  
  536. }
  537. else if (pcode/100 == 31) {
  538.  
  539. sub();
  540.  
  541. }
  542. else if (pcode/100 == 32) {
  543.  
  544. div();
  545.  
  546. }
  547. else if (pcode/100 == 33) {
  548.  
  549. mul();
  550.  
  551. }
  552.  
  553. }
  554.  
  555. }
  556.  
  557.  
  558. void mul(){
  559. accum*=coder2[coder[in]%100];
  560. if(coder[in]/100==11){
  561.  
  562. write();
  563.  
  564. }
  565. if(coder[in]/100==10){
  566.  
  567. read();
  568.  
  569. }
  570. if(coder[in]/100==20){
  571.  
  572. load();
  573.  
  574. }
  575. if(coder[in]/100==21){
  576.  
  577. store();
  578.  
  579. }
  580. if(coder[in]/100==30){
  581.  
  582. add();
  583.  
  584. }
  585. if(coder[in]/100==31){
  586.  
  587. sub();
  588.  
  589. }
  590. if(coder[in]/100==32){
  591.  
  592. div();
  593.  
  594. }
  595.  
  596.  
  597. }
  598.  
  599. void div(){
  600. accum/=coder2[coder[in]%100];
  601. if(coder[in]/100==11){
  602.  
  603. write();
  604.  
  605. }
  606. if(coder[in]/100==10){
  607.  
  608. read();
  609.  
  610. }
  611. if(coder[in]/100==20){
  612.  
  613. load();
  614.  
  615. }
  616. if(coder[in]/100==21){
  617.  
  618. store();
  619.  
  620. }
  621. if(coder[in]/100==30){
  622.  
  623. add();
  624.  
  625. }
  626. if(coder[in]/100==31){
  627.  
  628. sub();
  629.  
  630. }
  631.  
  632. if(coder[in]/100==33){
  633.  
  634. mul();
  635.  
  636. }
  637.  
  638. }
  639.  
  640. void sub(){
  641. accum-=coder2[coder[in]%100];
  642. if(coder[in]/100==11){
  643.  
  644. write();
  645.  
  646. }
  647. if(coder[in]/100==10){
  648.  
  649. read();
  650.  
  651. }
  652. if(coder[in]/100==20){
  653.  
  654. load();
  655.  
  656. }
  657. if(coder[in]/100==21){
  658.  
  659. store();
  660.  
  661. }
  662. if(coder[in]/100==30){
  663.  
  664. add();
  665.  
  666. }
  667.  
  668.  
  669. if(coder[in]/100==32){
  670.  
  671. div();
  672.  
  673. }
  674. if(coder[in]/100==33){
  675.  
  676. mul();
  677.  
  678. }
  679.  
  680. }
  681.  
  682. void add(){
  683. accum+=coder2[coder[in]%100];
  684. if(coder[in]/100==11){
  685.  
  686. write();
  687.  
  688. }
  689. if(coder[in]/100==10){
  690.  
  691. read();
  692.  
  693. }
  694. if(coder[in]/100==20){
  695.  
  696. load();
  697.  
  698. }
  699. if(coder[in]/100==21){
  700.  
  701. store();
  702.  
  703. }
  704.  
  705. if(coder[in]/100==31){
  706.  
  707. sub();
  708.  
  709. }
  710. if(coder[in]/100==32){
  711.  
  712. div();
  713.  
  714. }
  715. if(coder[in]/100==33){
  716.  
  717. mul();
  718.  
  719. }
  720.  
  721. }
  722.  
  723. void store(){
  724. coder2[coder[in]%100] = accum;
  725. if(coder[in]/100==11){
  726.  
  727. write();
  728.  
  729. }
  730. if(coder[in]/100==10){
  731.  
  732. read();
  733.  
  734. }
  735. if(coder[in]/100==20){
  736.  
  737. load();
  738.  
  739. }
  740.  
  741. if(coder[in]/100==30){
  742.  
  743. add();
  744.  
  745. }
  746. if(coder[in]/100==31){
  747.  
  748. sub();
  749.  
  750. }
  751. if(coder[in]/100==32){
  752.  
  753. div();
  754.  
  755. }
  756. if(coder[in]/100==33){
  757.  
  758. mul();
  759.  
  760. }
  761.  
  762. }
  763.  
  764. void load(){
  765.  
  766. accum = coder2[coder[in]%100];
  767. if(coder[in]/100==11){
  768.  
  769. write();
  770.  
  771. }
  772. if(coder[in]/100==10){
  773.  
  774. read();
  775.  
  776. }
  777.  
  778. if(coder[in]/100==21){
  779.  
  780. store();
  781.  
  782. }
  783. if(coder[in]/100==30){
  784.  
  785. add();
  786.  
  787. }
  788. if(coder[in]/100==31){
  789.  
  790. sub();
  791.  
  792. }
  793. if(coder[in]/100==32){
  794.  
  795. div();
  796.  
  797. }
  798. if(coder[in]/100==33){
  799.  
  800. mul();
  801.  
  802. }
  803.  
  804. }
  805.  
  806. void read(){
  807. resultS += "\n\nEnter an integer.";
  808. result.setText(resultS);
  809.  
  810.  
  811.  
  812. String integer1 = JOptionPane.showInputDialog(
  813. "Enter an integer \n"+
  814. "(a number between -128 \n"+
  815. "and +128 billion).");
  816.  
  817. coder2[(coder[in])%100] = Integer.parseInt(integer1);
  818.  
  819.  
  820.  
  821. if(coder[in]/100==11){
  822.  
  823. write();
  824.  
  825. }
  826.  
  827. if(coder[in]/100==20){
  828.  
  829. load();
  830.  
  831. }
  832. if(coder[in]/100==21){
  833.  
  834. store();
  835.  
  836. }
  837. if(coder[in]/100==30){
  838.  
  839. add();
  840.  
  841. }
  842. if(coder[in]/100==31){
  843.  
  844. sub();
  845.  
  846. }
  847. if(coder[in]/100==32){
  848.  
  849. div();
  850.  
  851. }
  852. if(coder[in]/100==33){
  853.  
  854. mul();
  855.  
  856. }
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865. }
  866.  
  867. void write(){
  868.  
  869. String code2 = "\n\n"+(coder2[(coder[in])%100])+"";
  870. resultS+=code2;
  871.  
  872. result.setText( resultS );
  873.  
  874. if(coder[in]/100==10){
  875.  
  876. read();
  877.  
  878. }
  879. if(coder[in]/100==20){
  880.  
  881. load();
  882.  
  883. }
  884. if(coder[in]/100==21){
  885.  
  886. store();
  887.  
  888. }
  889. if(coder[in]/100==30){
  890.  
  891. add();
  892.  
  893. }
  894. if(coder[in]/100==31){
  895.  
  896. sub();
  897.  
  898. }
  899. if(coder[in]/100==32){
  900.  
  901. div();
  902.  
  903. }
  904. if(coder[in]/100==33){
  905.  
  906. mul();
  907.  
  908. }
  909.  
  910. }
  911.  
  912. public static void main(String[] args){
  913. new cml();
  914. }
  915.  
  916. }

Any help would be appreciated...
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,590
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 710
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Java.io help!!!

 
0
  #2
Mar 5th, 2005
>cannot resolve symbol: constructor cml (int[],int[],java.lang.String)in class cml at line 439
You're calling a constructor that you haven't defined. In the code posted, only a constructor call to cml with zero arguments is allowed.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Java.io help!!!

 
0
  #3
Mar 5th, 2005
thanx - can u please tell me how 2 revise the problem though?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,590
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 710
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Java.io help!!!

 
0
  #4
Mar 5th, 2005
>can u please tell me how 2 revise the problem though?
You really only have two choices. You could write a constructor that takes two integer arrays and a string, or you could change the guilty line so that it calls the default constructor instead of a nonexistent constructor.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Java.io help!!!

 
0
  #5
Mar 6th, 2005
create your own costructor with those 3 arguments, it will give you a good learning experience!
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Java.io help!!!

 
0
  #6
Mar 6th, 2005
i created the constructor w/ 3 arguments but i dont know what to put in the body of the constructor.

Can anybody help?

Thanx
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,590
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 710
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Java.io help!!!

 
0
  #7
Mar 6th, 2005
Did you write this code in the first place? The constructor that takes three arguments should do the same thing as the default constructor except using the arguments instead of default values as initializers for the appropriate data members.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Java.io help!!!

 
0
  #8
Mar 6th, 2005
but if u make the constructor w/ 3 arguments the same as the default constructor, 2 identical windows open - I'll sow u my revised code:

  1. //Cinnamon Machine Language Compiler
  2. //This is a compiler for CML.
  3. //The CML manual can be found on http://www.freewebs.com/pcssuck/cml.rtf
  4. //Support can be found at code.rocket@gmail.com
  5. //This compiler is SHAREWARE and can be purchased for $4.99 from Ian C.
  6. //Start cml.java
  7.  
  8. import javax.swing.*;
  9. import javax.swing.event.*;
  10.  
  11. import java.awt.*;
  12. import java.awt.event.*;
  13.  
  14. import java.io.*;
  15.  
  16.  
  17. public class cml2 extends JFrame {
  18.  
  19. public String resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***";
  20.  
  21. JTextArea result = new JTextArea(resultS,20,25);
  22. JTextField inputCode = new JTextField("CODE");
  23.  
  24. JScrollPane scroller = new JScrollPane(result,
  25. JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  26. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  27.  
  28.  
  29. public Icon icn = new ImageIcon("icn.gif");
  30. public Icon icn2 = new ImageIcon("icn2.gif");
  31.  
  32. public JPopupMenu popupMenu;
  33.  
  34. private ObjectOutputStream output;
  35. private ObjectInputStream input;
  36.  
  37. JButton done = new JButton("Done with this C.M.L. line.",icn2);
  38. JButton next = new JButton("Compile.", icn);
  39. JButton reset = new JButton("Reset the compiler.");
  40. JButton help = new JButton("Help me.");
  41. JButton colors = new JButton("Color Scheme.");
  42. JButton save = new JButton("Save...");
  43. JButton open = new JButton("Open...");
  44. JButton exit = new JButton("Exit");
  45.  
  46.  
  47. Color coloring = Color.GREEN;
  48.  
  49. public int [] coder = new int[99];
  50. public int [] coder2 = new int[99];
  51.  
  52. public int i = -1;
  53. public int accum = 0;
  54. public int operand = 0;
  55. public int opCode = 0;
  56. public int x = 0;
  57. public int lines = 0;
  58.  
  59. public int code;
  60. public int in;
  61.  
  62. public String name;
  63.  
  64. public final String codes = result.getText();
  65.  
  66. public int[] Scoder = coder;
  67. public int[] Scoder2 = coder2;
  68.  
  69. public String resulter;
  70.  
  71. public UIManager.LookAndFeelInfo looks[];
  72.  
  73. public cml2(){
  74. //create frame
  75. super("Cinnamon Machine Language (C.M.L.) Compiler");
  76. setSize(700,450);
  77. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  78. setVisible(true);
  79. //done creating frame
  80.  
  81. looks = UIManager.getInstalledLookAndFeels();
  82.  
  83. try{
  84. UIManager.setLookAndFeel( looks[2].getClassName() );
  85. SwingUtilities.updateComponentTreeUI( this );
  86. }
  87. catch(Exception e){
  88. e.printStackTrace();
  89. }
  90.  
  91. Container content = getContentPane();
  92. content.setBackground(Color.GRAY);
  93.  
  94. FlowLayout flowManager = new FlowLayout();
  95. content.setLayout(flowManager);
  96.  
  97. name=JOptionPane.showInputDialog(null, "Please enter your name.", "Name Verification",
  98. JOptionPane.QUESTION_MESSAGE);
  99.  
  100.  
  101. reset();
  102.  
  103. popupMenu = new JPopupMenu();
  104. popupMenu.add(save);
  105. popupMenu.add(open);
  106. popupMenu.add(exit);
  107.  
  108. addMouseListener(
  109. new MouseAdapter(){
  110. public void mousePressed(MouseEvent event){
  111. checkForTriggerEvent(event);
  112. }
  113. public void mouseReleased(MouseEvent event){
  114. checkForTriggerEvent(event);
  115. }
  116. private void checkForTriggerEvent(MouseEvent event){
  117. if(event.isPopupTrigger()){
  118. popupMenu.show(
  119. event.getComponent(), event.getX(), event.getY() );
  120. }
  121. }
  122. }
  123. );
  124.  
  125.  
  126. save.addActionListener(
  127.  
  128. new ActionListener() {
  129.  
  130. public void actionPerformed(ActionEvent event) {
  131.  
  132. if(output != null) addRecord();
  133.  
  134. openFile();
  135.  
  136. }
  137. }
  138.  
  139. );
  140.  
  141.  
  142. open.addActionListener(
  143.  
  144. new ActionListener() {
  145.  
  146. public void actionPerformed(ActionEvent event) {
  147.  
  148. openTheFile();
  149.  
  150. }
  151. }
  152.  
  153. );
  154.  
  155. exit.addActionListener(
  156.  
  157. new ActionListener() {
  158.  
  159. public void actionPerformed(ActionEvent event) {
  160.  
  161. System.exit(0);
  162.  
  163. }
  164. }
  165.  
  166. );
  167.  
  168.  
  169.  
  170. addWindowListener(
  171. new WindowAdapter(){
  172. public void windowClosing(WindowEvent event){
  173. closeFile();
  174. }
  175. }
  176. );
  177.  
  178.  
  179.  
  180. content.add(scroller);
  181. result.setEnabled(false);
  182. result.setBackground(coloring);
  183.  
  184.  
  185. content.add(next);
  186. next.setForeground(Color.RED);
  187.  
  188.  
  189. next.addActionListener(
  190.  
  191. new ActionListener() {
  192.  
  193. public void actionPerformed(ActionEvent event) {
  194.  
  195. resultS+="\n\n*** Program loading completed ***\n"+
  196. "*** Program execution begins ***";
  197.  
  198. result.setText(resultS);
  199.  
  200. compile();
  201.  
  202. }
  203. }
  204.  
  205. );
  206.  
  207.  
  208.  
  209. content.add(inputCode);
  210. inputCode.setForeground(Color.BLACK);
  211.  
  212. inputCode.addKeyListener(
  213.  
  214. new KeyListener(){
  215.  
  216. public void keyTyped(KeyEvent event){}
  217. public void keyReleased(KeyEvent event){}
  218.  
  219. public void keyPressed(KeyEvent event) {
  220.  
  221. char key = event.getKeyChar();
  222. if(key=='|'){
  223. JOptionPane.showMessageDialog(null,"In the event that a suspect violates\n"+
  224. "his/her shareware rights and this code is\n"+
  225. "stolen, this section of code can be used in\n"+
  226. "court to prove that the suspect is indeed\n"+
  227. "guilty. Please do not plagarise.\n\n\n"+
  228. "Oh yes, if you're smart enough to take\n"+
  229. "this section of code out, don't think\n"+
  230. "you've escaped because more of these are\n"+
  231. "planted on CML.java.",
  232. "Shareware Rights Violation = Imprisonment",
  233. JOptionPane.ERROR_MESSAGE);
  234. }
  235.  
  236. }
  237. }
  238.  
  239. );
  240.  
  241.  
  242.  
  243.  
  244. content.add(done);
  245. done.setForeground(Color.BLUE);
  246.  
  247. done.addActionListener(
  248.  
  249. new ActionListener()
  250. {
  251.  
  252. public void actionPerformed(ActionEvent event){
  253. try{
  254. code = Integer.parseInt(inputCode.getText());
  255.  
  256. resultS += "\n" + lines + " = " + code;
  257. result.setText(resultS);
  258. lines++;
  259. wtd();
  260. }
  261. catch(Exception e){
  262. JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+
  263. "language statement.\n\n"+
  264. "Exception: \n"+e, "ERROR",
  265. JOptionPane.ERROR_MESSAGE);
  266. reset();
  267.  
  268. }
  269.  
  270. }
  271. }
  272.  
  273. );
  274.  
  275. content.add(reset);
  276. reset.setBackground(Color.GRAY);
  277. reset.setForeground(Color.WHITE);
  278.  
  279.  
  280. reset.addActionListener(
  281.  
  282. new ActionListener()
  283. {
  284.  
  285. public void actionPerformed(ActionEvent event){
  286.  
  287. reset();
  288.  
  289. resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***";
  290.  
  291. result.setText(resultS);
  292.  
  293. inputCode.setText("CODE");
  294.  
  295. }
  296. }
  297.  
  298. );
  299.  
  300. content.add(help);
  301. help.setBackground(Color.GRAY);
  302. help.setForeground(Color.WHITE);
  303.  
  304. help.addActionListener(
  305.  
  306. new ActionListener()
  307. {
  308.  
  309. public void actionPerformed(ActionEvent event){
  310.  
  311. JOptionPane.showMessageDialog(null,
  312. "To learn CML got to: http://www.freewebs.com/pcssuck/cml.rtf\n"+
  313. "If you're having trouble with the actual compiler and not the\n"+
  314. "language, email our team at code.rocket@gmail.com.\n\n\n"+
  315. "This language was created by a 7th grader named Ian\n"+
  316. "Cinnamon who followed MIT/UCLA's programming language \ndevelopment"+
  317. " course.\n\n\nC.M.L. (Cinnamon Machine Language) copyright 2004.\n"+
  318. "This compiler is shareware - please do not violate your rights.",
  319. "Help Me!",JOptionPane.ERROR_MESSAGE);
  320.  
  321. }
  322. }
  323.  
  324. );
  325.  
  326. content.add(colors);
  327. colors.setBackground(Color.GRAY);
  328. colors.setForeground(Color.WHITE);
  329.  
  330. colors.addActionListener(
  331.  
  332. new ActionListener()
  333. {
  334.  
  335. public void actionPerformed(ActionEvent event){
  336.  
  337. coloring = JColorChooser.showDialog(cml2.this, "Choose a Color.", coloring);
  338.  
  339. if(coloring==null) coloring = Color.GREEN;
  340.  
  341. result.setBackground(coloring);
  342.  
  343. }
  344. }
  345.  
  346. );
  347.  
  348. setContentPane(content);
  349.  
  350. }
  351.  
  352. public cml2(int [] coding, int[] coding2, String resultF){
  353. setCoder(coding);
  354. setCoder2(coding2);
  355. setResult(resultF);
  356. }
  357.  
  358. public void setCoder(int [] coding){
  359. Scoder = coding;
  360. }
  361. public void setCoder2(int [] coding2){
  362. Scoder2 = coding2;
  363. }
  364. public void setResult(String resulting){
  365. resulter = resulting;
  366. }
  367.  
  368.  
  369.  
  370.  
  371.  
  372. public void openTheFile(){
  373. JFileChooser fileChooser = new JFileChooser();
  374. fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
  375.  
  376. int result = fileChooser.showOpenDialog(this);
  377.  
  378. if(result==JFileChooser.CANCEL_OPTION) return;
  379.  
  380. File fileName = fileChooser.getSelectedFile();
  381.  
  382. if(fileName==null || fileName.getName().equals(""))
  383. JOptionPane.showMessageDialog(this, "Invalid File Name",
  384. "Invalid File Name", JOptionPane.ERROR_MESSAGE);
  385.  
  386. else{
  387.  
  388. try{
  389. input=new ObjectInputStream(
  390. new FileInputStream(fileName));
  391. }
  392. catch(IOException ion){
  393. JOptionPane.showMessageDialog(this, "Error Opening File",
  394. "Error", JOptionPane.ERROR_MESSAGE);
  395. }
  396.  
  397. }
  398. }
  399.  
  400.  
  401. public void openFile(){
  402.  
  403. JFileChooser fileChooser = new JFileChooser();
  404. fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
  405.  
  406. int result = fileChooser.showSaveDialog(this);
  407.  
  408. if(result == JFileChooser.CANCEL_OPTION)
  409. return;
  410.  
  411. File fileName = fileChooser.getSelectedFile();
  412.  
  413. if( fileName==null || fileName.getName().equals( "" ) )
  414. JOptionPane.showMessageDialog(this, "Invalid File Name",
  415. "Invalid File Name", JOptionPane.ERROR_MESSAGE);
  416. else{
  417. try{
  418. output = new ObjectOutputStream(
  419. new FileOutputStream( fileName ) );
  420. readRecord();
  421. }
  422. catch(IOException e){
  423. JOptionPane.showMessageDialog(this, "Error Opening File",
  424. "Error", JOptionPane.ERROR_MESSAGE);
  425. }
  426. }
  427.  
  428. }
  429.  
  430. public String getResult(){
  431. return result.getText();
  432. }
  433. public int[] getCoder(){
  434. return coder;
  435. }
  436. public int[] getCoder2(){
  437. return coder2;
  438. }
  439.  
  440.  
  441. public void readRecord(){
  442.  
  443. cml2 recorder;
  444.  
  445. try{
  446. recorder = (cml2) input.readObject();
  447. coder = recorder.getCoder();
  448. coder2 = recorder.getCoder2();
  449. resultS = recorder.getResult();
  450. result.setText( resultS );
  451. }
  452. catch(EOFException end){
  453. JOptionPane.showMessageDialog(this, "Error:\n"+end,
  454. "Error", JOptionPane.ERROR_MESSAGE);
  455. }
  456. catch(ClassNotFoundException classNotFound){
  457. JOptionPane.showMessageDialog(this, "Unable to create object.",
  458. "Class Not Found", JOptionPane.ERROR_MESSAGE);
  459. }
  460. catch(IOException ioException){
  461. JOptionPane.showMessageDialog(this, "Error during read from file.",
  462. "Read Error", JOptionPane.ERROR_MESSAGE);
  463. }
  464.  
  465. }
  466.  
  467.  
  468. private void closeFile(){
  469. try{
  470. System.exit( 0 );
  471. input.close();
  472. output.close();
  473. }
  474. catch(IOException io){
  475. JOptionPane.showMessageDialog(this, "Error closing file",
  476. "Error", JOptionPane.ERROR_MESSAGE);
  477. System.exit( 1 );
  478. }
  479. }
  480.  
  481. public void addRecord(){
  482.  
  483.  
  484. cml2 cql;
  485.  
  486. for(int s = 0; s < 99; s++) {
  487. Scoder[s] = coder[s];
  488. }
  489. for(int a = 0; a < 99; a++) {
  490. Scoder2[a] = coder2[a];
  491. }
  492.  
  493. try{
  494. cql = new cml2(coder, coder2, result.getText());
  495.  
  496. output.writeObject(cql);
  497. output.flush();
  498.  
  499. reset();
  500. }
  501. catch(NumberFormatException fe){
  502. JOptionPane.showMessageDialog(this, "Error: \n"+fe,
  503. "NumberFormatException",
  504. JOptionPane.ERROR_MESSAGE);
  505. }
  506. catch(IOException ioe){
  507. JOptionPane.showMessageDialog(this, "Error: \n"+ioe+"\n\n"+
  508. "Error writing to file",
  509. "IOException", JOptionPane.ERROR_MESSAGE);
  510. }
  511. closeFile();
  512.  
  513. }
  514.  
  515.  
  516. void reset(){
  517.  
  518. i = -1;
  519. accum = 0;
  520. operand = 0;
  521. opCode = 0;
  522. x = 0;
  523. lines = 0;
  524.  
  525. code = 0;
  526. in = 0;
  527.  
  528.  
  529.  
  530. for(int g = 0; g < 99; g++){
  531.  
  532. coder[g] = 0;
  533.  
  534. coder2[g] = 0;
  535.  
  536. }
  537.  
  538. }
  539.  
  540.  
  541. void wtd(){
  542. try{
  543. opCode = code / 100;
  544. operand = code % 100;
  545.  
  546. coder[lines] = code;
  547. x++;
  548.  
  549. inputCode.setText("CODE");
  550. }
  551. catch(Exception e){
  552. JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+
  553. "language statement.\n\n"+
  554. "Exception: \n"+e, "ERROR",
  555. JOptionPane.ERROR_MESSAGE);
  556. reset();
  557. }
  558.  
  559. }
  560.  
  561.  
  562. void compile(){
  563. for(in = 0; in<lines; in++){
  564.  
  565. int pcode = coder[in];
  566.  
  567. if (pcode/100 == 10) {
  568.  
  569. read();
  570.  
  571. }
  572. else if (pcode/100 == 11) {
  573.  
  574. write();
  575.  
  576. }
  577. else if (pcode/100 == 20) {
  578.  
  579. load();
  580.  
  581. }
  582. else if (pcode/100 == 21) {
  583.  
  584. store();
  585.  
  586. }
  587. else if (pcode/100 == 30) {
  588.  
  589. add();
  590.  
  591. }
  592. else if (pcode/100 == 31) {
  593.  
  594. sub();
  595.  
  596. }
  597. else if (pcode/100 == 32) {
  598.  
  599. div();
  600.  
  601. }
  602. else if (pcode/100 == 33) {
  603.  
  604. mul();
  605.  
  606. }
  607.  
  608. }
  609.  
  610. }
  611.  
  612.  
  613. void mul(){
  614. accum*=coder2[coder[in]%100];
  615. if(coder[in]/100==11){
  616.  
  617. write();
  618.  
  619. }
  620. if(coder[in]/100==10){
  621.  
  622. read();
  623.  
  624. }
  625. if(coder[in]/100==20){
  626.  
  627. load();
  628.  
  629. }
  630. if(coder[in]/100==21){
  631.  
  632. store();
  633.  
  634. }
  635. if(coder[in]/100==30){
  636.  
  637. add();
  638.  
  639. }
  640. if(coder[in]/100==31){
  641.  
  642. sub();
  643.  
  644. }
  645. if(coder[in]/100==32){
  646.  
  647. div();
  648.  
  649. }
  650.  
  651.  
  652. }
  653.  
  654. void div(){
  655. accum/=coder2[coder[in]%100];
  656. if(coder[in]/100==11){
  657.  
  658. write();
  659.  
  660. }
  661. if(coder[in]/100==10){
  662.  
  663. read();
  664.  
  665. }
  666. if(coder[in]/100==20){
  667.  
  668. load();
  669.  
  670. }
  671. if(coder[in]/100==21){
  672.  
  673. store();
  674.  
  675. }
  676. if(coder[in]/100==30){
  677.  
  678. add();
  679.  
  680. }
  681. if(coder[in]/100==31){
  682.  
  683. sub();
  684.  
  685. }
  686.  
  687. if(coder[in]/100==33){
  688.  
  689. mul();
  690.  
  691. }
  692.  
  693. }
  694.  
  695. void sub(){
  696. accum-=coder2[coder[in]%100];
  697. if(coder[in]/100==11){
  698.  
  699. write();
  700.  
  701. }
  702. if(coder[in]/100==10){
  703.  
  704. read();
  705.  
  706. }
  707. if(coder[in]/100==20){
  708.  
  709. load();
  710.  
  711. }
  712. if(coder[in]/100==21){
  713.  
  714. store();
  715.  
  716. }
  717. if(coder[in]/100==30){
  718.  
  719. add();
  720.  
  721. }
  722.  
  723.  
  724. if(coder[in]/100==32){
  725.  
  726. div();
  727.  
  728. }
  729. if(coder[in]/100==33){
  730.  
  731. mul();
  732.  
  733. }
  734.  
  735. }
  736.  
  737. void add(){
  738. accum+=coder2[coder[in]%100];
  739. if(coder[in]/100==11){
  740.  
  741. write();
  742.  
  743. }
  744. if(coder[in]/100==10){
  745.  
  746. read();
  747.  
  748. }
  749. if(coder[in]/100==20){
  750.  
  751. load();
  752.  
  753. }
  754. if(coder[in]/100==21){
  755.  
  756. store();
  757.  
  758. }
  759.  
  760. if(coder[in]/100==31){
  761.  
  762. sub();
  763.  
  764. }
  765. if(coder[in]/100==32){
  766.  
  767. div();
  768.  
  769. }
  770. if(coder[in]/100==33){
  771.  
  772. mul();
  773.  
  774. }
  775.  
  776. }
  777.  
  778. void store(){
  779. coder2[coder[in]%100] = accum;
  780. if(coder[in]/100==11){
  781.  
  782. write();
  783.  
  784. }
  785. if(coder[in]/100==10){
  786.  
  787. read();
  788.  
  789. }
  790. if(coder[in]/100==20){
  791.  
  792. load();
  793.  
  794. }
  795.  
  796. if(coder[in]/100==30){
  797.  
  798. add();
  799.  
  800. }
  801. if(coder[in]/100==31){
  802.  
  803. sub();
  804.  
  805. }
  806. if(coder[in]/100==32){
  807.  
  808. div();
  809.  
  810. }
  811. if(coder[in]/100==33){
  812.  
  813. mul();
  814.  
  815. }
  816.  
  817. }
  818.  
  819. void load(){
  820.  
  821. accum = coder2[coder[in]%100];
  822. if(coder[in]/100==11){
  823.  
  824. write();
  825.  
  826. }
  827. if(coder[in]/100==10){
  828.  
  829. read();
  830.  
  831. }
  832.  
  833. if(coder[in]/100==21){
  834.  
  835. store();
  836.  
  837. }
  838. if(coder[in]/100==30){
  839.  
  840. add();
  841.  
  842. }
  843. if(coder[in]/100==31){
  844.  
  845. sub();
  846.  
  847. }
  848. if(coder[in]/100==32){
  849.  
  850. div();
  851.  
  852. }
  853. if(coder[in]/100==33){
  854.  
  855. mul();
  856.  
  857. }
  858.  
  859. }
  860.  
  861. void read(){
  862. resultS += "\n\nEnter an integer.";
  863. result.setText(resultS);
  864.  
  865.  
  866.  
  867. String integer1 = JOptionPane.showInputDialog(
  868. "Enter an integer \n"+
  869. "(a number between -128 \n"+
  870. "and +128 billion).");
  871.  
  872. coder2[(coder[in])%100] = Integer.parseInt(integer1);
  873.  
  874.  
  875.  
  876. if(coder[in]/100==11){
  877.  
  878. write();
  879.  
  880. }
  881.  
  882. if(coder[in]/100==20){
  883.  
  884. load();
  885.  
  886. }
  887. if(coder[in]/100==21){
  888.  
  889. store();
  890.  
  891. }
  892. if(coder[in]/100==30){
  893.  
  894. add();
  895.  
  896. }
  897. if(coder[in]/100==31){
  898.  
  899. sub();
  900.  
  901. }
  902. if(coder[in]/100==32){
  903.  
  904. div();
  905.  
  906. }
  907. if(coder[in]/100==33){
  908.  
  909. mul();
  910.  
  911. }
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920. }
  921.  
  922. void write(){
  923.  
  924. String code2 = "\n\n"+(coder2[(coder[in])%100])+"";
  925. resultS+=code2;
  926.  
  927. result.setText( resultS );
  928.  
  929. if(coder[in]/100==10){
  930.  
  931. read();
  932.  
  933. }
  934. if(coder[in]/100==20){
  935.  
  936. load();
  937.  
  938. }
  939. if(coder[in]/100==21){
  940.  
  941. store();
  942.  
  943. }
  944. if(coder[in]/100==30){
  945.  
  946. add();
  947.  
  948. }
  949. if(coder[in]/100==31){
  950.  
  951. sub();
  952.  
  953. }
  954. if(coder[in]/100==32){
  955.  
  956. div();
  957.  
  958. }
  959. if(coder[in]/100==33){
  960.  
  961. mul();
  962.  
  963. }
  964.  
  965. }
  966.  
  967. public static void main(String[] args){
  968. new cml2();
  969. }
  970.  
  971. }

Thanx
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,590
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 710
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Java.io help!!!

 
0
  #9
Mar 6th, 2005
>2 identical windows open
Right, because cml is the master class that draws your compiler interface. If you don't want that to happen then your best bet is to separate the GUI processing code from the compiler itself. That would be a better solution than trying to fix what you have, but it takes more work. I'm afraid I haven't put much effort into understanding how your code is set up, so I won't be much help beyond that.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Java.io help!!!

 
0
  #10
Mar 6th, 2005
more help would be appreciated...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC