import java.awt.*; import java.sql.*; import java.io.*; import java.applet.*; import java.awt.event.*; public class diagramm{ public static void main(String argumendid[]) throws Exception{ new raam(); BufferedReader sisse=new BufferedReader( new InputStreamReader(System.in) ); } } class raam extends Frame implements ItemListener{ Choice valik=new Choice(); public raam(){ setLayout(new FlowLayout()); setSize(500, 500); valik.add("aadressid"); valik.add("riigid"); valik.add("seosed"); valik.addItemListener(this); add(valik); setVisible(true); addWindowListener(new kuular()); } public void paint(Graphics p){ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:baas5", "", ""); Statement st=cn.createStatement(); if(valik.getSelectedItem().equals("aadressid")){ p.setColor(Color.blue); ResultSet aadr=st.executeQuery("SELECT count(*) as a FROM aadress"); aadr.next(); p.fillRect(250, 200, 100, aadr.getInt("a")*10); } if(valik.getSelectedItem().equals("riigid")){ p.setColor(Color.yellow); ResultSet riik=st.executeQuery("SELECT count(*) as r FROM riigid"); riik.next(); p.fillRect(250, 200, 100, riik.getInt("r")*10); } if(valik.getSelectedItem().equals("seosed")){ p.setColor(Color.black); ResultSet seos=st.executeQuery("SELECT count(*) as s FROM seosed"); seos.next(); p.fillRect(250, 200, 100, seos.getInt("s")*10); } } catch(Exception e) { System.out.println("Viga: "+e.getMessage()); e.printStackTrace(); } } public void itemStateChanged(ItemEvent e){ repaint(); } } class kuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(1); } }