Swing首页、文档和下载 您所在的位置:网站首页 swing开发工具包 Swing首页、文档和下载

Swing首页、文档和下载

2023-06-27 00:58| 来源: 网络整理| 查看: 265

Swing 是一个为Java设计的GUI工具包。 Swing 是 JAVA基础类 的一部分。 Swing 包括了图形用户界面 (GUI) 器件 如:文本框,按钮,分隔窗格和表。

SWING 提供许多比AWT更好的屏幕显示元素。它们用纯Java写成,所以同Java本身一样可以跨平台运行,这 一点不像AWT。 它们是JFC的一部分。 它们支持可更换的面板和主题(各种操作系统默认的特有主题),然而不是真的使用原生平台提供的设备,而是仅仅在表面上模仿它们。这意味着你可以在任意平台 上使用JAVA支持的任意面板。 轻量级元件的缺点则是执行速度较慢,优点就是可以在所有平台上采用统一的行为。

Swing程序外观

示例代码:

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();             }         });     } }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有