среда, 29 июля 2015 г.

Helloworld in Java Graphics2D

For this need to make 2 classes with names Painting and Frame. In my situation I have package named graphh
Painting.class:
package graphh;
import java.awt.*;
import javax.swing.*;
public class Painting extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawOval(60, 80, 20, 20);
}
}

Frame.class:
package graphh;
import java.awt.*;
import javax.swing.*;
public class Frame {
public Frame() {
JFrame gui = new JFrame();
gui.setTitle("fsdfdsf");
gui.setSize(400, 300);
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Painting panel = new Painting();
Container pane = gui.getContentPane();
pane.setLayout(new GridLayout(1, 1));
pane.add(panel);
gui.setVisible(true);
}
public static void main(String args[]) {
new Frame();
}
}

If you are using Eclipse just press Run button
Taken from https://www.youtube.com/watch?v=U2G_2AS0otE

Комментариев нет:

Отправить комментарий