package 서준혁1;
/*
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main extends JFrame
{
int g;
String s = "Love Java";
JLabel l=new JLabel(s);
Main()
{
setTitle("+,-키로 폰트 크기 조절");
Container c=getContentPane();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.setLayout(new FlowLayout());
c.add(l);
l.setLayout(null);
c.addKeyListener(new MyKeyListener());
c.setFocusable(true);
c.requestFocus();
l.setOpaque(true);
l.setFont(new Font("Arial",Font.PLAIN,50));
setSize(500,200);
setVisible(true);
}
class MyKeyListener extends KeyAdapter{
public void keyPressed(KeyEvent e) {
int KeyCode=e.getKeyCode();
Font f=l.getFont();
int size=f.getSize();
if(e.getKeyCode()==KeyEvent.VK_PLUS)
{
l.setFont(new Font("Arial",Font.PLAIN,size+5));
}
else if(e.getKeyCode()==KeyEvent.VK_MINUS)
{
l.setFont(new Font("Arial",Font.PLAIN,size-5));
}
}
}
public static void main(String[] args) {
new Main();
}
}
/import javax.swing.;
import java.awt.*;
import java.awt.event.*;
class String
{
String c[]=new String["String"];
String()
{
}
public String substring(int a,int b)
{
return c[b];
}
public String substring(int a)
{
}
}
public class Main extends JFrame
{
int i=0;
JLabel l=new JLabel("Love Java");
Main()
{
setTitle("LEFT 키로 문자열 이동");
Container c=getContentPane();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.setLayout(new FlowLayout());
c.add(l);
l.setLayout(null);
c.addKeyListener(new MyKeyListener());
c.setFocusable(true);
c.requestFocus();
String text=new String();
l.setOpaque(true);
l.setFont(new Font("Arial",Font.PLAIN,25));
setSize(500,200);
setVisible(true);
}
class MyKeyListener extends KeyAdapter{
public void keyPressed(KeyEvent e) {
int KeyCode=e.getKeyCode();
if(e.getKeyCode()==KeyEvent.VK_LEFT)
{
i++;
l.setText(text.s);
}
}
}
public static void main(String[] args) {
new Main();
}
}