import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class ise extends Applet implements ActionListener{ TextField a=new TextField(5), b=new TextField(5), vastus=new TextField(5); Button b1=new Button(" = "); Label l=new Label("/",Label.CENTER); public void init(){ setCursor(new Cursor(Cursor.HAND_CURSOR)); setLayout(new GridLayout(1,5)); add(a); add(l); add(b); add(b1); add(vastus); b1.addActionListener(this); } public void actionPerformed(ActionEvent e){ System.out.println("Vajutati"); int nra=Integer.parseInt(a.getText().trim()); int nrb=Integer.parseInt(b.getText().trim()); Graphics g=getGraphics(); g.setColor(Color.white); g.fillRect(40, 40, 200, 50); g.setColor(Color.black); System.out.println("Vajutati"); if(nrb==0 ){g.drawString("Division by ZERO !!!",20 ,80);} else{ for(int i=2; i<=Math.min(nra, nrb); i++){ if(nra%i==0){ if(nrb%i==0){vastus.setText(nra/i+"/"+nrb/i);} else{ vastus.setText(nra+"/"+nrb);} } else{ vastus.setText(nra+"/"+nrb); } } } } }