Index: javax/swing/AbstractButton.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/AbstractButton.java,v retrieving revision 1.43 diff -u -r1.43 AbstractButton.java --- javax/swing/AbstractButton.java 30 Sep 2005 13:11:05 -0000 1.43 +++ javax/swing/AbstractButton.java 30 Sep 2005 16:35:56 -0000 @@ -549,7 +549,7 @@ */ public ButtonModel getModel() { - return model; + return model; } /** @@ -621,7 +621,8 @@ */ public void setActionCommand(String actionCommand) { - model.setActionCommand(actionCommand); + if (model != null) + model.setActionCommand(actionCommand); } /** @@ -788,7 +789,10 @@ */ public int getMnemonic() { - return getModel().getMnemonic(); + ButtonModel mod = getModel(); + if (mod != null) + return mod.getMnemonic(); + return -1; } /** @@ -816,11 +820,15 @@ */ public void setMnemonic(int mne) { - int old = getModel().getMnemonic(); + ButtonModel mod = getModel(); + int old = -1; + if (mod != null) + old = mod.getMnemonic(); if (old != mne) { - getModel().setMnemonic(mne); + if (mod != null) + mod.setMnemonic(mne); if (text != null && !text.equals("")) { @@ -913,7 +921,9 @@ */ public void setSelected(boolean s) { - getModel().setSelected(s); + ButtonModel mod = getModel(); + if (mod != null) + mod.setSelected(s); } /** @@ -924,7 +934,10 @@ */ public boolean isSelected() { - return getModel().isSelected(); + ButtonModel mod = getModel(); + if (mod != null) + return mod.isSelected(); + return false; } /** @@ -936,7 +949,9 @@ public void setEnabled(boolean b) { super.setEnabled(b); - getModel().setEnabled(b); + ButtonModel mod = getModel(); + if (mod != null) + mod.setEnabled(b); } /** @@ -1675,18 +1690,22 @@ */ public void doClick(int pressTime) { - getModel().setArmed(true); - getModel().setPressed(true); - try - { - java.lang.Thread.sleep(pressTime); - } - catch (java.lang.InterruptedException e) + ButtonModel mod = getModel(); + if (mod != null) { - // probably harmless + mod.setArmed(true); + mod.setPressed(true); + try + { + java.lang.Thread.sleep(pressTime); + } + catch (java.lang.InterruptedException e) + { + // probably harmless + } + mod.setPressed(false); + mod.setArmed(false); } - getModel().setPressed(false); - getModel().setArmed(false); } /** Index: javax/swing/plaf/basic/BasicMenuItemUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java,v retrieving revision 1.27 diff -u -r1.27 BasicMenuItemUI.java --- javax/swing/plaf/basic/BasicMenuItemUI.java 29 Sep 2005 16:37:29 -0000 1.27 +++ javax/swing/plaf/basic/BasicMenuItemUI.java 30 Sep 2005 16:35:57 -0000 @@ -52,6 +52,7 @@ import java.beans.PropertyChangeListener; import java.util.ArrayList; +import javax.swing.ButtonModel; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JMenu; @@ -538,7 +539,9 @@ // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems - if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() + ButtonModel mod = m.getModel(); + if ((m.isSelected() && checkIcon == null) || (mod != null && + mod.isArmed()) && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) @@ -637,8 +640,9 @@ { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem + ButtonModel mod = menuItem.getModel(); if ((menuItem.isSelected() && checkIcon == null) - || menuItem.getModel().isArmed() + || (mod != null && mod.isArmed()) && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else