import java.awt.*; import java.awt.event.*; import java.applet.Applet; import java.awt.image.*; import java.awt.geom.*; import java.util.StringTokenizer; import java.io.*; import java.awt.geom.AffineTransform; public class telekas extends Applet implements MouseListener, ItemListener{ int x=1; File kataloog=new File("."+File.separator+"pildid"); String[] failid=kataloog.list(); Image pilt1=Toolkit.getDefaultToolkit().getImage(kataloog+File.separator+failid[0]); Image pilt2=Toolkit.getDefaultToolkit().getImage(kataloog+File.separator+failid[1]); Image pilt3=Toolkit.getDefaultToolkit().getImage(kataloog+File.separator+failid[2]); Image pilt4=Toolkit.getDefaultToolkit().getImage(kataloog+File.separator+failid[3]); Choice valik=new Choice(); public telekas(){ valik.add("ETV"); valik.add("TV1"); valik.add("Kanal 2"); valik.add("TV3"); valik.add("Power off"); add(valik); valik.addItemListener(this); addMouseListener(this); } public void paint(Graphics g){ g.fillRect(100, 100, 360 , 300); g.drawRoundRect(109, 109, 332 , 262, 20, 20); g.setColor(Color.red); g.fillOval(120, 380, 8, 8); g.fillOval(140, 382, 6, 6); g.setColor(Color.green); g.fillOval(160, 382, 6, 6); if (x==1){ g.setColor(Color.yellow); g.fillRoundRect(115, 110, 330 , 260, 20, 20); g.drawImage(pilt1, 115, 110,this); valik.select("ETV"); g.setColor(Color.black); g.drawString("ETV" ,415, 125); } if (x==2){ g.setColor(Color.red); g.fillRoundRect(115, 110, 330 , 260, 20, 20); g.drawImage(pilt2, 115, 110,this); valik.select("TV1"); g.setColor(Color.black); g.drawString("TV1" ,415, 125); } if (x==3){ g.setColor(Color.blue); g.fillRoundRect(115, 110, 330 , 260, 20, 20); g.drawImage(pilt3, 115, 110,this); valik.select("Kanal 2"); g.setColor(Color.white); g.drawString("Kanal 2" ,400, 125); } if (x==4){ g.setColor(Color.green); g.fillRoundRect(115, 110, 330 , 260, 20, 20); g.drawImage(pilt4, 115, 110,this); valik.select("TV3"); g.setColor(Color.black); g.drawString("TV3" ,415, 125); } if (x==5){ g.setColor(Color.gray); g.fillRoundRect(115, 110, 330 , 260, 20, 20); } } public void mouseReleased(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mousePressed(MouseEvent e){ if (x==5){ x=0; } if (x==4){ x=0; } x=x+1; repaint(); } public void itemStateChanged(ItemEvent f){ String s=valik.getSelectedItem(); if(s.equals("ETV"))x=1; if(s.equals("TV1"))x=2; if(s.equals("Kanal 2"))x=3; if(s.equals("TV3"))x=4; if(s.equals("Power off"))x=5; repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("Telekas"); f.add(new telekas()); f.setSize(800, 600); f.setVisible(true); } }