Popular Posts
Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement... Simple Web snapshot import java.util.Date; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.graphics.GC; import org.e... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data....
Stats
OracleDBConsole service start failed @ host IP | name changed.
When host ip, or name changes, an error occurs.

It occurs emctl start service error. To solve this error, step by flowing:
set oracle_sid=mes
mes is the sid of oracle.
emctl start dbconsole
Then, a message "OC4J Configuration issue. C:\oracle\product\10.1.0\Db_1/oc4j/j2ee/OC4J_DBConsole_10.1.3.121_mes not found." is displayed. Copy the fold %ORACLE_HOME%\product\10.1.0\Db_1\oc4j\j2ee\OC4J_DBConsole_cci-r3_mes to %ORACLE_HOME%\product\10.1.0\Db_1\oc4j\j2ee\OC4J_DBConsole_10.1.3.121_mes and try start service again.
emctl start dbconsole
Another message "EM Configuration issue. C:\oracle\product\10.1.0\Db_1/10.1.3.121_mes not found." is returned. Copy fold %ORACLE_HOME%\product\10.1.0\Db_1\cci-r3_mes to %ORACLE_HOME%\product\10.1.0\Db_1\10.1.3.121_mes. and restart service again. Service will start successfully.
SwiXml - TabbedPane
TabbedPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel layout="BorderLayout">
    <label text="TabbedPane sample" constraints="BorderLayout.NORTH" />
    <tabbedpane>
        <panel name="Tab 1" layout="FlowLayout(FlowLayout.LEFT)">
            <label text="Blue content" foreground="0000FF" font="BOLD-30" />
        </panel>
        <panel name="Tab 2" layout="FlowLayout(FlowLayout.LEFT)">
            <label text="Green content" foreground="00FF00" font="BOLD-30" />
        </panel>
        <panel name="Tab 3" layout="FlowLayout(FlowLayout.LEFT)">
            <label text="Red content" foreground="FF0000" font="BOLD-30" />
        </panel>
    </tabbedpane>
