Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... 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.... 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...
Stats
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);
    }
}