Skip to main content

Posts

Swing : Using HTML in button and Label text

You can decorate the buttons and label using the html text. You no need to call methods to set color, font size, font style etc for the Button and labels. Just specify them through the HTML tag. import  javax.swing. * ; import  java.awt. * ; class  HTMLButton {      public   static   void  main( String  ar[ ] )     {           String  html =          "<html><table border=1>"          + "<tr><td>One</td><td>1</td></tr>"          + "<tr><td>Two</td><td>2</td></tr>"          + "</table>" ;                   JFrame  fram...

String : Tabded Pane

Java has class javax.swing.JTabbedPane that is used to represent the tabbed pane. Tabbed pane is a container that has the more than one Panel attached with the tabbed name, where you can place the components. Each tabbed have their own components properties. You create tabs to JTabbedPane using the addTab( ). Each tab may contain other components. import  javax.swing. * ; import  java.awt. * ; import  java.awt.event. * ; class  TabbedPaneDemo {      public   static   void  main( String  ar[])     {          JFrame  frame = new   JFrame ( "Menus" );                   JTabbedPane  tp = new   JTabbedPane ();                   JPanel  p1 = new   JPanel ();   ...

Swing : DeskTop Pane

 In swing API, JDeskTopPane is the container used to create a display area where multiple-document may be placed. So virtually, it works like a desktop where we can place anther component. It has two properties public static final int LIVE_DRAG_MODE             this indicates that while dragging components, they should be inside the desktop. public static final int OUTLINE_DRAG_MODE  this indicates that component inside the desktop may be dragged out side of desktop pane. Internal Frame You can create graphical interface that has the windows insides another window. This is done in java by using JInternalFrame class. Internal frame can be moved and resized independently. This is used to create the MDI application. According to java specification, it has the following different types of constructors JInternalFrame ()           Creates a non-resizable, non-closabl...

Swing : Toolbars

Tool bar component is a container for button , images , labels that can be added to any Frame. It contains horizontally aligned components and can be dragged and drop in window. You can add more then one tool bar to your window. Often too bars are used to access functionality that is also listed in menus. This facility is provided by the class JToolBar that is in javax.swing packge. There are following methods and constructors use commonly. Constructors JToolBar () it creates the toolbar with HORIZONTAL orientation. JToolBar (int orientation)  it creates the toolbar with specified orientation. JToolBar (String name)  it creates the toolbar with specified name and HORIZONTAL orientation. JToolBar (String name, int orientation) it creates the toolbar with specified name and specified orientation. Methods add(Copoenent) adds component to tool bar addSeparator () adds separator of de...

Swing : Table

Table component in Java swing is created by the javax.swing. JTable class. This class is graphically representation of table. The graphical area is divided in to rows and columns and data are arranged into the cells.  Creating table import  javax.swing. * ; import  javax.swing.event. * ; import  java.awt. * ; import  javax.swing.border. * ; class  SwingDemo14 {      public   static   void  main( String  ar[])     {          JFrame  f = new   JFrame ( "Tool bar demo" );                   Object  colNames[] = { "Name" , "Phone" , "Address" };                   Object  rows[][] = {  { "ABC" , "345345" , "T-&*6,kdjhfkj" },   ...

Tree

To create three component int Java swing we use   JTree class of the package javax.swing used to create the tree. Using tree class you can create the hierarchical view of items. import  javax.swing. * ; import  javax.swing.event. * ; import  java.awt. * ; import  javax.swing.tree. * ; class  SwingDemo {      public   static   void  main( String  ar[])     {          JFrame  f = new   JFrame ( "Tool bar demo" );                   DefaultMutableTreeNode  a = new   DefaultMutableTreeNode ( "Info" );          DefaultMutableTreeNode  name = new   DefaultMutableTreeNode ( "Name" );          DefaultMutableTreeNode  phone = new   ...

Using HyperSQL (HSQLDB)

HSQLDB is a portable RDBMS implemented in pure java. It can be embedded with your application as well as can be used separately. It is very a small database that supports almost all features of the standard database system. It comes with small jar file that can be found in lib folder. The HSQLDB jar package is located in the /lib directory of the ZIP package and contains several components and programs. Core components of jar file are : HyperSQL RDBMS Engine (HSQLDB), HyperSQL JDBC Driver, Database Manager, and Sql Tool. Installing and Using Download: download latest release of HyperSQL database from http://hsqldb.org website and extract it. You will see following contents. Here "bin" directory contains some batch files those can be used to run a swing based GUI tool. You can use runManagerSwing.bat to connect to database, but database must be on before running it. Directory lib contains File hsqldb.jar . It is the database to be used by you. Running database First ...