</panel>
TabbedPane.java
package swixml.sample;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class TabbedPane extends JPanel {

    public TabbedPane() {
        try {
            new SwingEngine(this).insert("swixml/sample/TabbedPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - TabbedPane");

        frame.setContentPane(new TabbedPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}
SwiXml - Layout

BorderLayout

BorderLayoutPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel layout="BorderLayout">
    <button constraints="BorderLayout.NORTH" text="North" action="btn_Click" />
    <button constraints="BorderLayout.EAST" text="East" action="btn_Click" />
    <button constraints="BorderLayout.WEST" text="West" action="btn_Click" />
    <button constraints="BorderLayout.SOUTH" text="South" action="btn_Click" />
    <button constraints="BorderLayout.CENTER" text="Center" action="btn_Click" />
</panel>
BorderLayoutPane.java
package swixml.sample;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class BorderLayoutPane extends JPanel {

    public Action btn_Click = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), ((JButton) e.getSource()).getText());
        }
    };

    public BorderLayoutPane() {
        // TODO Auto-generated constructor stub
        try {
            new SwingEngine(this).insert("swixml/sample/BorderLayoutPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - BorderLayout");

        frame.setContentPane(new BorderLayoutPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}

BoxLayout

BoxLayoutPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel>
    <hbox>
        <vbox>
            <button text="A1" />
            <glue />
            <button text="A2" />
            <button text="A3" />
            <button text="A4" />
        </vbox>
        <vbox border="TitledBorder(A Titled Border)">
            <button text="B1" />
            <button text="B2" />
            <button text="B3" />
            <glue />
            <button text="B4" />
            <hbox>
                <button text="C1" />
                <button text="C2" />
                <button text="C3" />
            </hbox>
        </vbox>
    </hbox>

</panel>
BoxLayoutPane.java
package swixml.sample;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class BoxLayoutPane extends JPanel {

    public BoxLayoutPane() {
        // TODO Auto-generated constructor stub
        try {
            new SwingEngine(this).insert("swixml/sample/BoxLayoutPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - BoxLayout");

        frame.setContentPane(new BoxLayoutPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}

CardLayout

CardLayoutPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel layout="CardLayout">
    <panel constraints="view1" layout="BorderLayout">
        <label text="View one" foreground="FF0000" font="bold-30" constraints="BorderLayout.CENTER" />
        <button text="Change View" constraints="BorderLayout.SOUTH" action="btnViewChange_Click" />
    </panel>
    <panel constraints="view2" layout="BorderLayout">
        <label text="View two" foreground="00FF00" font="bold-30" constraints="BorderLayout.CENTER" />
        <button text="Change View" constraints="BorderLayout.SOUTH" action="btnViewChange_Click" />
    </panel>
    <panel constraints="view3" layout="BorderLayout">
        <label text="View three" foreground="0000FF" font="bold-30" constraints="BorderLayout.CENTER" />
        <button text="Change View" constraints="BorderLayout.SOUTH" action="btnViewChange_Click" />
    </panel>
</panel>
CardLayoutPane.java
package swixml.sample;

import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class CardLayoutPane extends JPanel {

    public Action btnViewChange_Click = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            CardLayout layout = (CardLayout) getLayout();
            layout.next(CardLayoutPane.this);
        }
    };

    public CardLayoutPane() {
        // TODO Auto-generated constructor stub
        try {
            new SwingEngine(this).insert("swixml/sample/CardLayoutPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - CardLayout");

        frame.setContentPane(new CardLayoutPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}

FlowLayout

FlowLayoutPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel layout="FlowLayout">
    <label text="姓名" />
    <textfield id="txtName" columns="25" />
    <button id="btnSubmit" text="確定" action="btnSubmit_Click" />
</panel>
FlowLayoutPane.java
package swixml.sample;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class FlowLayoutPane extends JPanel {

    public Action btnSubmit_Click = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), //
                    String.format("Hi, %s!", txtName.getText()));
        }
    };

    JTextField txtName;
    JButton btnSubmit;

    public FlowLayoutPane() {
        // TODO Auto-generated constructor stub
        try {
            new SwingEngine(this).insert("swixml/sample/FlowLayoutPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - FlowLayout");

        frame.setContentPane(new FlowLayoutPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}

GridBagLayout

GridBagLayoutPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel layout="GridBagLayout">
    <button text="1">
        <gridbagconstraints gridx="0" gridy="0" fill="GridBagConstraints.BOTH" />
    </button>
    <button text="2">
        <gridbagconstraints gridx="1" />
    </button>
    <button text="3">
        <gridbagconstraints gridx="2" />
    </button>
    <button text="4 + 7">
        <gridbagconstraints gridx="0" gridy="1" gridheight="2" fill="GridBagConstraints.BOTH" />
    </button>
    <button text="5 + 6">
        <gridbagconstraints gridx="1" gridwidth="2" fill="GridBagConstraints.BOTH" />
    </button>
    <button text="8">
        <gridbagconstraints gridx="1" gridy="2" />
    </button>
    <button text="9">
        <gridbagconstraints gridx="2" gridy="2" />
    </button>
</panel>
GridBagLayoutPane.java
package swixml.sample;

import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class GridBagLayoutPane extends JPanel {

    public GridBagLayoutPane() {
        // TODO Auto-generated constructor stub
        try {
            new SwingEngine(this).insert("swixml/sample/GridBagLayoutPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - GridBagLayout");

        frame.setContentPane(new GridBagLayoutPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}

GridLayout

GridLayoutPane.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel layout="GridLayout(3,3)">
    <button text="1" action="btn_Click" />
    <button text="2" action="btn_Click" />
    <button text="3" action="btn_Click" />
    <button text="4" action="btn_Click" />
    <button text="5" action="btn_Click" />
    <button text="6" action="btn_Click" />
    <button text="7" action="btn_Click" />
    <button text="8" action="btn_Click" />
    <button text="9" action="btn_Click" />
</panel>
GridLayoutPane.java
package swixml.sample;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class GridLayoutPane extends JPanel {

    public Action btn_Click = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), ((JButton) e.getSource()).getText());
        }
    };

    public GridLayoutPane() {
        // TODO Auto-generated constructor stub
        try {
            new SwingEngine(this).insert("swixml/sample/GridLayoutPane.xml", this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("SwiXML - GridLayout");

        frame.setContentPane(new GridLayoutPane());
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}
reference : LayoutConverter
CookSwing
CookSwing is a library which builds Java Swing GUI from XML documents. It is under continuously active development, since I make a living by doing Swing GUI :) Unlike many other XUL toolkits, Swing is complete in its capability dealing with Swing and beyond. It is mature and stable. If you like this library, please help spreading the word.

CookSwing: XML to Java Swing GUI

MyPanel.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel>
    <flowlayout>
        <label id="lbHello" text="Hello World Again!" horizontalalignment="CENTER" foreground="#ff0000" font="Serif,bold italic,20" />
        <button text="test" actionlistener="btnTest_Click" />
    </flowlayout>
</panel>
MyPanel.java
package cs;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;

import cookxml.cookswing.CookSwing;

public class MyPanel extends JPanel {

    public String msg;

    // action variant for CookSwing
    public Action btnTest_Click = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {

            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), MyPanel.this.toString());
        }
    };

    // constructor with arguments
    public MyPanel(String msg) {
        this.msg = msg;
    }

    // customized method, this method can't be assign to rendered object
    public void randomCode() {
        // do something
        JOptionPane.showConfirmDialog(JOptionPane.getRootFrame(), "Test code");
    }

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("CookSwing basic usage");

        MyPanel panel = new MyPanel("My name is bruce.");
        CookSwing cs = new CookSwing(panel);
        Container container = cs.render("cs/MyPanel.xml");

        // pane & container are two different instance
        System.out.println(panel);
        System.out.println(container);
        // get object by id
        System.out.println(cs.getId("lbHello").object);

        frame.setContentPane(container);
        frame.pack();

        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((sc.width - frame.getWidth()) / 2, (sc.height - frame.getHeight()) / 2);
        frame.setVisible(true);
    }

}

It is a pity that CookSwing, not like SwiXml, can't render object itself, but create a new instance for using. In this condition, I msut create a component by assign a instance (variant) and a xml document, instead of by using new . And I can't specify a public method for redered object to invoke some process.

SwiXml
SwiXml, is a small GUI generating engine for Java applications and applets. Graphical User Interfaces are described in XML documents that are parsed at runtime and rendered into javax.swing objects.
http://www.swixml.org/index.html
Building GUIs with SwiXml

Version 1.5, supported Layout :
FlowLayout
BorderLayout
GridLayout
GridBagLayout
BoxLayout
CardLayout

XPanel.xml
<?xml version="1.0" encoding="UTF-8"?>
<panel Layout="flowlayout">
    <label text="條碼" />
    <textfield id="txtBarCode" columns="30" />
    <button id="btnEnter" text="輸入" action="btnEnter_click" />
</panel>
XPanel.java
package swixml.sample;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.util.UUID;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import org.swixml.SwingEngine;

public class XPanel extends JPanel {
    public Action btnEnter_click = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println(txtBarCode.getText());
        }
    };

    JTextField txtBarCode;
    JButton btnEnter;

    public XPanel() throws Exception {
        new SwingEngine(this).insert("swixml/sample/XPanel.xml", this);

        // other setting
        btnEnter.setForeground(Color.red);
    }

    // customized method
    public void randomCode() {
        txtBarCode.setText(UUID.randomUUID().toString());
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        MFrame frame = new MFrame();
        // invoke method
        ((XPanel) frame.getContentPane()).randomCode();
    }

}

