-
Bug
-
Resolution: Fixed
-
P3
-
7, 7u4
-
b16
-
generic, x86
-
os_x
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2222367 | 8 | Anthony Petrov | P3 | Resolved | Fixed | b34 |
FULL PRODUCT VERSION :
JDK 7 from http://jdk7.java.net/macportpreview/
*** I did Not get this string from command line output ***
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.2
A DESCRIPTION OF THE PROBLEM :
This package works fine on Java 1.6 (by Apple) BUT NOT on Java 1.7 (current work in progress). I tried to use the About, Preferences and Quit methods (these menu items are on the Apple menu on Mac), with the following results:
ABOUT - doesn't work at all - just gives default Java About
PREFERENCES - doen't work either from Apple menu or menu-shortcut (comma).
QUIT - works from Apple menu but NOT from menu-shortcut (Q).
In all cases where it doesn't work, I checked that the Handler is not being invoked. The code below is a simple app that displays a message when the handlers are invoked. Works fine on Java 1.6 (from Apple). Code has TWO class files.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code above to interface with a simple Java app running on Mac OS X 10.7
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Accessing these items from the Apple menu, either with the mouse or with a standard menu-shortcut, should invoke the handler.
ACTUAL -
For about you get the default About box - this would be expected if you passed a null pointer to the handler, but I passed a valid reference
ERROR MESSAGES/STACK TRACES THAT OCCUR :
none - the submitted app logs whether or not the handlers are being invoked
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
public class TestApp extends Frame implements LayoutManager, ActionListener {
private AppleListener mAppleListener = null;
private Label mListenerLabel;
private Label mAboutLabel;
private Label mPreferencesLabel;
private Label mQuitLabel;
private Button mClearButton;
public TestApp() {
super("TestApp");
setResizable(false);
addNotify();
setLayout(this);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
try{
try {
mAppleListener = new AppleListener(this);
} catch (Exception e) {}
} catch (Error e) {}
mListenerLabel = new Label("Listener " + (mAppleListener != null));
add(mListenerLabel);
mAboutLabel = new Label("---");
add(mAboutLabel);
mPreferencesLabel = new Label("---");
add(mPreferencesLabel);
mQuitLabel = new Label("---");
add(mQuitLabel);
mClearButton = new Button("Clear");
mClearButton.addActionListener(this);
add(mClearButton);
setVisible(true);
setSize(200, 300);
}
public final void addLayoutComponent(String n, Component c) {}
public final void removeLayoutComponent(Component c) {}
public final Dimension preferredLayoutSize(Container t)
{return new Dimension(1, 1);}
public final Dimension minimumLayoutSize(Container t)
{return new Dimension(1, 1);}
public final void layoutContainer(Container target)
{
mListenerLabel.setBounds(20, 50, 150, 20);
mAboutLabel.setBounds(20, 100, 150, 20);
mPreferencesLabel.setBounds(20, 150, 150, 20);
mQuitLabel.setBounds(20, 200, 150, 20);
mClearButton.setBounds(20, 250, 50, 30);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == mClearButton) {
mAboutLabel.setText("---");
mPreferencesLabel.setText("---");
mQuitLabel.setText("---");
}
}
public final void processAbout() {mAboutLabel.setText("processAbout");}
public final void processPreferences(){mPreferencesLabel.setText("processPreferences");}
public final void processQuit(){mQuitLabel.setText("processQuit");}
public static void main(String args[]) {
new TestApp();
}
}
import com.apple.eawt.*;
public class AppleListener {
private TestApp mTestApp;
public AppleListener(TestApp controller) {
mTestApp = controller;
try{
try {
Application.getApplication().setAboutHandler(
new AboutHandler() {
public void handleAbout(AppEvent.AboutEvent e) {
mTestApp.processAbout();
}
}
);
Application.getApplication().setPreferencesHandler(
new PreferencesHandler() {
public void handlePreferences(AppEvent.PreferencesEvent e) {
mTestApp.processPreferences();
}
}
);
Application.getApplication().setQuitHandler(
new QuitHandler() {
public void handleQuitRequestWith(
AppEvent.QuitEvent e, QuitResponse response) {
mTestApp.processQuit();
response.cancelQuit();
}
}
);
} catch (Exception e) {}
} catch (Error e) {}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None - I reported this as severe because it would severely impact Apps that are supposed to behave correctly on Mac OS using forthcoming Java 7.
JDK 7 from http://jdk7.java.net/macportpreview/
*** I did Not get this string from command line output ***
ADDITIONAL OS VERSION INFORMATION :
Mac OS X 10.7.2
A DESCRIPTION OF THE PROBLEM :
This package works fine on Java 1.6 (by Apple) BUT NOT on Java 1.7 (current work in progress). I tried to use the About, Preferences and Quit methods (these menu items are on the Apple menu on Mac), with the following results:
ABOUT - doesn't work at all - just gives default Java About
PREFERENCES - doen't work either from Apple menu or menu-shortcut (comma).
QUIT - works from Apple menu but NOT from menu-shortcut (Q).
In all cases where it doesn't work, I checked that the Handler is not being invoked. The code below is a simple app that displays a message when the handlers are invoked. Works fine on Java 1.6 (from Apple). Code has TWO class files.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use the code above to interface with a simple Java app running on Mac OS X 10.7
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Accessing these items from the Apple menu, either with the mouse or with a standard menu-shortcut, should invoke the handler.
ACTUAL -
For about you get the default About box - this would be expected if you passed a null pointer to the handler, but I passed a valid reference
ERROR MESSAGES/STACK TRACES THAT OCCUR :
none - the submitted app logs whether or not the handlers are being invoked
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
public class TestApp extends Frame implements LayoutManager, ActionListener {
private AppleListener mAppleListener = null;
private Label mListenerLabel;
private Label mAboutLabel;
private Label mPreferencesLabel;
private Label mQuitLabel;
private Button mClearButton;
public TestApp() {
super("TestApp");
setResizable(false);
addNotify();
setLayout(this);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
});
try{
try {
mAppleListener = new AppleListener(this);
} catch (Exception e) {}
} catch (Error e) {}
mListenerLabel = new Label("Listener " + (mAppleListener != null));
add(mListenerLabel);
mAboutLabel = new Label("---");
add(mAboutLabel);
mPreferencesLabel = new Label("---");
add(mPreferencesLabel);
mQuitLabel = new Label("---");
add(mQuitLabel);
mClearButton = new Button("Clear");
mClearButton.addActionListener(this);
add(mClearButton);
setVisible(true);
setSize(200, 300);
}
public final void addLayoutComponent(String n, Component c) {}
public final void removeLayoutComponent(Component c) {}
public final Dimension preferredLayoutSize(Container t)
{return new Dimension(1, 1);}
public final Dimension minimumLayoutSize(Container t)
{return new Dimension(1, 1);}
public final void layoutContainer(Container target)
{
mListenerLabel.setBounds(20, 50, 150, 20);
mAboutLabel.setBounds(20, 100, 150, 20);
mPreferencesLabel.setBounds(20, 150, 150, 20);
mQuitLabel.setBounds(20, 200, 150, 20);
mClearButton.setBounds(20, 250, 50, 30);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == mClearButton) {
mAboutLabel.setText("---");
mPreferencesLabel.setText("---");
mQuitLabel.setText("---");
}
}
public final void processAbout() {mAboutLabel.setText("processAbout");}
public final void processPreferences(){mPreferencesLabel.setText("processPreferences");}
public final void processQuit(){mQuitLabel.setText("processQuit");}
public static void main(String args[]) {
new TestApp();
}
}
import com.apple.eawt.*;
public class AppleListener {
private TestApp mTestApp;
public AppleListener(TestApp controller) {
mTestApp = controller;
try{
try {
Application.getApplication().setAboutHandler(
new AboutHandler() {
public void handleAbout(AppEvent.AboutEvent e) {
mTestApp.processAbout();
}
}
);
Application.getApplication().setPreferencesHandler(
new PreferencesHandler() {
public void handlePreferences(AppEvent.PreferencesEvent e) {
mTestApp.processPreferences();
}
}
);
Application.getApplication().setQuitHandler(
new QuitHandler() {
public void handleQuitRequestWith(
AppEvent.QuitEvent e, QuitResponse response) {
mTestApp.processQuit();
response.cancelQuit();
}
}
);
} catch (Exception e) {}
} catch (Error e) {}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None - I reported this as severe because it would severely impact Apps that are supposed to behave correctly on Mac OS using forthcoming Java 7.
- backported by
-
JDK-2222367 [macosx] Class com.apple.eawt not functioning
- Resolved
- duplicates
-
JDK-7144027 [macosx] PreferencesHandler and AboutHandler not working
- Closed
- relates to
-
JDK-7159266 [macosx] ApplicationDelegate should not be set in the headless mode
- Closed
-
JDK-7130377 [macosx] Adding Preferences menu results in NPE
- Closed