package kurki; import java.awt.*; import java.awt.event.*; import borland.jbcl.control.*; import borland.jbcl.layout.*; import borland.jbcl.dataset.*; public class cKurki extends DecoratedFrame { BorderLayout borderLayout1 = new BorderLayout(); XYLayout xYLayout2 = new XYLayout(); BevelPanel bevelPanel1 = new BevelPanel(); NavigatorControl navigatorControl1 = new NavigatorControl(); TextDataFile textDataFile1 = new TextDataFile(); TableDataSet tableDataSet1 = new TableDataSet(); Button buttonSave = new Button(); GridControl gridControl1 = new GridControl(); LocatorControl locatorControl1 = new LocatorControl(); StatusBar statusBar1 = new StatusBar(); //Construct the frame public cKurki() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } //Component initialization public void jbInit() throws Exception{ this.setLayout(borderLayout1); this.setSize(new Dimension(400, 348)); this.setTitle("Kurki for Java"); navigatorControl1.setDataSet(tableDataSet1); textDataFile1.setDelimiter(""); textDataFile1.setFileName("E:\\KURSSIT\\WINOHJ\\JAVA\\kurki\\C.dat"); textDataFile1.setSeparator("|"); tableDataSet1.setSort(new borland.jbcl.dataset.SortDescriptor(new String[] {"nimi"}, true, false)); tableDataSet1.setTableName(""); tableDataSet1.setDataFile(textDataFile1); tableDataSet1.setSchemaName(""); buttonSave.setLabel("Save"); gridControl1.setDataSet(tableDataSet1); locatorControl1.setColumnName(""); locatorControl1.setColumns(1); locatorControl1.setDataSet(tableDataSet1); statusBar1.setDataSet(tableDataSet1); buttonSave.addActionListener(new cKurki_buttonSave_actionAdapter(this)); bevelPanel1.setLayout(xYLayout2); this.add(bevelPanel1, BorderLayout.WEST); bevelPanel1.add(gridControl1, new XYConstraints(4, 47, 342, 180)); bevelPanel1.add(buttonSave, new XYConstraints(307, 230, 67, 45)); bevelPanel1.add(navigatorControl1, new XYConstraints(2, 229, 380, 46)); bevelPanel1.add(locatorControl1, new XYConstraints(4, 14, 342, 28)); bevelPanel1.add(statusBar1, new XYConstraints(3, 276, 375, 38)); } void buttonSave_actionPerformed(ActionEvent e) { try { tableDataSet1.getDataFile().save(tableDataSet1); System.out.println("Changes saved"); } catch (Exception ex) { System.out.println("Changes NOT saved"); System.err.println("Exception: " + ex); } } } class cKurki_buttonSave_actionAdapter implements java.awt.event.ActionListener { cKurki adaptee; cKurki_buttonSave_actionAdapter(cKurki adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.buttonSave_actionPerformed(e); } }