class MFrame extends JFrame {
    public MFrame() {
        try {
            setContentPane(new XPanel());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        setTitle("SwiXML Panel Sample");
        pack();
        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((sc.width - getWidth()) / 2, (sc.height - getHeight()) / 2);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }
}
Date function : system date
Oracle
SELECT CURRENT_DATE FROM DUAL;
SELECT SYSDATE FROM DUAL;
Oracle Date Functions : http://psoug.org/reference/date_func.html
JTable readonly / single selection
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.util.UUID;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;

public class JTableFrame extends JFrame {

 public JTableFrame() {
  // TODO Auto-generated constructor stub
  getContentPane().setLayout(new BorderLayout());
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  DefaultTableModel model = new DefaultTableModel();
  JTable table = new JTable(model) {
   @Override
   public boolean isCellEditable(int row, int column) {
    // set table column uneditable
    return false;
   }
  };

  // set table single row selectable
  table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

  // set column move disabled
  table.getTableHeader().setReorderingAllowed(false);

  table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
   @Override
   public void valueChanged(ListSelectionEvent e) {
    // row selection changed

    if (e.getValueIsAdjusting()) {
     System.out.println(e.getFirstIndex());
    }
   }
  });

  model.addColumn("No.");
  table.getColumnModel().getColumn(0).setMaxWidth(100);
  model.addColumn("UUID");

  for (int i = 1; i < 51; i++) {
   model.addRow(new Object[] { i, UUID.randomUUID() });
  }

  JScrollPane spane = new JScrollPane();
  spane.setViewportView(table);
  getContentPane().add(spane, BorderLayout.CENTER);

  // if content value is changed, try invoke :
  // table.revalidate();
  // spane.revalidate();

  setSize(400, 300);

  Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
  setLocation(new Point((sc.width - getWidth()) / 2, (sc.height - getHeight()) / 2));
  setVisible(true);
 }

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  new JTableFrame();
 }

}
Resize image (awt)
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class ResizeImageFrame extends JFrame {

    public ResizeImageFrame() throws IOException {
        setTitle("Resize image");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new FlowLayout());

        JLabel img1 = new JLabel();
        img1.setIcon(new ImageIcon(getClass().getResource("/arrow_right.png")));
        add(img1);

        BufferedImage icon2 = ImageIO.read(getClass().getResource("/arrow_right.png"));
        // resize image
        AffineTransform transform = AffineTransform.getScaleInstance(30.0 / icon2.getWidth(), 30.0 / icon2.getHeight());
        AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
        icon2 = op.filter(icon2, null);
        JLabel img2 = new JLabel();
        img2.setIcon(new ImageIcon(icon2));
        add(img2);

        pack();
        Dimension sc = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation(new Point((sc.width - getWidth()) / 2, (sc.height - getHeight()) / 2));
        setVisible(true);
    }

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

        new ResizeImageFrame();
    }

}