※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

Swing JComponent

中間コンテナとアトミックコンポーネントの総称

1.機能
  • Tool tips
  • Painting and borders
  • Application-wide pluggable look and feel
  • Custom properties
  • Support for layout
  • Support for accessibility
  • Support for drag and drop
  • Double buffering
  • Key bidings

2.API
2.1 Customizing Component Appearance
  • void setBorder(Border)
  • Border getBorder()

  • void setForeground(Color)
  • void setBackground(Color)

  • Color getForeground()
  • Color getBackground()

  • void setOpaque(boolean)
  • boolean isOpaque()

  • void setFont(Font)
  • Font getFont()

  • void setCursor(Cursor)
  • Cursor getCursor()

2.2 Setting and Getting Component State
  • void setComponentPopupMenu(JPopupMenu)

  • void setTransferHandler(TransferHandler)
  • TransferHandler getTransferHandler()

  • void setToolTipText(String)

  • void setName(String)
  • String getName()

  • boolean isShowing()

  • void setEnabled(boolean)
  • boolean isEnabled()

  • void setVisible(boolean)
  • boolean isVisible()

2.3 Handling Events (see Writing Event Listeners for details)
  • void addHierarchyListener(hierarchyListener l)
  • void removeHierarchyListener(hierarchyListener l)

  • void addMouseListener(MouseListener)
  • void removeMouseListener(MouseListener)

  • void addMouseMotionListener(MouseMotionListener)
  • void removeMouseMotionListener(MouseMotionListener)

  • void addKeyListener(KeyListener)
  • void removeKeyListener(KeyListener)

  • void addComponentListener(ComponentListener)
  • void removeComponentListener(ComponentListener)

  • boolean contains(int, int)
  • boolean contains(Point)

  • Component getComponentAt(int, int)
  • Component getComponentAt(Point)

  • Component setComponentZOrder(component comp, int index)

  • Component getComponentZOrder(component comp)

2.4 Painting Components (see Performing Custom Painting for details)
  • void repaint()
  • void repaint(int, int, int, int)

  • void repaint(Rectangle)

  • void revalidate()

  • void paintComponent(Graphics)

2.5 Dealing with the Containment Hierarchy (see Using Top-Level Containers for more information)
  • Component add(Component)
  • Component add(Component, int)
  • void add(Component, Object)

  • void remove(int)
  • void remove(Component)
  • void removeAll()

  • JRootPane getRootPane()

  • Container getTopLevelAncestor()

  • Container getParent()

  • int getComponentCount()

  • Component getComponent(int)
  • Component[] getComponents()

  • Component getComponentZOrder(int)
  • Component[] getComponentZOrder()

2.6 Laying Out Components (see Laying Out Components Within a Container for more information)
  • void setPreferredSize(Dimension)
  • void setMaximumSize(Dimension)
  • void setMinimumSize(Dimension)

  • Dimension getPreferredSize()
  • Dimension getMaximumSize()
  • Dimension getMinimumSize()

  • void setAlignmentX(float)
  • void setAlignmentY(float)

  • float getAlignmentX()
  • float getAlignmentY()

  • void setLayout(LayoutManager)
  • LayoutManager getLayout()

  • void applyComponentOrientation(ComponentOrientation) void -setComponentOrientation(ComponentOrientation)

2.7 Getting Size and Position Information
  • int getWidth()
  • int getHeight()

  • Dimension getSize()
  • Dimension getSize(Dimension)

  • int getX()
  • int getY()

  • Rectangle getBounds()
  • Rectangle getBounds(Rectangle)

  • Point getLocation()
  • Point getLocation(Point)

  • Point getLocationOnScreen()

  • Insets getInsets()

2.8 Specifying Absolute Size and Position (see Doing Without a Layout Manager (Absolute Positioning) for more information)
  • void setLocation(int, int)
  • void setLocation(Point)

  • void setSize(int, int)
  • void setSize(Dimension)

  • void setBounds(int, int, int, int)
  • void setBounds(Rectangle)