| | |
Java.io help!!!
![]() |
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:
Any help would be appreciated...
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:
Java Syntax (Toggle Plain Text)
//Cinnamon Machine Language Compiler import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class cml extends JFrame { public String resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***"; JTextArea result = new JTextArea(resultS,20,10); JTextField inputCode = new JTextField("CODE"); public Icon icn = new ImageIcon("icn.gif"); public Icon icn2 = new ImageIcon("icn2.gif"); public JPopupMenu popupMenu; private ObjectOutputStream output; private ObjectInputStream input; JButton done = new JButton("Done with this C.M.L. line.",icn2); JButton next = new JButton("Compile.", icn); JButton reset = new JButton("Reset the compiler."); JButton help = new JButton("Help me."); JButton colors = new JButton("Color Scheme."); JButton save = new JButton("Save..."); JButton open = new JButton("Open..."); Color coloring = Color.GREEN; public int [] coder = new int[99]; public int [] coder2 = new int[99]; public int i = -1; public int accum = 0; public int operand = 0; public int opCode = 0; public int x = 0; public int lines = 0; public int code; public int in; public final String codes = result.getText(); public final int[] Scoder = coder; public final int[] Scoder2 = coder2; public UIManager.LookAndFeelInfo looks[]; public cml(){ //create frame super("Cinnamon Machine Language (C.M.L.) Compiler"); setSize(750,450); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); //done creating frame Container content = getContentPane(); content.setBackground(Color.GRAY); FlowLayout flowManager = new FlowLayout(); content.setLayout(flowManager); reset(); popupMenu = new JPopupMenu(); popupMenu.add(save); popupMenu.add(open); addMouseListener( new MouseAdapter(){ public void mousePressed(MouseEvent event){ checkForTriggerEvent(event); } public void mouseReleased(MouseEvent event){ checkForTriggerEvent(event); } private void checkForTriggerEvent(MouseEvent event){ if(event.isPopupTrigger()){ popupMenu.show( event.getComponent(), event.getX(), event.getY() ); } } } ); save.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if(output != null) addRecord(); openFile(); } } ); open.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { openTheFile(); } } ); addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent event){ closeFile(); } } ); content.add(result); result.setEditable(false); result.setBackground(coloring); content.add(next); next.setForeground(Color.RED); next.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { resultS+="\n\n*** Program loading completed ***\n"+ "*** Program execution begins ***"; result.setText(resultS); compile(); } } ); content.add(inputCode); inputCode.setForeground(Color.BLACK); inputCode.addKeyListener( new KeyListener(){ public void keyTyped(KeyEvent event){} public void keyReleased(KeyEvent event){} public void keyPressed(KeyEvent event) { char key = event.getKeyChar(); if(key=='|'){ JOptionPane.showMessageDialog(null,"In the event that a suspect violates\n"+ "his/her shareware rights and this code is\n"+ "stolen, this section of code can be used in\n"+ "court to prove that the suspect is indeed\n"+ "guilty. Please do not plagarise.\n\n\n"+ "Oh yes, if you're smart enough to take\n"+ "this section of code out, don't think\n"+ "you've escaped because more of these are\n"+ "planted on CML.java.", "Shareware Rights Violation = Imprisonment", JOptionPane.ERROR_MESSAGE); } } } ); content.add(done); done.setForeground(Color.BLUE); done.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ try{ code = Integer.parseInt(inputCode.getText()); resultS += "\n" + lines + " = " + code; result.setText(resultS); lines++; wtd(); } catch(Exception e){ JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+ "language statement.\n\n"+ "Exception: \n"+e, "ERROR", JOptionPane.ERROR_MESSAGE); reset(); } } } ); content.add(reset); reset.setBackground(Color.GRAY); reset.setForeground(Color.WHITE); reset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ reset(); resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***"; result.setText(resultS); inputCode.setText("CODE"); } } ); content.add(help); help.setBackground(Color.GRAY); help.setForeground(Color.WHITE); help.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ JOptionPane.showMessageDialog(null, "To learn CML got to: http://www.freewebs.com/pcssuck/index2.htm\n"+ "If you're having trouble with the actual compiler and not the\n"+ "language, email our team at code.rocket@gmail.com.\n\n\n"+ "This language was created by a 7th grader named Ian\n"+ "Cinnamon who followed MIT/UCLA's programming language \ndevelopment"+ " course.\n\n\nC.M.L. (Cinnamon Machine Language) copyright 2004.\n"+ "This compiler is shareware - please do not violate your rights.", "Help Me!",JOptionPane.ERROR_MESSAGE); } } ); content.add(colors); colors.setBackground(Color.GRAY); colors.setForeground(Color.WHITE); colors.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ coloring = JColorChooser.showDialog(cml.this, "Choose a Color.", coloring); if(coloring==null) coloring = Color.GREEN; result.setBackground(coloring); } } ); looks = UIManager.getInstalledLookAndFeels(); try{ UIManager.setLookAndFeel( looks[2].getClassName() ); SwingUtilities.updateComponentTreeUI( this ); } catch(Exception e){ e.printStackTrace(); } setContentPane(content); } private void openTheFile(){ JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int result = fileChooser.showOpenDialog(this); if(result==JFileChooser.CANCEL_OPTION) return; File fileName = fileChooser.getSelectedFile(); if(fileName==null || fileName.getName().equals("")) JOptionPane.showMessageDialog(this, "Invalid File Name", "Invalid File Name", JOptionPane.ERROR_MESSAGE); else{ try{ input=new ObjectInputStream( new FileInputStream(fileName)); } catch(IOException ion){ JOptionPane.showMessageDialog(this, "Error Opening File", "Error", JOptionPane.ERROR_MESSAGE); } } } private void openFile(){ JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY ); int result = fileChooser.showSaveDialog(this); if(result == JFileChooser.CANCEL_OPTION) return; File fileName = fileChooser.getSelectedFile(); if( fileName==null || fileName.getName().equals( "" ) ) JOptionPane.showMessageDialog(this, "Invalid File Name", "Invalid File Name", JOptionPane.ERROR_MESSAGE); else{ try{ output = new ObjectOutputStream( new FileOutputStream( fileName ) ); readRecord(); } catch(IOException e){ JOptionPane.showMessageDialog(this, "Error Opening File", "Error", JOptionPane.ERROR_MESSAGE); } } } public String getResult(){ return result.getText(); } public int[] getCoder(){ return coder; } public int[] getCoder2(){ return coder2; } public void readRecord(){ cml record; try{ record = (cml) input.readObject(); coder = getCoder(); coder2 = getCoder2(); result.setText( getResult() ); } catch(EOFException end){ JOptionPane.showMessageDialog(this, "Error:\n"+end, "Error", JOptionPane.ERROR_MESSAGE); } catch(ClassNotFoundException classNotFound){ JOptionPane.showMessageDialog(this, "Unable to create object.", "Class Not Found", JOptionPane.ERROR_MESSAGE); } catch(IOException ioException){ JOptionPane.showMessageDialog(this, "Error during read from file.", "Read Error", JOptionPane.ERROR_MESSAGE); } } private void closeFile(){ try{ input.close(); output.close(); System.exit( 0 ); } catch(IOException io){ JOptionPane.showMessageDialog(this, "Error closing file", "Error", JOptionPane.ERROR_MESSAGE); System.exit( 1 ); } } public void addRecord(){ cml cql; for(int s = 0; s < 99; s++) { Scoder[s] = coder[s]; } for(int a = 0; a < 99; a++) { Scoder2[a] = coder2[a]; } try{ cql = new cml(getCoder(), getCoder2(), getResult()); output.writeObject(cql); output.flush(); reset(); } catch(NumberFormatException fe){ JOptionPane.showMessageDialog(this, "Error: \n"+fe, "NumberFormatException", JOptionPane.ERROR_MESSAGE); } catch(IOException ioe){ JOptionPane.showMessageDialog(this, "Error: \n"+ioe+"\n\n"+ "Error writing to file", "IOException", JOptionPane.ERROR_MESSAGE); } closeFile(); } void reset(){ i = -1; accum = 0; operand = 0; opCode = 0; x = 0; lines = 0; code = 0; in = 0; for(int g = 0; g < 99; g++){ coder[g] = 0; coder2[g] = 0; } } void wtd(){ try{ opCode = code / 100; operand = code % 100; coder[lines] = code; x++; inputCode.setText("CODE"); } catch(Exception e){ JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+ "language statement.\n\n"+ "Exception: \n"+e, "ERROR", JOptionPane.ERROR_MESSAGE); reset(); } } void compile(){ for(in = 0; in<lines; in++){ int pcode = coder[in]; if (pcode/100 == 10) { read(); } else if (pcode/100 == 11) { write(); } else if (pcode/100 == 20) { load(); } else if (pcode/100 == 21) { store(); } else if (pcode/100 == 30) { add(); } else if (pcode/100 == 31) { sub(); } else if (pcode/100 == 32) { div(); } else if (pcode/100 == 33) { mul(); } } } void mul(){ accum*=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } } void div(){ accum/=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==33){ mul(); } } void sub(){ accum-=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void add(){ accum+=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void store(){ coder2[coder[in]%100] = accum; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void load(){ accum = coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void read(){ resultS += "\n\nEnter an integer."; result.setText(resultS); String integer1 = JOptionPane.showInputDialog( "Enter an integer \n"+ "(a number between -128 \n"+ "and +128 billion)."); coder2[(coder[in])%100] = Integer.parseInt(integer1); if(coder[in]/100==11){ write(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void write(){ String code2 = "\n\n"+(coder2[(coder[in])%100])+""; resultS+=code2; result.setText( resultS ); if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } public static void main(String[] args){ new cml(); } }
Any help would be appreciated...
>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.
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.
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:
Thanx
Java Syntax (Toggle Plain Text)
//Cinnamon Machine Language Compiler //This is a compiler for CML. //The CML manual can be found on http://www.freewebs.com/pcssuck/cml.rtf //Support can be found at code.rocket@gmail.com //This compiler is SHAREWARE and can be purchased for $4.99 from Ian C. //Start cml.java import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class cml2 extends JFrame { public String resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***"; JTextArea result = new JTextArea(resultS,20,25); JTextField inputCode = new JTextField("CODE"); JScrollPane scroller = new JScrollPane(result, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); public Icon icn = new ImageIcon("icn.gif"); public Icon icn2 = new ImageIcon("icn2.gif"); public JPopupMenu popupMenu; private ObjectOutputStream output; private ObjectInputStream input; JButton done = new JButton("Done with this C.M.L. line.",icn2); JButton next = new JButton("Compile.", icn); JButton reset = new JButton("Reset the compiler."); JButton help = new JButton("Help me."); JButton colors = new JButton("Color Scheme."); JButton save = new JButton("Save..."); JButton open = new JButton("Open..."); JButton exit = new JButton("Exit"); Color coloring = Color.GREEN; public int [] coder = new int[99]; public int [] coder2 = new int[99]; public int i = -1; public int accum = 0; public int operand = 0; public int opCode = 0; public int x = 0; public int lines = 0; public int code; public int in; public String name; public final String codes = result.getText(); public int[] Scoder = coder; public int[] Scoder2 = coder2; public String resulter; public UIManager.LookAndFeelInfo looks[]; public cml2(){ //create frame super("Cinnamon Machine Language (C.M.L.) Compiler"); setSize(700,450); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); //done creating frame looks = UIManager.getInstalledLookAndFeels(); try{ UIManager.setLookAndFeel( looks[2].getClassName() ); SwingUtilities.updateComponentTreeUI( this ); } catch(Exception e){ e.printStackTrace(); } Container content = getContentPane(); content.setBackground(Color.GRAY); FlowLayout flowManager = new FlowLayout(); content.setLayout(flowManager); name=JOptionPane.showInputDialog(null, "Please enter your name.", "Name Verification", JOptionPane.QUESTION_MESSAGE); reset(); popupMenu = new JPopupMenu(); popupMenu.add(save); popupMenu.add(open); popupMenu.add(exit); addMouseListener( new MouseAdapter(){ public void mousePressed(MouseEvent event){ checkForTriggerEvent(event); } public void mouseReleased(MouseEvent event){ checkForTriggerEvent(event); } private void checkForTriggerEvent(MouseEvent event){ if(event.isPopupTrigger()){ popupMenu.show( event.getComponent(), event.getX(), event.getY() ); } } } ); save.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if(output != null) addRecord(); openFile(); } } ); open.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { openTheFile(); } } ); exit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } } ); addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent event){ closeFile(); } } ); content.add(scroller); result.setEnabled(false); result.setBackground(coloring); content.add(next); next.setForeground(Color.RED); next.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { resultS+="\n\n*** Program loading completed ***\n"+ "*** Program execution begins ***"; result.setText(resultS); compile(); } } ); content.add(inputCode); inputCode.setForeground(Color.BLACK); inputCode.addKeyListener( new KeyListener(){ public void keyTyped(KeyEvent event){} public void keyReleased(KeyEvent event){} public void keyPressed(KeyEvent event) { char key = event.getKeyChar(); if(key=='|'){ JOptionPane.showMessageDialog(null,"In the event that a suspect violates\n"+ "his/her shareware rights and this code is\n"+ "stolen, this section of code can be used in\n"+ "court to prove that the suspect is indeed\n"+ "guilty. Please do not plagarise.\n\n\n"+ "Oh yes, if you're smart enough to take\n"+ "this section of code out, don't think\n"+ "you've escaped because more of these are\n"+ "planted on CML.java.", "Shareware Rights Violation = Imprisonment", JOptionPane.ERROR_MESSAGE); } } } ); content.add(done); done.setForeground(Color.BLUE); done.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ try{ code = Integer.parseInt(inputCode.getText()); resultS += "\n" + lines + " = " + code; result.setText(resultS); lines++; wtd(); } catch(Exception e){ JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+ "language statement.\n\n"+ "Exception: \n"+e, "ERROR", JOptionPane.ERROR_MESSAGE); reset(); } } } ); content.add(reset); reset.setBackground(Color.GRAY); reset.setForeground(Color.WHITE); reset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ reset(); resultS = "*** Welcome to the C.M.L. Compiler. ***\n\n*** Please code a program and compile. ***"; result.setText(resultS); inputCode.setText("CODE"); } } ); content.add(help); help.setBackground(Color.GRAY); help.setForeground(Color.WHITE); help.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ JOptionPane.showMessageDialog(null, "To learn CML got to: http://www.freewebs.com/pcssuck/cml.rtf\n"+ "If you're having trouble with the actual compiler and not the\n"+ "language, email our team at code.rocket@gmail.com.\n\n\n"+ "This language was created by a 7th grader named Ian\n"+ "Cinnamon who followed MIT/UCLA's programming language \ndevelopment"+ " course.\n\n\nC.M.L. (Cinnamon Machine Language) copyright 2004.\n"+ "This compiler is shareware - please do not violate your rights.", "Help Me!",JOptionPane.ERROR_MESSAGE); } } ); content.add(colors); colors.setBackground(Color.GRAY); colors.setForeground(Color.WHITE); colors.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event){ coloring = JColorChooser.showDialog(cml2.this, "Choose a Color.", coloring); if(coloring==null) coloring = Color.GREEN; result.setBackground(coloring); } } ); setContentPane(content); } public cml2(int [] coding, int[] coding2, String resultF){ setCoder(coding); setCoder2(coding2); setResult(resultF); } public void setCoder(int [] coding){ Scoder = coding; } public void setCoder2(int [] coding2){ Scoder2 = coding2; } public void setResult(String resulting){ resulter = resulting; } public void openTheFile(){ JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int result = fileChooser.showOpenDialog(this); if(result==JFileChooser.CANCEL_OPTION) return; File fileName = fileChooser.getSelectedFile(); if(fileName==null || fileName.getName().equals("")) JOptionPane.showMessageDialog(this, "Invalid File Name", "Invalid File Name", JOptionPane.ERROR_MESSAGE); else{ try{ input=new ObjectInputStream( new FileInputStream(fileName)); } catch(IOException ion){ JOptionPane.showMessageDialog(this, "Error Opening File", "Error", JOptionPane.ERROR_MESSAGE); } } } public void openFile(){ JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY ); int result = fileChooser.showSaveDialog(this); if(result == JFileChooser.CANCEL_OPTION) return; File fileName = fileChooser.getSelectedFile(); if( fileName==null || fileName.getName().equals( "" ) ) JOptionPane.showMessageDialog(this, "Invalid File Name", "Invalid File Name", JOptionPane.ERROR_MESSAGE); else{ try{ output = new ObjectOutputStream( new FileOutputStream( fileName ) ); readRecord(); } catch(IOException e){ JOptionPane.showMessageDialog(this, "Error Opening File", "Error", JOptionPane.ERROR_MESSAGE); } } } public String getResult(){ return result.getText(); } public int[] getCoder(){ return coder; } public int[] getCoder2(){ return coder2; } public void readRecord(){ cml2 recorder; try{ recorder = (cml2) input.readObject(); coder = recorder.getCoder(); coder2 = recorder.getCoder2(); resultS = recorder.getResult(); result.setText( resultS ); } catch(EOFException end){ JOptionPane.showMessageDialog(this, "Error:\n"+end, "Error", JOptionPane.ERROR_MESSAGE); } catch(ClassNotFoundException classNotFound){ JOptionPane.showMessageDialog(this, "Unable to create object.", "Class Not Found", JOptionPane.ERROR_MESSAGE); } catch(IOException ioException){ JOptionPane.showMessageDialog(this, "Error during read from file.", "Read Error", JOptionPane.ERROR_MESSAGE); } } private void closeFile(){ try{ System.exit( 0 ); input.close(); output.close(); } catch(IOException io){ JOptionPane.showMessageDialog(this, "Error closing file", "Error", JOptionPane.ERROR_MESSAGE); System.exit( 1 ); } } public void addRecord(){ cml2 cql; for(int s = 0; s < 99; s++) { Scoder[s] = coder[s]; } for(int a = 0; a < 99; a++) { Scoder2[a] = coder2[a]; } try{ cql = new cml2(coder, coder2, result.getText()); output.writeObject(cql); output.flush(); reset(); } catch(NumberFormatException fe){ JOptionPane.showMessageDialog(this, "Error: \n"+fe, "NumberFormatException", JOptionPane.ERROR_MESSAGE); } catch(IOException ioe){ JOptionPane.showMessageDialog(this, "Error: \n"+ioe+"\n\n"+ "Error writing to file", "IOException", JOptionPane.ERROR_MESSAGE); } closeFile(); } void reset(){ i = -1; accum = 0; operand = 0; opCode = 0; x = 0; lines = 0; code = 0; in = 0; for(int g = 0; g < 99; g++){ coder[g] = 0; coder2[g] = 0; } } void wtd(){ try{ opCode = code / 100; operand = code % 100; coder[lines] = code; x++; inputCode.setText("CODE"); } catch(Exception e){ JOptionPane.showMessageDialog(null, "Please enter a correct machine\n"+ "language statement.\n\n"+ "Exception: \n"+e, "ERROR", JOptionPane.ERROR_MESSAGE); reset(); } } void compile(){ for(in = 0; in<lines; in++){ int pcode = coder[in]; if (pcode/100 == 10) { read(); } else if (pcode/100 == 11) { write(); } else if (pcode/100 == 20) { load(); } else if (pcode/100 == 21) { store(); } else if (pcode/100 == 30) { add(); } else if (pcode/100 == 31) { sub(); } else if (pcode/100 == 32) { div(); } else if (pcode/100 == 33) { mul(); } } } void mul(){ accum*=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } } void div(){ accum/=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==33){ mul(); } } void sub(){ accum-=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void add(){ accum+=coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void store(){ coder2[coder[in]%100] = accum; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void load(){ accum = coder2[coder[in]%100]; if(coder[in]/100==11){ write(); } if(coder[in]/100==10){ read(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void read(){ resultS += "\n\nEnter an integer."; result.setText(resultS); String integer1 = JOptionPane.showInputDialog( "Enter an integer \n"+ "(a number between -128 \n"+ "and +128 billion)."); coder2[(coder[in])%100] = Integer.parseInt(integer1); if(coder[in]/100==11){ write(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } void write(){ String code2 = "\n\n"+(coder2[(coder[in])%100])+""; resultS+=code2; result.setText( resultS ); if(coder[in]/100==10){ read(); } if(coder[in]/100==20){ load(); } if(coder[in]/100==21){ store(); } if(coder[in]/100==30){ add(); } if(coder[in]/100==31){ sub(); } if(coder[in]/100==32){ div(); } if(coder[in]/100==33){ mul(); } } public static void main(String[] args){ new cml2(); } }
Thanx
>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.
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.
![]() |
Similar Threads
- FT Junior Java Developer Needed for Major Media firm in NYC (Software Development Job Offers)
- Java/J2EE Senior Software Engineer (Software Development Job Offers)
- Front-end Java Software Engineer for Digital Video/Media Market Leader (Software Development Job Offers)
- Senior Software Engineer (Java) (Web Development Job Offers)
- Java Software Engineer (Software Development Job Offers)
- Java Front-end Developer Engineer for Stealth Media Start-up (Software Development Job Offers)
- Java Developer Required (Software Development Job Offers)
Other Threads in the Java Forum
- Previous Thread: Setting Font of Button Label
- Next Thread: Help with Java Threads
| Thread Tools | Search this Thread |
911 addball addressbook android api append applet application apps array arrays automation binary bluetooth businessintelligence button card class client code collision component crashcourse css csv database eclipse ee error fractal free ftp game gis givemetehcodez graphics gui html ide image integer integration j2me japplet java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm linked linux list loan machine map method methods migrate mobile netbeans objects oriented output phone physics printf problem program programming project projects radio recursion replaydirector reporting researchinmotion rotatetext scanner se server service set sms software sort sql string swing test textfield threads tree trolltech ubuntu utility windows






