2024-03-30
This commit is contained in:
99
doc/02_basic_component_methods.md
Normal file
99
doc/02_basic_component_methods.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# 컴포넌트 공통 사항
|
||||
|
||||
## 스타일
|
||||
* `getBorder()` / `setBorder(Border)`
|
||||
* `getForeground()` / `setForeground(Color)`
|
||||
* `getBackground()` / `setBackground(Color)`
|
||||
* `isOpaque()` / `setOpague(boolean)`
|
||||
* `getFont()` / `setFont(Font)`
|
||||
* `getCursor()` / `setCursor(Cursor)`
|
||||
|
||||
```java
|
||||
myComponent.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
myComponent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
myComponent.setBackground(Color.PINK);
|
||||
```
|
||||
|
||||
## 상태
|
||||
* `isEnabled()` / `setEnabled(boolean)`
|
||||
* `isVisible()` / `setVisible(boolean)`
|
||||
* `isShowing()`
|
||||
* `getName()` / `setName(String)` : 컴포넌트에 관리용 이름을 붙일 때 사용할 수 있다.
|
||||
* `setTooltipText()`
|
||||
* `getTransferHandler()` / `setTransferHandlerTransferHandler()` : 드래그&드롭에서 사용한다.
|
||||
* `setComponentPopupMenu(JPopupMenu)`
|
||||
|
||||
## 리스너
|
||||
* `addXXXListener()` / `removeXXXListener()`
|
||||
* HierarchyListener
|
||||
* MouseListener
|
||||
* MouseMotionListener
|
||||
* KeyListener
|
||||
* ComponentListener
|
||||
|
||||
## 컴포넌트
|
||||
* `add(Component)` / `add(Component,int)` / `add(Component,Object)`
|
||||
* `remove(int)` / `remove(Component)` / `removeAll()`
|
||||
* `contains(int,int)` / `contains(Point)` : 주어진 좌표가 컴포넌트 내부인가?
|
||||
* `getComponentAt(int,int)` / `getComponentAt(Point)`
|
||||
* `getComponentZOrder(Component)` / `setComponentZOrder(Component,int)`
|
||||
* `getComponentZOrder(int)` / `getComponentZOrder()`
|
||||
* `getRootPane()` / `getTopLevelAnscestor()` / `getParent()`
|
||||
* `getComponentCount()`
|
||||
* `getComponent(int)` / `getComponents()`
|
||||
|
||||
## 레이아웃
|
||||
* `getLayout()` / `setLayout(LayoutManager)`
|
||||
* `getPreferredSize()` / `setPreferredSize(Dimension)`
|
||||
* `getMaximumSize()` / `setMaximumSize(Dimension)`
|
||||
* `getMinimumSize()` / `setMinimumSize(Dimension)`
|
||||
* `getAlignmentX()` / `setAlignmentX(float)`
|
||||
* `getAlignmentY()` / `setAlignmentY(float)`
|
||||
* `applyComponentOrientation(ComponentOrientation)` / `setComponentOrientation(ComponentOrientation)`
|
||||
|
||||
## 위치와 크기
|
||||
* `getX()` / `getY()`
|
||||
* `getWidth()` / `getHeight()`
|
||||
* `getSize()` / `setSize(Dimension)`
|
||||
* `getBounds()` / `setBounds(Rectangle)`
|
||||
* `getLocation()` / `setLocation(Point)`
|
||||
* `getLocationOnScreen()`
|
||||
* `getInsets()` / `setInsets(Inset)`
|
||||
|
||||
## 패인팅
|
||||
* `repaint()` / `repaint(int,int,int,int)` / `repaint(Rectangle)`
|
||||
* `revalidate()`
|
||||
* `paintComponent(Graphics)` : 이 메서드를 오버라이드해서 커스텀 컴포넌트를 만든다.
|
||||
|
||||
|
||||
## Focus
|
||||
|
||||
* `isFocusOwner()`
|
||||
* `isRequestFocusEnabled()` / `setRequestFocusEnabled(boolean)`
|
||||
* `isFocusable()` / `setFocusable(boolean)`
|
||||
* `requestFocusInWindow()`
|
||||
* `getFocusTraversalKeys(int)` / `setFocusTraversalKeys(int,Set)` / `areFocusTraversalKeysSet(int)`
|
||||
|
||||
|
||||
### LayoutFocusTraversalPolicy
|
||||
|
||||
* `getComponentAfter(Container,Component)`
|
||||
* `getComponentBefore(Container,Component)`
|
||||
* `getFirstComponent(Container)` / `getInitialComponent(Container)` / `getLastComponent(Container)`
|
||||
|
||||
|
||||
* `container.getFocusTraversalPolicy()` / `container.setFocusTraversalPolicy(FocusTraversalPolicy)`
|
||||
* `container.isFocusCycleRoot()` / `container.setFocusCycleRoot(boolean)`
|
||||
* `container.isFocusTraversalPolicyProvider()` / `container.setFocusTraversalPolicyProvider(boolean)`
|
||||
|
||||
|
||||
## InputMap
|
||||
|
||||
* `component.getInputMap()` / `component.getInputMap(int)` : JComponent.WHEN_FOCUSED | WHEN_IN_FOCUSED_WINDOW | WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
|
||||
* `put(KeyStroke,Object)` : 키 스트록, 액션명. 키와 이름을 연결시킨다.
|
||||
* `KeyStroke.getKeyStroke(String)`
|
||||
|
||||
## ActionMap
|
||||
|
||||
* `component.getActionMap()`
|
||||
* `put(Object,Action)` : 이름과 액션을 연결시킨다.
|
||||
Reference in New Issue
Block a user