Use JVx Swing controls without JVx UI

Contains useful source code for specific use cases.

Use JVx Swing controls without JVx UI

Postby Development@SIB » Thu Jan 05, 2012 3:18 pm

JVx's Swing controls are independent of JVx UI. It is no problem to use a table that shows some database or in-memory records. It is also possible to use 3-tier or 2-tier architecture.

In-Memory data

Use JVxTable and integrate it in your Swing application. Use it like a standard JTable.

Code: Select all
public class JVxTableTest extends JFrame
   public static void main(String[] pArgs) throws Throwable
      new JVxTableTest();
   JVxTableTest() throws Throwable
      // Data

      MemDataBook mdbData = new MemDataBook();
      mdbData.getRowDefinition().addColumnDefinition(new ColumnDefinition("FIRSTNAME"));
      mdbData.getRowDefinition().addColumnDefinition(new ColumnDefinition("LASTNAME"));
      mdbData.getRowDefinition().addColumnDefinition(new ColumnDefinition("PHONE"));;
      mdbData.setValues(new String[] {"FIRSTNAME", "LASTNAME", "PHONE"},
                        new String[] {"JVx", "rocks", "+43 000 / 1234 567"});


      // Swing
      JVxTable table = new JVxTable();

      setLayout(new BorderLayout());
      add(table, BorderLayout.CENTER);
      setPreferredSize(new Dimension(500, 400));
}   // JVxTableTest

You have all JVx features like link cell editors, image choice editors - in your Swing application!

2-tier data (database)

Replace the MemDataBook with following code:

Code: Select all
// Database handling

//DB Connection
DBAccess dba = DBAccess.getDBAccess("jdbc:hsqldb:hsql://localhost/db");
//Table access
DBStorage dsFiles = dba.createStorage();
// Communication

//Connection handling
DirectObjectConnection con = new DirectObjectConnection();
con.put("files", dsFiles);
MasterConnection macon = new MasterConnection(con);;
//Connect to the "remote" table
RemoteDataSource rds = new RemoteDataSource(macon);;

RemoteDataBook rdbData = new RemoteDataBook();

3-tier data (database)

Remote DBAccess, DBStorage and DirectObjectConnection and replace the MasterConnection with following code:

Code: Select all
HttpConnection con = new HttpConnection("http://server/app/services/Server");      
MasterConnection macon = new MasterConnection(con);
User avatar
Posts: 311
Joined: Mon Sep 28, 2009 1:54 pm

Return to Code snippets