The AS400JDBCDataSourcePane class presents the property values of an AS400JDBCDataSource object. Optionally, changes can be made to the AS400JDBCDataSource object.
AS400JDBCDataSourcePane extends JComponent. To use an AS400JDBCDataSourcePane to display the properties of a data source, the data source can either be specified on the AS400JDBCDataSourcePane constructor or set after the AS400JDBCDataSourcePane has been created using setDataSource(). Changes made to the graphical user interface (GUI) can be applied to the data source object using applyChanges().
The following example creates an AS400JDBCDataSourcePane and an OK button and adds them to a frame. Changes made to the GUI are applied to the data source when you click OK.
// Create a data source. myDataSource = new AS400JDBCDataSource(); // Create a window to hold the pane and an OK button. JFrame frame = new JFrame ("JDBC Data Source Properties"); // Create a data source pane. dataSourcePane = new AS400JDBCDataSourcePane(myDataSource); // Create an OK button JButton okButton = new JButton("OK"); // Add an ActionListener to the OK button. When OK is // pressed, applyChanges() will be called to commit any // changes to the data source. okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { // Apply all changes made on the data source pane // to the data source. If all changes are applied // successfully, get the data source from the pane. if (dataSourcePane.applyChanges()) { System.out.println("ok pressed"); myDataSource = dataSourcePane.getDataSource(); System.out.println(myDataSource.getServerName()); } } } ); // Setup the frame to show the pane and OK button. frame.getContentPane ().setLayout (new BorderLayout ()); frame.getContentPane ().add ("Center", dataSourcePane); frame.getContentPane ().add ("South", okButton); // Pack the frame. frame.pack (); //Display the pane and OK button. frame.show ();