58 lines
1.9 KiB
Markdown
58 lines
1.9 KiB
Markdown
# 최상위 컨데이너
|
|
JFrame, JDialog, JApplet 등이 최상위 컨테이너이며, 프로그램 창(윈도우)이라고도 이해할 수 있다.
|
|
최상위 컨테이너는 시각적 컴포넌트를 위한 영역인 content pane을 가지고 있다.
|
|
|
|
## JFrame
|
|
|
|
* `getDefaultCloseOperation()` / `setDefaultCloseOperation(int)` : DO_NOTHING_ON_CLOSE | HIDE_ON_CLOSE | DISPOSE_ON_CLOSE | EXIT_ON_CLOSE
|
|
* `getIconImage()` / `setIconImage(java.awt.Image)`
|
|
* `getTitle()` / `setTitle(String)`
|
|
* `isUndecorated()` / `setUndecorated(boolean)`
|
|
* `isDefaultLookAndFeelDecorated()` / `setDefaultLookAndFeelDecorated(boolean)`
|
|
|
|
* `getSize()` / `setSize(int,int)` / `setSize(Dimension)`
|
|
* `getBounds()` / `setBounds(int,int,int,int)` / `setBounds(Rectangle)` : x, y, width, height
|
|
* `getLocation()` / `setLocation(int,int)` / `setLocationRelativeTo(Component)`
|
|
* `pack()`
|
|
|
|
* `getContentPane()` / `setContentPnae(Container)`
|
|
* `getRootPane()` / `setRootPane(JRootPane)` / `createRootPane()`
|
|
* `getJMenuBar()` / `setJMenuBar(JMenuBar)`
|
|
* `getGlassPane()` / `setGlassPane(Component)`
|
|
* `getLayeredPane()` / `setLayeredPane(JLayeredPane)`
|
|
|
|
|
|
```java
|
|
public static void main(String... args) {
|
|
// 컨텐트 패널에 버튼 등의 컴포넌트를 구성한다.
|
|
final JPanel contentPane = new JPanel();
|
|
contentPane.setBackground(Color.PINK);
|
|
|
|
// 프레임을 생성한다.
|
|
final JFrame jFrame = new JFrame();
|
|
jFrame.setTitle("Example");
|
|
jFrame.setSize(800, 600);
|
|
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
jFrame.setContentPane(contentPane);
|
|
|
|
// 이벤트 디스패치 스레드에서 프레임을 표시한다.
|
|
SwingUtilities.invokeLater(() -> {
|
|
jFrame.setVisible(true);
|
|
});
|
|
}
|
|
```
|
|
|
|
## JDialog
|
|
|
|
|
|
|
|
## Full-screen Exclusive mode
|
|
|
|
```java
|
|
if(graphicsDevice.isFullScreenSupported()){
|
|
graphicsDevice.setFullScreenWindow(jFrame);
|
|
// graphicsDevice.setFullScreenWindow(null); //null to exit
|
|
}
|
|
```
|
|
### DisplayMode
|