OMG, Jave的JMenu居然有433个方法
Java的Swing类库中有一个类叫JMenu,这个类上面有7层的继承,加上所有被继承下来的方法,这个类一共有433个方法,虽然,很多类是从上面继承下来的,而它自己的方法并没有定义太多的方法,不过,继承体系过深,在底层类上要想知道所有的继承下来的东西并不是一样容易的事情。这个例子展示了一个滥用代码重用的反面案例。我个人认为我们应该反思一下滥用面向对象的作法。
要把Java一个类所有的方法例出来并不是一件难事,使用Javascript 利用Firefox浏览器所支持的Package来穷举JMenu的方法可以很方便的列出所有的方法。
下面是这段Javascripts程序:
虽然,在Firefox下有比较严格的安全限制,我们并不一定能够使用Swing类库中所有的Java方法,但我们查看一下其继承体系和一个类所拥有的方法却没有什么安全问题。
使用上面那段程序,你可以在Firefox中输出JMenu的433个如下的方法,下面是的列表中JMenu的方法在最后。
下面你可以理解为是在灌水:
- java.awt.Component.action(java.awt.Event,java.lang.Object)
- java.awt.Component.add(java.awt.PopupMenu)
- java.awt.Component.addComponentListener(java.awt.event.ComponentListener)
- java.awt.Component.addFocusListener(java.awt.event.FocusListener)
- java.awt.Component.addHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
- java.awt.Component.addHierarchyListener(java.awt.event.HierarchyListener)
- java.awt.Component.addInputMethodListener(java.awt.event.InputMethodListener)
- java.awt.Component.addKeyListener(java.awt.event.KeyListener)
- java.awt.Component.addMouseListener(java.awt.event.MouseListener)
- java.awt.Component.addMouseMotionListener(java.awt.event.MouseMotionListener)
- java.awt.Component.addMouseWheelListener(java.awt.event.MouseWheelListener)
- java.awt.Component.bounds()
- java.awt.Component.checkImage(java.awt.Image,int,int,java.awt.image.ImageObserver)
- java.awt.Component.checkImage(java.awt.Image,java.awt.image.ImageObserver)
- java.awt.Component.contains(java.awt.Point)
- java.awt.Component.createImage(int,int)
- java.awt.Component.createImage(java.awt.image.ImageProducer)
- java.awt.Component.createVolatileImage(int,int)
- java.awt.Component.createVolatileImage(int,int,java.awt.ImageCapabilities)
- java.awt.Component.dispatchEvent(java.awt.AWTEvent)
- java.awt.Component.enable(boolean)
- java.awt.Component.enableInputMethods(boolean)
- java.awt.Component.firePropertyChange(java.lang.String,byte,byte)
- java.awt.Component.firePropertyChange(java.lang.String,double,double)
- java.awt.Component.firePropertyChange(java.lang.String,float,float)
- java.awt.Component.firePropertyChange(java.lang.String,long,long)
- java.awt.Component.firePropertyChange(java.lang.String,short,short)
- java.awt.Component.getBackground()
- java.awt.Component.getBounds()
- java.awt.Component.getColorModel()
- java.awt.Component.getComponentListeners()
- java.awt.Component.getComponentOrientation()
- java.awt.Component.getCursor()
- java.awt.Component.getDropTarget()
- java.awt.Component.getFocusCycleRootAncestor()
- java.awt.Component.getFocusListeners()
- java.awt.Component.getFocusTraversalKeysEnabled()
- java.awt.Component.getFont()
- java.awt.Component.getForeground()
- java.awt.Component.getGraphicsConfiguration()
- java.awt.Component.getHierarchyBoundsListeners()
- java.awt.Component.getHierarchyListeners()
- java.awt.Component.getIgnoreRepaint()
- java.awt.Component.getInputContext()
- java.awt.Component.getInputMethodListeners()
- java.awt.Component.getInputMethodRequests()
- java.awt.Component.getKeyListeners()
- java.awt.Component.getLocale()
- java.awt.Component.getLocation()
- java.awt.Component.getLocationOnScreen()
- java.awt.Component.getMouseListeners()
- java.awt.Component.getMouseMotionListeners()
- java.awt.Component.getMousePosition()
- java.awt.Component.getMouseWheelListeners()
- java.awt.Component.getName()
- java.awt.Component.getParent()
- java.awt.Component.getPeer()
- java.awt.Component.getPropertyChangeListeners()
- java.awt.Component.getPropertyChangeListeners(java.lang.String)
- java.awt.Component.getSize()
- java.awt.Component.getToolkit()
- java.awt.Component.getTreeLock()
- java.awt.Component.gotFocus(java.awt.Event,java.lang.Object)
- java.awt.Component.handleEvent(java.awt.Event)
- java.awt.Component.hasFocus()
- java.awt.Component.hide()
- java.awt.Component.inside(int,int)
- java.awt.Component.isBackgroundSet()
- java.awt.Component.isCursorSet()
- java.awt.Component.isDisplayable()
- java.awt.Component.isEnabled()
- java.awt.Component.isFocusOwner()
- java.awt.Component.isFocusTraversable()
- java.awt.Component.isFocusable()
- java.awt.Component.isFontSet()
- java.awt.Component.isForegroundSet()
- java.awt.Component.isLightweight()
- java.awt.Component.isMaximumSizeSet()
- java.awt.Component.isMinimumSizeSet()
- java.awt.Component.isPreferredSizeSet()
- java.awt.Component.isShowing()
- java.awt.Component.isValid()
- java.awt.Component.isVisible()
- java.awt.Component.keyDown(java.awt.Event,int)
- java.awt.Component.keyUp(java.awt.Event,int)
- java.awt.Component.list()
- java.awt.Component.list(java.io.PrintStream)
- java.awt.Component.list(java.io.PrintWriter)
- java.awt.Component.location()
- java.awt.Component.lostFocus(java.awt.Event,java.lang.Object)
- java.awt.Component.mouseDown(java.awt.Event,int,int)
- java.awt.Component.mouseDrag(java.awt.Event,int,int)
- java.awt.Component.mouseEnter(java.awt.Event,int,int)
- java.awt.Component.mouseExit(java.awt.Event,int,int)
- java.awt.Component.mouseMove(java.awt.Event,int,int)
- java.awt.Component.mouseUp(java.awt.Event,int,int)
- java.awt.Component.move(int,int)
- java.awt.Component.nextFocus()
- java.awt.Component.paintAll(java.awt.Graphics)
- java.awt.Component.postEvent(java.awt.Event)
- java.awt.Component.prepareImage(java.awt.Image,int,int,java.awt.image.ImageObserver)
- java.awt.Component.prepareImage(java.awt.Image,java.awt.image.ImageObserver)
- java.awt.Component.remove(java.awt.MenuComponent)
- java.awt.Component.removeComponentListener(java.awt.event.ComponentListener)
- java.awt.Component.removeFocusListener(java.awt.event.FocusListener)
- java.awt.Component.removeHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
- java.awt.Component.removeHierarchyListener(java.awt.event.HierarchyListener)
- java.awt.Component.removeInputMethodListener(java.awt.event.InputMethodListener)
- java.awt.Component.removeKeyListener(java.awt.event.KeyListener)
- java.awt.Component.removeMouseListener(java.awt.event.MouseListener)
- java.awt.Component.removeMouseMotionListener(java.awt.event.MouseMotionListener)
- java.awt.Component.removeMouseWheelListener(java.awt.event.MouseWheelListener)
- java.awt.Component.removePropertyChangeListener(java.beans.PropertyChangeListener)
- java.awt.Component.removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
- java.awt.Component.repaint()
- java.awt.Component.repaint(int,int,int,int)
- java.awt.Component.repaint(long)
- java.awt.Component.resize(int,int)
- java.awt.Component.resize(java.awt.Dimension)
- java.awt.Component.setBounds(int,int,int,int)
- java.awt.Component.setBounds(java.awt.Rectangle)
- java.awt.Component.setCursor(java.awt.Cursor)
- java.awt.Component.setDropTarget(java.awt.dnd.DropTarget)
- java.awt.Component.setFocusTraversalKeysEnabled(boolean)
- java.awt.Component.setFocusable(boolean)
- java.awt.Component.setIgnoreRepaint(boolean)
- java.awt.Component.setLocale(java.util.Locale)
- java.awt.Component.setLocation(int,int)
- java.awt.Component.setLocation(java.awt.Point)
- java.awt.Component.setName(java.lang.String)
- java.awt.Component.setSize(int,int)
- java.awt.Component.setSize(java.awt.Dimension)
- java.awt.Component.show()
- java.awt.Component.show(boolean)
- java.awt.Component.size()
- java.awt.Component.toString()
- java.awt.Component.transferFocus()
- java.awt.Component.transferFocusBackward()
- java.awt.Component.transferFocusUpCycle()
- java.awt.Container.add(java.awt.Component,java.lang.Object)
- java.awt.Container.add(java.awt.Component,java.lang.Object,int)
- java.awt.Container.add(java.lang.String,java.awt.Component)
- java.awt.Container.addContainerListener(java.awt.event.ContainerListener)
- java.awt.Container.addPropertyChangeListener(java.beans.PropertyChangeListener)
- java.awt.Container.addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
- java.awt.Container.areFocusTraversalKeysSet(int)
- java.awt.Container.countComponents()
- java.awt.Container.deliverEvent(java.awt.Event)
- java.awt.Container.doLayout()
- java.awt.Container.findComponentAt(int,int)
- java.awt.Container.findComponentAt(java.awt.Point)
- java.awt.Container.getComponent(int)
- java.awt.Container.getComponentAt(int,int)
- java.awt.Container.getComponentAt(java.awt.Point)
- java.awt.Container.getComponentCount()
- java.awt.Container.getComponentZOrder(java.awt.Component)
- java.awt.Container.getComponents()
- java.awt.Container.getContainerListeners()
- java.awt.Container.getFocusTraversalKeys(int)
- java.awt.Container.getFocusTraversalPolicy()
- java.awt.Container.getLayout()
- java.awt.Container.getMousePosition(boolean)
- java.awt.Container.insets()
- java.awt.Container.invalidate()
- java.awt.Container.isAncestorOf(java.awt.Component)
- java.awt.Container.isFocusCycleRoot()
- java.awt.Container.isFocusCycleRoot(java.awt.Container)
- java.awt.Container.isFocusTraversalPolicyProvider()
- java.awt.Container.isFocusTraversalPolicySet()
- java.awt.Container.layout()
- java.awt.Container.list(java.io.PrintStream,int)
- java.awt.Container.list(java.io.PrintWriter,int)
- java.awt.Container.locate(int,int)
- java.awt.Container.minimumSize()
- java.awt.Container.paintComponents(java.awt.Graphics)
- java.awt.Container.preferredSize()
- java.awt.Container.printComponents(java.awt.Graphics)
- java.awt.Container.removeContainerListener(java.awt.event.ContainerListener)
- java.awt.Container.setComponentZOrder(java.awt.Component,int)
- java.awt.Container.setFocusCycleRoot(boolean)
- java.awt.Container.setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
- java.awt.Container.setFocusTraversalPolicyProvider(boolean)
- java.awt.Container.transferFocusDownCycle()
- java.awt.Container.validate()
- java.lang.Object.equals(java.lang.Object)
- java.lang.Object.getClass()
- java.lang.Object.hashCode()
- java.lang.Object.notify()
- java.lang.Object.notifyAll()
- java.lang.Object.wait()
- java.lang.Object.wait(long)
- java.lang.Object.wait(long,int)
- javax.swing.AbstractButton.addActionListener(java.awt.event.ActionListener)
- javax.swing.AbstractButton.addChangeListener(javax.swing.event.ChangeListener)
- javax.swing.AbstractButton.addItemListener(java.awt.event.ItemListener)
- javax.swing.AbstractButton.doClick()
- javax.swing.AbstractButton.getAction()
- javax.swing.AbstractButton.getActionCommand()
- javax.swing.AbstractButton.getActionListeners()
- javax.swing.AbstractButton.getChangeListeners()
- javax.swing.AbstractButton.getDisabledIcon()
- javax.swing.AbstractButton.getDisabledSelectedIcon()
- javax.swing.AbstractButton.getDisplayedMnemonicIndex()
- javax.swing.AbstractButton.getHideActionText()
- javax.swing.AbstractButton.getHorizontalAlignment()
- javax.swing.AbstractButton.getHorizontalTextPosition()
- javax.swing.AbstractButton.getIcon()
- javax.swing.AbstractButton.getIconTextGap()
- javax.swing.AbstractButton.getItemListeners()
- javax.swing.AbstractButton.getLabel()
- javax.swing.AbstractButton.getMargin()
- javax.swing.AbstractButton.getMnemonic()
- javax.swing.AbstractButton.getModel()
- javax.swing.AbstractButton.getMultiClickThreshhold()
- javax.swing.AbstractButton.getPressedIcon()
- javax.swing.AbstractButton.getRolloverIcon()
- javax.swing.AbstractButton.getRolloverSelectedIcon()
- javax.swing.AbstractButton.getSelectedIcon()
- javax.swing.AbstractButton.getSelectedObjects()
- javax.swing.AbstractButton.getText()
- javax.swing.AbstractButton.getUI()
- javax.swing.AbstractButton.getVerticalAlignment()
- javax.swing.AbstractButton.getVerticalTextPosition()
- javax.swing.AbstractButton.imageUpdate(java.awt.Image,int,int,int,int,int)
- javax.swing.AbstractButton.isBorderPainted()
- javax.swing.AbstractButton.isContentAreaFilled()
- javax.swing.AbstractButton.isFocusPainted()
- javax.swing.AbstractButton.isRolloverEnabled()
- javax.swing.AbstractButton.removeActionListener(java.awt.event.ActionListener)
- javax.swing.AbstractButton.removeChangeListener(javax.swing.event.ChangeListener)
- javax.swing.AbstractButton.removeItemListener(java.awt.event.ItemListener)
- javax.swing.AbstractButton.removeNotify()
- javax.swing.AbstractButton.setAction(javax.swing.Action)
- javax.swing.AbstractButton.setActionCommand(java.lang.String)
- javax.swing.AbstractButton.setBorderPainted(boolean)
- javax.swing.AbstractButton.setContentAreaFilled(boolean)
- javax.swing.AbstractButton.setDisabledIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setDisabledSelectedIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setDisplayedMnemonicIndex(int)
- javax.swing.AbstractButton.setFocusPainted(boolean)
- javax.swing.AbstractButton.setHideActionText(boolean)
- javax.swing.AbstractButton.setHorizontalAlignment(int)
- javax.swing.AbstractButton.setHorizontalTextPosition(int)
- javax.swing.AbstractButton.setIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setIconTextGap(int)
- javax.swing.AbstractButton.setLabel(java.lang.String)
- javax.swing.AbstractButton.setLayout(java.awt.LayoutManager)
- javax.swing.AbstractButton.setMargin(java.awt.Insets)
- javax.swing.AbstractButton.setMnemonic(char)
- javax.swing.AbstractButton.setMnemonic(int)
- javax.swing.AbstractButton.setMultiClickThreshhold(long)
- javax.swing.AbstractButton.setPressedIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setRolloverEnabled(boolean)
- javax.swing.AbstractButton.setRolloverIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setRolloverSelectedIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setSelectedIcon(javax.swing.Icon)
- javax.swing.AbstractButton.setText(java.lang.String)
- javax.swing.AbstractButton.setUI(javax.swing.plaf.ButtonUI)
- javax.swing.AbstractButton.setVerticalAlignment(int)
- javax.swing.AbstractButton.setVerticalTextPosition(int)
- javax.swing.JComponent.addAncestorListener(javax.swing.event.AncestorListener)
- javax.swing.JComponent.addNotify()
- javax.swing.JComponent.addVetoableChangeListener(java.beans.VetoableChangeListener)
- javax.swing.JComponent.computeVisibleRect(java.awt.Rectangle)
- javax.swing.JComponent.contains(int,int)
- javax.swing.JComponent.createToolTip()
- javax.swing.JComponent.disable()
- javax.swing.JComponent.enable()
- javax.swing.JComponent.firePropertyChange(java.lang.String,boolean,boolean)
- javax.swing.JComponent.firePropertyChange(java.lang.String,char,char)
- javax.swing.JComponent.firePropertyChange(java.lang.String,int,int)
- javax.swing.JComponent.getActionForKeyStroke(javax.swing.KeyStroke)
- javax.swing.JComponent.getActionMap()
- javax.swing.JComponent.getAlignmentX()
- javax.swing.JComponent.getAlignmentY()
- javax.swing.JComponent.getAncestorListeners()
- javax.swing.JComponent.getAutoscrolls()
- javax.swing.JComponent.getBaseline(int,int)
- javax.swing.JComponent.getBaselineResizeBehavior()
- javax.swing.JComponent.getBorder()
- javax.swing.JComponent.getBounds(java.awt.Rectangle)
- javax.swing.JComponent.getClientProperty(java.lang.Object)
- javax.swing.JComponent.getComponentPopupMenu()
- javax.swing.JComponent.getConditionForKeyStroke(javax.swing.KeyStroke)
- javax.swing.JComponent.getDebugGraphicsOptions()
- javax.swing.JComponent.getDefaultLocale()
- javax.swing.JComponent.getFontMetrics(java.awt.Font)
- javax.swing.JComponent.getGraphics()
- javax.swing.JComponent.getHeight()
- javax.swing.JComponent.getInheritsPopupMenu()
- javax.swing.JComponent.getInputMap()
- javax.swing.JComponent.getInputMap(int)
- javax.swing.JComponent.getInputVerifier()
- javax.swing.JComponent.getInsets()
- javax.swing.JComponent.getInsets(java.awt.Insets)
- javax.swing.JComponent.getListeners(java.lang.Class)
- javax.swing.JComponent.getLocation(java.awt.Point)
- javax.swing.JComponent.getMaximumSize()
- javax.swing.JComponent.getMinimumSize()
- javax.swing.JComponent.getNextFocusableComponent()
- javax.swing.JComponent.getPopupLocation(java.awt.event.MouseEvent)
- javax.swing.JComponent.getPreferredSize()
- javax.swing.JComponent.getRegisteredKeyStrokes()
- javax.swing.JComponent.getRootPane()
- javax.swing.JComponent.getSize(java.awt.Dimension)
- javax.swing.JComponent.getToolTipLocation(java.awt.event.MouseEvent)
- javax.swing.JComponent.getToolTipText()
- javax.swing.JComponent.getToolTipText(java.awt.event.MouseEvent)
- javax.swing.JComponent.getTopLevelAncestor()
- javax.swing.JComponent.getTransferHandler()
- javax.swing.JComponent.getVerifyInputWhenFocusTarget()
- javax.swing.JComponent.getVetoableChangeListeners()
- javax.swing.JComponent.getVisibleRect()
- javax.swing.JComponent.getWidth()
- javax.swing.JComponent.getX()
- javax.swing.JComponent.getY()
- javax.swing.JComponent.grabFocus()
- javax.swing.JComponent.isDoubleBuffered()
- javax.swing.JComponent.isLightweightComponent(java.awt.Component)
- javax.swing.JComponent.isManagingFocus()
- javax.swing.JComponent.isOpaque()
- javax.swing.JComponent.isOptimizedDrawingEnabled()
- javax.swing.JComponent.isPaintingForPrint()
- javax.swing.JComponent.isPaintingTile()
- javax.swing.JComponent.isRequestFocusEnabled()
- javax.swing.JComponent.isValidateRoot()
- javax.swing.JComponent.paint(java.awt.Graphics)
- javax.swing.JComponent.paintImmediately(int,int,int,int)
- javax.swing.JComponent.paintImmediately(java.awt.Rectangle)
- javax.swing.JComponent.print(java.awt.Graphics)
- javax.swing.JComponent.printAll(java.awt.Graphics)
- javax.swing.JComponent.putClientProperty(java.lang.Object,java.lang.Object)
- javax.swing.JComponent.registerKeyboardAction(java.awt.event.ActionListener,java.lang.String,javax.swing.KeyStroke,int)
- javax.swing.JComponent.registerKeyboardAction(java.awt.event.ActionListener,javax.swing.KeyStroke,int)
- javax.swing.JComponent.removeAncestorListener(javax.swing.event.AncestorListener)
- javax.swing.JComponent.removeVetoableChangeListener(java.beans.VetoableChangeListener)
- javax.swing.JComponent.repaint(java.awt.Rectangle)
- javax.swing.JComponent.repaint(long,int,int,int,int)
- javax.swing.JComponent.requestDefaultFocus()
- javax.swing.JComponent.requestFocus()
- javax.swing.JComponent.requestFocus(boolean)
- javax.swing.JComponent.requestFocusInWindow()
- javax.swing.JComponent.resetKeyboardActions()
- javax.swing.JComponent.reshape(int,int,int,int)
- javax.swing.JComponent.revalidate()
- javax.swing.JComponent.scrollRectToVisible(java.awt.Rectangle)
- javax.swing.JComponent.setActionMap(javax.swing.ActionMap)
- javax.swing.JComponent.setAlignmentX(float)
- javax.swing.JComponent.setAlignmentY(float)
- javax.swing.JComponent.setAutoscrolls(boolean)
- javax.swing.JComponent.setBackground(java.awt.Color)
- javax.swing.JComponent.setBorder(javax.swing.border.Border)
- javax.swing.JComponent.setComponentPopupMenu(javax.swing.JPopupMenu)
- javax.swing.JComponent.setDebugGraphicsOptions(int)
- javax.swing.JComponent.setDefaultLocale(java.util.Locale)
- javax.swing.JComponent.setDoubleBuffered(boolean)
- javax.swing.JComponent.setFocusTraversalKeys(int,java.util.Set)
- javax.swing.JComponent.setFont(java.awt.Font)
- javax.swing.JComponent.setForeground(java.awt.Color)
- javax.swing.JComponent.setInheritsPopupMenu(boolean)
- javax.swing.JComponent.setInputMap(int,javax.swing.InputMap)
- javax.swing.JComponent.setInputVerifier(javax.swing.InputVerifier)
- javax.swing.JComponent.setMaximumSize(java.awt.Dimension)
- javax.swing.JComponent.setMinimumSize(java.awt.Dimension)
- javax.swing.JComponent.setNextFocusableComponent(java.awt.Component)
- javax.swing.JComponent.setOpaque(boolean)
- javax.swing.JComponent.setPreferredSize(java.awt.Dimension)
- javax.swing.JComponent.setRequestFocusEnabled(boolean)
- javax.swing.JComponent.setToolTipText(java.lang.String)
- javax.swing.JComponent.setTransferHandler(javax.swing.TransferHandler)
- javax.swing.JComponent.setVerifyInputWhenFocusTarget(boolean)
- javax.swing.JComponent.setVisible(boolean)
- javax.swing.JComponent.unregisterKeyboardAction(javax.swing.KeyStroke)
- javax.swing.JComponent.update(java.awt.Graphics)
- javax.swing.JMenu.add(java.awt.Component)
- javax.swing.JMenu.add(java.awt.Component,int)
- javax.swing.JMenu.add(java.lang.String)
- javax.swing.JMenu.add(javax.swing.Action)
- javax.swing.JMenu.add(javax.swing.JMenuItem)
- javax.swing.JMenu.addMenuListener(javax.swing.event.MenuListener)
- javax.swing.JMenu.addSeparator()
- javax.swing.JMenu.applyComponentOrientation(java.awt.ComponentOrientation)
- javax.swing.JMenu.doClick(int)
- javax.swing.JMenu.getAccessibleContext()
- javax.swing.JMenu.getComponent()
- javax.swing.JMenu.getDelay()
- javax.swing.JMenu.getItem(int)
- javax.swing.JMenu.getItemCount()
- javax.swing.JMenu.getMenuComponent(int)
- javax.swing.JMenu.getMenuComponentCount()
- javax.swing.JMenu.getMenuComponents()
- javax.swing.JMenu.getMenuListeners()
- javax.swing.JMenu.getPopupMenu()
- javax.swing.JMenu.getSubElements()
- javax.swing.JMenu.getUIClassID()
- javax.swing.JMenu.insert(java.lang.String,int)
- javax.swing.JMenu.insert(javax.swing.Action,int)
- javax.swing.JMenu.insert(javax.swing.JMenuItem,int)
- javax.swing.JMenu.insertSeparator(int)
- javax.swing.JMenu.isMenuComponent(java.awt.Component)
- javax.swing.JMenu.isPopupMenuVisible()
- javax.swing.JMenu.isSelected()
- javax.swing.JMenu.isTearOff()
- javax.swing.JMenu.isTopLevelMenu()
- javax.swing.JMenu.menuSelectionChanged(boolean)
- javax.swing.JMenu.remove(int)
- javax.swing.JMenu.remove(java.awt.Component)
- javax.swing.JMenu.remove(javax.swing.JMenuItem)
- javax.swing.JMenu.removeAll()
- javax.swing.JMenu.removeMenuListener(javax.swing.event.MenuListener)
- javax.swing.JMenu.setAccelerator(javax.swing.KeyStroke)
- javax.swing.JMenu.setComponentOrientation(java.awt.ComponentOrientation)
- javax.swing.JMenu.setDelay(int)
- javax.swing.JMenu.setMenuLocation(int,int)
- javax.swing.JMenu.setModel(javax.swing.ButtonModel)
- javax.swing.JMenu.setPopupMenuVisible(boolean)
- javax.swing.JMenu.setSelected(boolean)
- javax.swing.JMenu.updateUI()
- javax.swing.JMenuItem.addMenuDragMouseListener(javax.swing.event.MenuDragMouseListener)
- javax.swing.JMenuItem.addMenuKeyListener(javax.swing.event.MenuKeyListener)
- javax.swing.JMenuItem.getAccelerator()
- javax.swing.JMenuItem.getMenuDragMouseListeners()
- javax.swing.JMenuItem.getMenuKeyListeners()
- javax.swing.JMenuItem.isArmed()
- javax.swing.JMenuItem.processKeyEvent(java.awt.event.KeyEvent,javax.swing.MenuElement[],javax.swing.MenuSelectionManager)
- javax.swing.JMenuItem.processMenuDragMouseEvent(javax.swing.event.MenuDragMouseEvent)
- javax.swing.JMenuItem.processMenuKeyEvent(javax.swing.event.MenuKeyEvent)
- javax.swing.JMenuItem.processMouseEvent(java.awt.event.MouseEvent,javax.swing.MenuElement[],javax.swing.MenuSelectionManager)
- javax.swing.JMenuItem.removeMenuDragMouseListener(javax.swing.event.MenuDragMouseListener)
- javax.swing.JMenuItem.removeMenuKeyListener(javax.swing.event.MenuKeyListener)
- javax.swing.JMenuItem.setArmed(boolean)
- javax.swing.JMenuItem.setEnabled(boolean)
- javax.swing.JMenuItem.setUI(javax.swing.plaf.MenuItemUI)
最后,如果你知道某个类有更多的方法,请告诉我们。
关注CoolShell微信公众账号和微信小程序
(转载本站文章请注明作者和出处 酷 壳 – CoolShell ,请勿用于任何商业用途)
《OMG, Jave的JMenu居然有433个方法》的相关评论
Java的Swing类库,确实挺让人抓狂,不过确实是让新手学会查找API的好东西。
版主?请问本文中JS调用Java的是什么技术?可以在html里面这么写嘛?偶尔看到这篇文章,对其中的这段内容有兴趣,还望告知,谢谢。
java代码:Method[] methods = JMenu.class.getMethods;
int i = 0;
for(Method m: methods ){
System.out.println(m.toString()+i);
i++;
}
java反射
看来大家都对标题里的Jave熟视无睹了。