Original Post
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?