< prev index next >

src/share/classes/com/sun/java/swing/plaf/motif/MotifInternalFrameTitlePane.java

Print this page
rev 1581 : 6693507: There are unnecessary compilation warnings in the com.sun.java.swing.plaf.motif package
Summary: Removed unnecessary castings and other warnings
Reviewed-by: peterz
Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>
rev 1582 : 8020708: NLS mnemonics missing in SwingSet2/JInternalFrame demo
Reviewed-by: malenkov, leonidr


  69 
  70     protected void uninstallListeners() {
  71         // Get around protected method in superclass
  72         super.uninstallListeners();
  73     }
  74 
  75     protected PropertyChangeListener createPropertyChangeListener() {
  76         return this;
  77     }
  78 
  79     protected LayoutManager createLayout() {
  80         return this;
  81     }
  82 
  83     JPopupMenu getSystemMenu() {
  84         return systemMenu;
  85     }
  86 
  87     protected void assembleSystemMenu() {
  88         systemMenu = new JPopupMenu();
  89         JMenuItem mi = (JMenuItem)systemMenu.add(new JMenuItem(restoreAction));
  90         mi.setMnemonic('R');
  91         mi = (JMenuItem) systemMenu.add(new JMenuItem(moveAction));
  92         mi.setMnemonic('M');
  93         mi = (JMenuItem) systemMenu.add(new JMenuItem(sizeAction));
  94         mi.setMnemonic('S');
  95         mi = (JMenuItem) systemMenu.add(new JMenuItem(iconifyAction));
  96         mi.setMnemonic('n');
  97         mi = (JMenuItem) systemMenu.add(new JMenuItem(maximizeAction));
  98         mi.setMnemonic('x');
  99         systemMenu.add(new JSeparator());
 100         mi = (JMenuItem) systemMenu.add(new JMenuItem(closeAction));
 101         mi.setMnemonic('C');
 102 
 103         systemButton = new SystemButton();
 104         systemButton.addActionListener(new ActionListener() {
 105             public void actionPerformed(ActionEvent e) {
 106                 systemMenu.show(systemButton, 0, BUTTON_SIZE);
 107             }
 108         });
 109 
 110         systemButton.addMouseListener(new MouseAdapter() {
 111             public void mousePressed(MouseEvent evt) {
 112                 try {
 113                     frame.setSelected(true);
 114                 } catch (PropertyVetoException pve) {
 115                 }
 116                 if ((evt.getClickCount() == 2)) {
 117                     closeAction.actionPerformed(new
 118                         ActionEvent(evt.getSource(),
 119                             ActionEvent.ACTION_PERFORMED,
 120                             null, evt.getWhen(), 0));
 121                     systemMenu.setVisible(false);
 122                 }
 123             }
 124         });
 125     }
 126 








 127 
 128     protected void createButtons() {
 129         minimizeButton = new MinimizeButton();
 130         minimizeButton.addActionListener(iconifyAction);
 131 
 132         maximizeButton = new MaximizeButton();
 133         maximizeButton.addActionListener(maximizeAction);
 134     }
 135 
 136 
 137     protected void addSubComponents() {
 138         title = new Title(frame.getTitle());
 139         title.setFont(getFont());
 140 
 141         add(systemButton);
 142         add(title);
 143         add(minimizeButton);
 144         add(maximizeButton);
 145     }
 146 
 147     public void paintComponent(Graphics g) {
 148     }
 149 
 150     void setColors(Color c, Color h, Color s) {
 151         color = c;
 152         highlight = h;
 153         shadow = s;
 154     }
 155 
 156     public void actionPerformed(ActionEvent e) {
 157     }
 158 
 159     public void propertyChange(PropertyChangeEvent evt) {
 160         String prop = (String)evt.getPropertyName();
 161         JInternalFrame f = (JInternalFrame)evt.getSource();
 162         boolean value = false;
 163         if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
 164             repaint();
 165         } else if (prop.equals("maximizable")) {
 166             if ((Boolean)evt.getNewValue() == Boolean.TRUE)
 167                 add(maximizeButton);
 168             else
 169                 remove(maximizeButton);
 170             revalidate();
 171             repaint();
 172         } else if (prop.equals("iconable")) {
 173             if ((Boolean)evt.getNewValue() == Boolean.TRUE)
 174                 add(minimizeButton);
 175             else
 176                 remove(minimizeButton);
 177             revalidate();
 178             repaint();
 179         } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
 180             repaint();




  69 
  70     protected void uninstallListeners() {
  71         // Get around protected method in superclass
  72         super.uninstallListeners();
  73     }
  74 
  75     protected PropertyChangeListener createPropertyChangeListener() {
  76         return this;
  77     }
  78 
  79     protected LayoutManager createLayout() {
  80         return this;
  81     }
  82 
  83     JPopupMenu getSystemMenu() {
  84         return systemMenu;
  85     }
  86 
  87     protected void assembleSystemMenu() {
  88         systemMenu = new JPopupMenu();
  89         JMenuItem mi = systemMenu.add(restoreAction);
  90         mi.setMnemonic(getButtonMnemonic("restore"));
  91         mi = systemMenu.add(moveAction);
  92         mi.setMnemonic(getButtonMnemonic("move"));
  93         mi = systemMenu.add(sizeAction);
  94         mi.setMnemonic(getButtonMnemonic("size"));
  95         mi = systemMenu.add(iconifyAction);
  96         mi.setMnemonic(getButtonMnemonic("minimize"));
  97         mi = systemMenu.add(maximizeAction);
  98         mi.setMnemonic(getButtonMnemonic("maximize"));
  99         systemMenu.add(new JSeparator());
 100         mi = systemMenu.add(closeAction);
 101         mi.setMnemonic(getButtonMnemonic("close"));
 102 
 103         systemButton = new SystemButton();
 104         systemButton.addActionListener(new ActionListener() {
 105             public void actionPerformed(ActionEvent e) {
 106                 systemMenu.show(systemButton, 0, BUTTON_SIZE);
 107             }
 108         });
 109 
 110         systemButton.addMouseListener(new MouseAdapter() {
 111             public void mousePressed(MouseEvent evt) {
 112                 try {
 113                     frame.setSelected(true);
 114                 } catch (PropertyVetoException pve) {
 115                 }
 116                 if ((evt.getClickCount() == 2)) {
 117                     closeAction.actionPerformed(new
 118                         ActionEvent(evt.getSource(),
 119                             ActionEvent.ACTION_PERFORMED,
 120                             null, evt.getWhen(), 0));
 121                     systemMenu.setVisible(false);
 122                 }
 123             }
 124         });
 125     }
 126 
 127     private static int getButtonMnemonic(String button) {
 128         try {
 129             return Integer.parseInt(UIManager.getString(
 130                     "InternalFrameTitlePane." + button + "Button.mnemonic"));
 131         } catch (NumberFormatException e) {
 132             return -1;
 133         }
 134     }
 135 
 136     protected void createButtons() {
 137         minimizeButton = new MinimizeButton();
 138         minimizeButton.addActionListener(iconifyAction);
 139 
 140         maximizeButton = new MaximizeButton();
 141         maximizeButton.addActionListener(maximizeAction);
 142     }
 143 
 144 
 145     protected void addSubComponents() {
 146         title = new Title(frame.getTitle());
 147         title.setFont(getFont());
 148 
 149         add(systemButton);
 150         add(title);
 151         add(minimizeButton);
 152         add(maximizeButton);
 153     }
 154 
 155     public void paintComponent(Graphics g) {
 156     }
 157 
 158     void setColors(Color c, Color h, Color s) {
 159         color = c;
 160         highlight = h;
 161         shadow = s;
 162     }
 163 
 164     public void actionPerformed(ActionEvent e) {
 165     }
 166 
 167     public void propertyChange(PropertyChangeEvent evt) {
 168         String prop = evt.getPropertyName();
 169         JInternalFrame f = (JInternalFrame)evt.getSource();
 170         boolean value = false;
 171         if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
 172             repaint();
 173         } else if (prop.equals("maximizable")) {
 174             if ((Boolean)evt.getNewValue() == Boolean.TRUE)
 175                 add(maximizeButton);
 176             else
 177                 remove(maximizeButton);
 178             revalidate();
 179             repaint();
 180         } else if (prop.equals("iconable")) {
 181             if ((Boolean)evt.getNewValue() == Boolean.TRUE)
 182                 add(minimizeButton);
 183             else
 184                 remove(minimizeButton);
 185             revalidate();
 186             repaint();
 187         } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
 188             repaint();


< prev index next >