forked from Kotlin-Polytech/FromKotlinToJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainFrame.java
More file actions
40 lines (35 loc) · 970 Bytes
/
Copy pathMainFrame.java
File metadata and controls
40 lines (35 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package part3.simple.panel;
import javax.swing.*;
import java.awt.*;
/**
*
* @author Digitek
*/
public class MainFrame extends JFrame {
private MainFrame(String s) {
super(s);
setSize(600, 400);
JPanel panel = new MainPanel();
setContentPane(panel);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
@Override
public void paint(Graphics g) {
super.paint(g);
// It's better to draw on panel, not here
g.setColor(Color.BLACK);
g.drawLine(0, 0, getWidth() - 1, getHeight() - 1);
g.drawLine(getWidth() - 1, 0, 0, getHeight() - 1);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new MainFrame("Swing frame with panel"));
}
}