//javac -encoding Unicode guie5_2.java //appletviewer -encoding Unicode guie5_2.html import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class guie5_2 extends Applet implements ActionListener, ItemListener { int n = 50; String X = "", Y = ""; int y = 70; Font font; Font font_30; int i; int strlen; int flen; int fn; Choice choicebtn; st stri = new st(); Button clear; Button space, comma, period; Button butto_1[] = new Button[40]; public void init() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String Fonts[] = {"Batang","BatangChe","Gulim","GulimChe","Gungsuh","GungsuhChe","Dotum","DotumChe"}; flen = Fonts.length; choicebtn = new Choice(); for(i = 0; i < Fonts.length; i++) { choicebtn.addItem(Fonts[i]); } font = new Font(Fonts[0], Font.PLAIN, 12); clear = new Button(); clear.setFont( font ); space = new Button(); space.setFont( font ); comma = new Button(); comma.setFont( font ); period = new Button(); period.setFont( font ); int st_12 = stri.st_1.length()+stri.st_2.length(); font_30 = new Font(Fonts[0], Font.PLAIN, 30); for( int i = 0; i < 26; i++ ) { butto_1[i] = new Button(); butto_1[i].setFont( font_30 ); //butto_2[i] = new Button(); //butto_2[i].setFont( font_30 ); //butto_3[i] = new Button(); //butto_3[i].setFont( font_30 ); } add(clear); clear.addActionListener( this ); add(space); space.addActionListener( this ); add(comma); comma.addActionListener( this ); add(period); period.addActionListener( this ); for( int i = 0; i < 26; i++ ) { add( butto_1[i] ); butto_1[i].addActionListener( this ); } add(choicebtn); choicebtn.addItemListener( this ); } public void paint( Graphics g ) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String Fonts[] = {"Batang","BatangChe","Gulim","GulimChe","Gungsuh","GungsuhChe","Dotum","DotumChe"}; g.setFont(new Font(Fonts[fn], Font.PLAIN, 30)); g.drawString("" + X, 10, 300); g.drawString(Fonts[fn], 10, 350); clear.setBounds( 0, 0, 40, 22); space.setBounds(40, 0, 40, 22); comma.setBounds(80, 0, 40, 22); period.setBounds(120,0, 40, 22); Graphics gcl = clear.getGraphics(); gcl.drawString("명확한", 0, 12); Graphics gsp = space.getGraphics(); gsp.drawString("공간", 0, 12); Graphics gco = comma.getGraphics(); gco.drawString("호", 0, 12); Graphics gpe = period.getGraphics(); gpe.drawString("기간", 0, 12); //int st_12 = stri.st_1.length()+stri.st_2.length(); Graphics gst_1[] = new Graphics[26]; butto_1[ 0].setBounds( 45, 0+y, 40, 40); butto_1[ 1].setBounds( 90, 0+y, 40, 40); butto_1[ 2].setBounds( 135, 0+y, 40, 40); butto_1[ 3].setBounds( 180, 0+y, 40, 40); butto_1[ 4].setBounds( 225, 0+y, 40, 40); butto_1[ 5].setBounds( 270, 0+y, 40, 40); butto_1[ 6].setBounds( 315, 0+y, 40, 40); butto_1[ 7].setBounds( 360, 0+y, 40, 40); butto_1[ 8].setBounds( 405, 0+y, 40, 40); butto_1[ 9].setBounds( 450, 0+y, 40, 40); // butto_1[10].setBounds( 45+22, 45+y, 40, 40); butto_1[11].setBounds( 90+22, 45+y, 40, 40); butto_1[12].setBounds( 135+22, 45+y, 40, 40); butto_1[13].setBounds( 180+22, 45+y, 40, 40); butto_1[14].setBounds( 225+22, 45+y, 40, 40); butto_1[15].setBounds( 270+22, 45+y, 40, 40); butto_1[16].setBounds( 315+22, 45+y, 40, 40); butto_1[17].setBounds( 360+22, 45+y, 40, 40); butto_1[18].setBounds( 405+22, 45+y, 40, 40); // butto_1[19].setBounds( 90+22, 90+y, 40, 40); butto_1[20].setBounds( 135+22, 90+y, 40, 40); butto_1[21].setBounds( 180+22, 90+y, 40, 40); butto_1[22].setBounds( 225+22, 90+y, 40, 40); butto_1[23].setBounds( 270+22, 90+y, 40, 40); butto_1[24].setBounds( 315+22, 90+y, 40, 40); butto_1[25].setBounds( 360+22, 90+y, 40, 40); for(int i = 0; i < 26; i++ ) { gst_1[i] = butto_1[i].getGraphics(); } gst_1[ 0].drawString( stri.st_1.substring(5,5+1), 4, 30); gst_1[ 1].drawString( stri.st_1.substring(8,8+1), 4, 30); gst_1[ 2].drawString( stri.st_1.substring(2,2+1), 4, 30); gst_1[ 3].drawString( stri.st_1.substring(0,0+1), 4, 30); gst_1[ 4].drawString( stri.st_1.substring(6,6+1), 4, 30); gst_1[ 5].drawString( stri.st_2.substring(5,5+1), -25, 30); gst_1[ 6].drawString( stri.st_2.substring(3,3+1), -25, 30); gst_1[ 7].drawString( stri.st_2.substring(1,1+1), -25, 30); gst_1[ 8].drawString( stri.st_2.substring(10,10+1), -25, 30); gst_1[ 9].drawString( stri.st_2.substring(12,12+1), -25, 30); gst_1[10].drawString( stri.st_1.substring(4,4+1), 4, 30); gst_1[11].drawString( stri.st_1.substring(1,1+1), 4, 30); gst_1[12].drawString( stri.st_1.substring(7,7+1), 4, 30); gst_1[13].drawString( stri.st_1.substring(3,3+1), 4, 30); gst_1[14].drawString( stri.st_1.substring(13,13+1), 4, 30); gst_1[15].drawString( stri.st_2.substring(4,4+1), -25, 30); gst_1[16].drawString( stri.st_2.substring(2,2+1), -25, 30); gst_1[17].drawString( stri.st_2.substring(0,0+1), -25, 30); gst_1[18].drawString( stri.st_2.substring(9,9+1), -25, 30); gst_1[19].drawString( stri.st_1.substring(10,10+1), 4, 30); gst_1[20].drawString( stri.st_1.substring(11,11+1), 4, 30); gst_1[21].drawString( stri.st_1.substring(9,9+1), 4, 30); gst_1[22].drawString( stri.st_1.substring(12,12+1), 4, 30); gst_1[23].drawString( stri.st_2.substring(7,7+1), -25, 30); gst_1[24].drawString( stri.st_2.substring(6,6+1), -25, 30); gst_1[25].drawString( stri.st_2.substring(8,8+1), -25, 30); choicebtn.setBounds( 400, 600, 100, 30 ); } public void actionPerformed(ActionEvent event) { if (event.getSource() == clear ) { X = ""; repaint(); } else if (event.getSource() == space ) { X = X + " "; repaint(); } else if (event.getSource() == comma ) { X = X + ","; repaint(); } else if (event.getSource() == period) { X = X + "."; repaint(); } else { if (event.getSource() == butto_1[ 0]) { X = X + stri.st_1.substring(5,5+1); repaint(); } if (event.getSource() == butto_1[ 1]) { X = X + stri.st_1.substring(8,8+1); repaint(); } if (event.getSource() == butto_1[ 2]) { X = X + stri.st_1.substring(2,2+1); repaint(); } if (event.getSource() == butto_1[ 3]) { X = X + stri.st_1.substring(0,0+1); repaint(); } if (event.getSource() == butto_1[ 4]) { X = X + stri.st_1.substring(6,6+1); repaint(); } if (event.getSource() == butto_1[ 5]) { X = X + stri.st_2.substring(5,5+1); repaint(); } if (event.getSource() == butto_1[ 6]) { X = X + stri.st_2.substring(3,3+1); repaint(); } if (event.getSource() == butto_1[ 7]) { X = X + stri.st_2.substring(1,1+1); repaint(); } if (event.getSource() == butto_1[ 8]) { X = X + stri.st_2.substring(10,10+1); repaint(); } if (event.getSource() == butto_1[ 9]) { X = X + stri.st_2.substring(12,12+1); repaint(); } if (event.getSource() == butto_1[10]) { X = X + stri.st_1.substring(4,4+1); repaint(); } if (event.getSource() == butto_1[11]) { X = X + stri.st_1.substring(1,1+1); repaint(); } if (event.getSource() == butto_1[12]) { X = X + stri.st_1.substring(7,7+1); repaint(); } if (event.getSource() == butto_1[13]) { X = X + stri.st_1.substring(3,3+1); repaint(); } if (event.getSource() == butto_1[14]) { X = X + stri.st_1.substring(13,13+1); repaint(); } if (event.getSource() == butto_1[15]) { X = X + stri.st_2.substring(4,4+1); repaint(); } if (event.getSource() == butto_1[16]) { X = X + stri.st_2.substring(2,2+1); repaint(); } if (event.getSource() == butto_1[17]) { X = X + stri.st_2.substring(0,0+1); repaint(); } if (event.getSource() == butto_1[18]) { X = X + stri.st_2.substring(9,9+1); repaint(); } if (event.getSource() == butto_1[19]) { X = X + stri.st_1.substring(10,10+1); repaint(); } if (event.getSource() == butto_1[20]) { X = X + stri.st_1.substring(11,11+1); repaint(); } if (event.getSource() == butto_1[21]) { X = X + stri.st_1.substring(9,9+1); repaint(); } if (event.getSource() == butto_1[22]) { X = X + stri.st_1.substring(12,12+1); repaint(); } if (event.getSource() == butto_1[23]) { X = X + stri.st_2.substring(7,7+1); repaint(); } if (event.getSource() == butto_1[24]) { X = X + stri.st_2.substring(6,6+1); repaint(); } if (event.getSource() == butto_1[25]) { X = X + stri.st_2.substring(8,8+1); repaint(); } } } public void itemStateChanged(ItemEvent ie) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String Fonts[] = {"Batang","BatangChe","Gulim","GulimChe","Gungsuh","GungsuhChe","Dotum","DotumChe"}; Choice c = (Choice)ie.getItemSelectable(); fn = c.getSelectedIndex(); font = new Font(Fonts[fn], Font.PLAIN, 20); repaint(); } }
戻る