GUI工具包 Swing

fmms 12年前
     <p><strong>Swing</strong> 是一个为Java设计的<span class="mw-redirect">GUI</span>工具包。 Swing 是 JAVA基础类 的一部分。 Swing 包括了图形用户界面 (GUI) <span class="new">器件</span> 如:文本框,按钮,分隔窗格和表。</p>    <p>SWING 提供许多比AWT更好的屏幕显示元素。它们用纯<strong>Java</strong>写成,所以同<strong>Java</strong>本 身一样可以跨平台运行,这 一点不像AWT。 它们是JFC的一部分。 它们支持可更换的面板和主题(各种操作系统默认的特有主题),然而不是真的使用原生平台提供的设备,而是仅仅在表面上模仿它们。这意味着你可以在任意平台 上使用JAVA支持的任意面板。 轻量级元件的缺点则是执行速度较慢,优点就是可以在所有平台上采用统一的行为。</p>    <p>Swing程序外观<br /> <img alt="GUI工具包 Swing" src="https://simg.open-open.com/show/ac326cfd640a4216b3857e515233e3fb.gif" width="210" height="49" /></p>    <p>示例代码:</p>    <pre class="brush:java; toolbar: true; auto-links: false;">import javax.swing.*;         public class HelloWorldSwing {     /**      * 创建并显示GUI。 出于线程安全的考虑,      * 这个方法在事件调用线程中调用。      */     private static void createAndShowGUI() {         //Make sure we have nice window decorations.         JFrame.setDefaultLookAndFeelDecorated(true);          //Create and set up the window.         JFrame frame = new JFrame("HelloWorldSwing");         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);          //Add the ubiquitous "Hello World" label.         JLabel label = new JLabel("Hello World");         frame.getContentPane().add(label);          //Display the window.         frame.pack();         frame.setVisible(true);     }      public static void main(String[] args) {         //Schedule a job for the event-dispatching thread:         //creating and showing this application's GUI.         javax.swing.SwingUtilities.invokeLater(new Runnable() {             public void run() {                 createAndShowGUI();             }         });     } }</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1323347806640" target="_blank">http://www.open-open.com/lib/view/home/1323347806640</a></p>    <p></p>