import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
public class Main extends JFrame{
JLabel la=new JLabel("I Love Java");
JSlider slider=new JSlider(JSlider.HORIZONTAL,1,96,48);
public Main() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
slider.setPaintLabels(true);
slider.setPaintTicks(true);
slider.setPaintTrack(true);
slider.setMajorTickSpacing(20);
slider.setMinorTickSpacing(5);
slider.addChangeListener(new MychangeListener());
c.add(slider, BorderLayout.NORTH);
c.add(p, BorderLayout.CENTER);
p.add(la);
setSize(500,500);
setVisible(true);
}
class MychangeListener implements ChangeListener{
public void stateChanged(ChangeEvent e) {
la.setFont(new Font("Arial", Font.PLAIN, slider.getValue()/2));
//System.out.println(slider.getValue());
}
}
public static void main(String[] args) {
new Main();
}
}*/
/*
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
class Main extends JFrame{
Main(){
Container c = getContentPane();
c.add(new MyPanel());
setSize(500, 500);
setVisible(true);
}
class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLUE);
g.drawRect(10, 10, 50, 50); // 사각형
g.setColor(Color.red);
String str = "Hello";
g.setFont(new Font("Arial",Font.PLAIN,50));
g.drawString(str, 80, 80); // 글자
g.setColor(Color.green);
g.fillOval(150, 150, 100, 100); // 동그라미
g.fillRoundRect(200 , 300, 100, 100, 30, 60);
g.setColor(Color.black);
g.drawLine(20, 20, 100, 300);
}
}
public static void main(String[] args) {
new Main();
}
}*/
/*
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
public class Main extends JFrame{
Main(){
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.add(new MyPanel());
setSize(500,500);
setVisible(true);
}
class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.magenta);
g.fillRect(5, 5, 50, 50);
g.setColor(Color.DARK_GRAY);
g.drawRect(55, 55,50, 50);
g.fillOval(98, 98, 50, 50);
}
}
public static void main(String[] args) {
new Main();
}
}*/
/*
import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
public class Main extends JFrame{
Main(){
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.add(new MyPanel());
setSize(1000,1000);
setVisible(true);
}
class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("자바는 얼마나 재밌나?", 30, 30);
g.drawString("얼마나? 하늘만큼 땅만큼", 60, 60);
}
}
public static void main(String[] args) {
new Main();
}
}*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
private MyPanel panel = new MyPanel();
Main(){
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.add(new MyPanel());
setSize(520,560);
setVisible(true);
}
class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.drawString("I Love Java", 30, 30);
g.setColor(Color.green);
g.setFont(new Font("영주풍기인삼체 TTF", Font.ITALIC, 30));
g.drawString("How much", 30, 60);
g.setColor(new Color(0x00ff00ff));
for(int i=1;i<=5;i++) {
g.setFont(new Font("Arial", Font.ITALIC, i*10));
g.drawString("This much!!", 30, 60+i*60);
}
}
}
public static void main(String[] args) {
new Main();
}
}*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
private MyPanel panel=new MyPanel();
public Main() {
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.add(new MyPanel());
setSize(500,500);
setVisible(true);
}
class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.drawLine(0,0, 500, 500);
g.setColor(Color.black);
g.drawLine(500, 500, 10, 10);
}
}
public static void main(String[] args) {
new Main();
}
}*/
/*
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
Main(){
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.add(new MyPanel());
setSize(500,500);
setVisible(true);
}
class MyPanel extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.black);
g.fillRect(0, 0, 30, 30);
g.setColor(Color.red);
g.fillRect(30, 30, 50, 50);
g.setColor(Color.red);
g.fillArc(55, 55, 50, 50, 180, 270);
g.setColor(Color.blue);
int []x= {100,100,30,60};
int[]y= {259,275,307,277};
g.fillPolygon(x,y,4);
}
}
public static void main(String[] args) {
new Main();
}
}*/
//#1
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame{
Main(){
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
c.add(new MyPanel());
setSize(500,500);
setVisible(true);
}
class MyPanel extends JPanel{
}
}