import javax.swing.*; import java.awt.*; public class OntoApp extends JApplet{ boolean isStandalone=false; OntoData od=new OntoData(); OntoPanel op=new OntoPanel(); OntoListener ol=new OntoListener(); OntoTableModel ot=new OntoTableModel(); OntoSliders os=new OntoSliders(this); OntoDataFrame odf; JButton b1=new JButton("RandomIterate"); JTextField btf1=new JTextField("1"); JButton b2=new JButton("RandomCoordinates"); JToggleButton b3=new JToggleButton("Continous calculating"); JButton b4=new JButton("Dataframe"); Choice fileChoice=new Choice(); JTable table; JScrollPane tablePanel; public OntoApp(){ this(false); } public OntoApp(boolean standalone){ this.isStandalone=standalone; getContentPane().setLayout(new BorderLayout()); odf=new OntoDataFrame(this); JPanel buttonPanel=new JPanel(new GridLayout()); if(isStandalone){od.readDataFromFile("Creatures2.txt");} else{od.readSampleData();} od.normalizeData(); od.randomCoordinates(); op.od=od; ol.oa=this; ot.oa=this; os.initialize(); getContentPane().add(buttonPanel, BorderLayout.NORTH); getContentPane().add(op, BorderLayout.CENTER); buttonPanel.add(b1); buttonPanel.add(btf1); buttonPanel.add(b2); buttonPanel.add(b3); buttonPanel.add(b4); buttonPanel.add(fileChoice); b1.addActionListener(ol); b2.addActionListener(ol); b3.addActionListener(ol); b4.addActionListener(ol); fileChoice.addItemListener(ol); op.addMouseListener(ol); op.addMouseMotionListener(ol); addTable(); os.setSize(100, 100); getContentPane().add(new JScrollPane(os, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.WEST); } public void init(){ ol.filenamesToChoice(); } void addTable(){ if(tablePanel!=null){getContentPane().remove(tablePanel);} table=new JTable(ot); tablePanel=new JScrollPane(table); tablePanel.setPreferredSize(new Dimension(200, 150)); getContentPane().add(tablePanel, BorderLayout.SOUTH); validate(); } public static void main(String[] arg){ JFrame f=new JFrame("OntoApp"); OntoApp oa=new OntoApp(true); oa.init(); f.getContentPane().add(oa); f.setSize(700, 600); f.setVisible(true); } }