aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes ActionListener not recognized under Solaris Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ActionListener not recognized under Solaris" Watch "ActionListener not recognized under Solaris" New topic
Author

ActionListener not recognized under Solaris

Jason Travis
Greenhorn

Joined: Apr 05, 2001
Posts: 8
Hello. I have an actionListener which runs under Windows but when I move the jar file to Solaris the only listener that works is the MouseEventListener.
I need help fast...thanks in advance.
-Jason
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Could you post the code of your ActionListener?

Because I know that the Solaris system supports ActionListeners... maybe there is a system dependent call being made in yours, or maybe there are different versions of Java installed on the machines...

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jason Travis
Greenhorn

Joined: Apr 05, 2001
Posts: 8
What follows is the code you requested...
public class LoginFrame extends JFrame {
JPanel contentPane;
JPanel jPanel1 = new JPanel();
JLabel jLabelUserName = new JLabel();
JLabel jLabelPassword = new JLabel();
JPasswordField jPasswordField = new JPasswordField();
JTextField jUserNameField = new JTextField();
JButton QuitButton = new JButton();
JPanel jPanel2 = new JPanel();
JButton SubmitButton = new JButton();
JPanel jPanel3 = new JPanel();
JPanel jPanel4 = new JPanel();
GridBagLayout gridBagLayout1 = new GridBagLayout();
GridBagLayout gridBagLayout2 = new GridBagLayout();
GridBagLayout gridBagLayout3 = new GridBagLayout();
GridBagLayout gridBagLayout4 = new GridBagLayout();
GridBagLayout gridBagLayout5 = new GridBagLayout();
private Object x = this;
boolean resizable = false;
boolean generateNotification90 = false;
boolean generateNotification91 = false;
boolean generateNotification92 = false;
/**Construct the frame*/
public LoginFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(gridBagLayout1);
this.setSize(new Dimension(400, 300));
this.setResizable(resizable);
this.setTitle("Login");
jPanel1.setLayout(gridBagLayout2);
jLabelUserName.setToolTipText("");
jLabelUserName.setHorizontalAlignment(SwingConstants.CENTER);
jLabelUserName.setHorizontalTextPosition(SwingConstants.RIGHT);
jLabelUserName.setText("User Name");
jLabelPassword.setToolTipText("");
jLabelPassword.setHorizontalAlignment(SwingConstants.CENTER);
jLabelPassword.setHorizontalTextPosition(SwingConstants.CENTER);
jLabelPassword.setText("Password");
jPanel1.setToolTipText("");
QuitButton.setText("Exit");
QuitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
QuitButton_actionPerformed(e);
}
});
QuitButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
QuitButton_mousePressed(e);
}
});
jPanel2.setLayout(gridBagLayout5);
SubmitButton.setText("Submit");
SubmitButton.setEnabled(true);
SubmitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
submitButtonActivated();
}
});
SubmitButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent f) {
if (f.getID() == f.MOUSE_PRESSED) {
submitButtonActivated();
}
}
});
jPanel3.setLayout(gridBagLayout4);
jPanel4.setLayout(gridBagLayout3);
contentPane.add(jPanel1, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(36, 29, 0, 67), 0, 13));
jPanel1.add(jLabelUserName, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(40, 22, 0, 0), 18, 5));
jPanel1.add(jLabelPassword, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(37, 22, 13, 0), 22, 5));
jPanel1.add(jPasswordField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(35, 18, 13, 1), 72, 3));
jPanel1.add(jUserNameField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(40, 17, 0, 1), 119, 2));
contentPane.add(jPanel2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(26, 61, 34, 67), 0, 5));
jPanel2.add(jPanel3, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 0, 0), 0, 0));
jPanel3.add(SubmitButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(17, 9, 16, 9), 0, 0));
jPanel2.add(jPanel4, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 90, 0, 0), 0, 0));
jPanel4.add(QuitButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 9, 17, 9), 16, 0));
}
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void QuitButton_mousePressed(MouseEvent e) {
ConfirmationsAndNotifications confirm = new ConfirmationsAndNotifications(this, 8);
this.setEnabled(false);
}
void QuitButton_actionPerformed(ActionEvent e) {
ConfirmationsAndNotifications confirm = new ConfirmationsAndNotifications(this, 8);
this.setEnabled(false);
}
void submitButtonActivated() {
try {
//-----------Added to replace deprecated getText() method------------------
jUserNameField.selectAll();
jPasswordField.selectAll();
String userName = jUserNameField.getSelectedText();
String passWord = jPasswordField.getSelectedText();
//---------End Added to replace deprecated getText() method-------------------
if (userName == null | | passWord == null) {
if (userName == null && passWord != null) {
// generate window telling user to supply a username
ConfirmationsAndNotifications notification = new ConfirmationsAndNotifications(x, 90);
} else if (userName != null && passWord == null) {
// generate window telling user to supply a password
ConfirmationsAndNotifications notification = new ConfirmationsAndNotifications(x, 91);
} else {
// generate window telling user to supply both a username
// and a password
ConfirmationsAndNotifications notification = new ConfirmationsAndNotifications(x, 92);
}
}else if (userName.equals("pervigil") && passWord.equals("pervigil")) {
this.hide();
MainFrame f = new MainFrame(this); // create a new MainFrame object
MainFrame currentMainFrame = f;
if (!f.imageFileDoesNotExistOrNotFile) {
f.dispose();
f.setJMenuBar(currentMainFrame.mb); // add the MenuBar object to this instance of MainFrame
this.dispose();
if (f.getConnectionStatus()) {
f.dispose();
} else {
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (com.pervigil.PingUI.packFrame) {
f.pack();
} else {
f.validate();
}
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = f.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
f.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
f.setVisible(true);
}
} else {
this.dispose();
}
} else {
System.exit(1);
} // end of if statment to check username and password fields text
} catch (Exception i) {
System.out.println("NullPointerException or ClassCastException occured during Submitbutton actionPerformed method" + i);
}
} // end of submitButtonActivated method
} // end of LoginFrame class
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

OK... I got your code running... had to comment out references to other classes... How exactly is the actionListener "not working"? I ran it on both a Windows NT machine and a Solaris machine and they both seemed to work the same... The problem may be in a class that the actionListener is calling...

-Nate
Jason Travis
Greenhorn

Joined: Apr 05, 2001
Posts: 8
The problem is that under Win2K you can actually perform either a mouse click on say the Submit button or hit the enter key to perform the same event. However, I moved the jar file over to the Solaris 8 system and ran the program and the application would not recognize the enter key (when pressed) as an action event. The application would simply do nothing.
I appreciate all you help. Thank you for your suggestions.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Under Solaris the space bar activates buttons and such... not the Enter key...

-Nate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionListener not recognized under Solaris