Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rkazuhiro

[java] errors

This topic is 5840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my code:
import javax.swing.*;			//for the swing graphics lib
//import javax.comm.*;			//for port access
import java.io.*;				//for i/o routines
import java.util.*;				//utility routines
import java.awt.*;				//swings sometimes uses awt libs
import java.awt.event.*;		//for handling events

public class CommControl extends JFrame implements ActionListener{
	//constructor	
	public CommControl(){
		Image frameIcon = Toolkit.getDefaultToolkit().getImage("chip.gif");
		setIconImage(frameIcon);
        setTitle("CommControl");
        setSize(400,300);
        addWindowListener(new WindowAdapter()
          {   public void windowClosing(WindowEvent e){
          		  System.exit(0);
              }
          }
        );
        JMenuBar menubar = new JMenuBar();
        setJMenuBar(menubar);
        //the file menu
        JMenu fileMenu = new JMenu("File");
        fileMenu.addActionListener(this);
        JMenuItem exitMenuItem = new JMenuItem("Exit");
        exitMenuItem.addActionListener(this);
        fileMenu.add(exitMenuItem);
        //the port menu
        JMenu serialPortMenu = new JMenu("Serial Port");
        serialPortMenu.addActionListener(this);
        JMenuItem receiveMenuItem = new JMenuItem("Receive");
        JMenuItem transferMenuItem = new JMenuItem("Transfer");
        JMenuItem configureMenuItem = new JMenuItem("Configure");
        receiveMenuItem.addActionListener(this);
        transferMenuItem.addActionListener(this);
        configureMenuItem.addActionListener(this);
        serialPortMenu.add(receiveMenuItem);
        serialPortMenu.add(transferMenuItem);
        serialPortMenu.add(configureMenuItem);
        //the help menu
        JMenu helpMenu = new JMenu("Help");
        helpMenu.addActionListener(this);
        JMenuItem aboutMenuItem = new JMenuItem("About");
        aboutMenuItem.addActionListener(this);
        helpMenu.add(aboutMenuItem);
        //build the menubar
        menubar.add(fileMenu);
        menubar.add(serialPortMenu);
        menubar.add(helpMenu);
		initialize();
	}

	public static void initialize(){
	//set look and feel
	try {  //try to set the look of the program, the java feel
            UIManager.setLookAndFeel(
                UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (Exception e) { } //use default if we can''t set lookn''feel
	//detect platform
	//detect locale
	//generate list of comm ports
	}
		
	public void actionPerformed(ActionEvent evt){
		String arg = evt.getActionCommand();
		if(arg.equals("Exit")) System.exit(0);
    }
    //public void menuSelected(MenuEvent evt) {}
    //public void menuDeselected(MenuEvent evt) {}
    //public void menuCanceled(MenuEvent evt) {}
			
	public void initialize(){
	//set look and feel
		try {  //try to set the look of the program, the java feel
        	    UIManager.setLookAndFeel(
            	    UIManager.getCrossPlatformLookAndFeelClassName());
    	} catch (Exception e) { } //use default if we can''t set lookn''feel
	//detect platform
	//detect locale
	//generate list of comm ports
	}
	
	public static void main(String args[]){
		JFrame f = new CommControl();  //create an instance of the frame
		f.show();
	}
}
 
First of all, I can''t get javac to find javax.comm package. I really need this package, as it is core to the entire program. Does anyone know if I have to download it separately somewhere? Secondly, I have an error here(please excuse the Japanese, I''ll translate):
D:\Program Files\Xinox Software\JCreator LE\MyProjects\CommControl\CommControl.java:72: initialize() ‚Í CommControl ‚Å’è‹`‚³‚ê‚Ä‚¢‚Ü‚·B
	public void initialize(){
 
The error message is that initialze() is not defined in CommControl. What does that mean? What did I do that was incorrect?

Share this post


Link to post
Share on other sites
Advertisement
Hello rkazuhiro,

The comm package can be downloaded from the java.sun web site

http://java.sun.com/products/javacomm/

I''m not prepaired to look at your code in great detail, but the one thing that jumps out is you''ve got two definitions to the initialize function (one static and one normal) And I don''t believe that would be valid java.

Hope this helps

Tom.

Share this post


Link to post
Share on other sites
About the javax.comm package:

It's not in the 1.4 SDK; it must be an external API. Check that it's correctly installed, and located in your classpath, etc.

About the initialize:

I'm not sure about this. My first thought was that 'initialize' was a final method, so I looked at the source for JFrame and its superclasses, only to find there wasn't a method of that name. I looked at this for ages, and was then about to try compiling it, when I saw: you've defined initialize() twice: as a public void, and as a public static void.

[EDIT]: TomH: Your too fast, dammit!

[edited by - ServantOfGlaaki on May 30, 2002 2:39:56 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!