Swing桌面程序(第2篇)
Swing中的控件可以分为三类:顶层容器、非顶层容器和普通控件。 1)顶层容器是一种可以直接显示在系统桌面上的控件,也就是作为GUI应用程序的最外层容器。其他控件必须直接或间接地借助顶层容器进行显示。 顶层容器一般包括JFrame窗口类,JWindow和JDialog类
Swing中的控件可以分为三类:顶层容器、非顶层容器和普通控件。
1)顶层容器是一种可以直接显示在系统桌面上的控件,也就是作为GUI应用程序的最外层容器。其他控件必须直接或间接地借助顶层容器进行显示。
顶层容器一般包括JFrame窗口类,JWindow和JDialog类。
2)非顶层容器是要放到顶层容器中使用的,对于顶层容器来说,非顶层容器是一般控件。
在非顶层容器中还可以添加控件,对于这些控件来看,非顶层容器就是一个容器。
非顶层容器包括JPanel面板类。
3)普通控件在控件中占大多数,使用这些控件可以实现特定的功能,但普通控件不具有容器的作用。
package com.whut.sw;
import javax.swing.*;
public class Swing7 extends JFrame{
JPanel jp=new JPanel();
JButton jb=new JButton();
//定义构造器
public Swing7(){
this.setTitle("创建面板");
jb.setText("这是一个按钮");
jp.add(jb);
this.add(jp);
this.setBounds(300, 250, 300, 200);
this.setVisible(true);
}
public static void main(String[] args) {
Swing7 s = new Swing7();
}
}
---------------------------------------------------------------------------------
结果如下:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

We all encounter some operational problems when using the win11 system. Recently, many users have asked what to do if there is a dark box on the left side of the win11 desktop? Users can directly select the recommended settings under the screen resolution, and then proceed with the operation. Let this site carefully introduce to users the analysis of the problem of dark boxes on the left side of the win11 desktop. Analysis of the problem of dark boxes on the left side of the win11 desktop. Adjust the screen resolution: right-click a blank area of the desktop, select "Display Settings", and select the appropriate resolution in the "Resolution" column. Update the graphics card driver: Open Device Manager, expand "Display Adapters", right-click

How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

When we were using the win10 system, we found that some friends' desktop icons were placed arbitrarily, while our computers were neatly arranged in a row. If we want to place icons randomly, we can right-click the desktop with the mouse and make relevant selections in the pop-up options to achieve this operation. Let’s take a look at the specific steps to see how the editor did it~ I hope it can help you. How to place Windows 10 desktop icons randomly 1. Right-click the "View" option in a blank space on the desktop. 2. Select to turn off "Automatically arrange icons" in the viewing mode. 3. In this way, you can drag and drop the desktop icons to where you want. The desired position is in place. Extension: icon display method | reasons why it is not displayed

What should I do if the RPC server is unavailable and cannot be accessed on the desktop? In recent years, computers and the Internet have penetrated into every corner of our lives. As a technology for centralized computing and resource sharing, Remote Procedure Call (RPC) plays a vital role in network communication. However, sometimes we may encounter a situation where the RPC server is unavailable, resulting in the inability to enter the desktop. This article will describe some of the possible causes of this problem and provide solutions. First, we need to understand why the RPC server is unavailable. RPC server is a

In win10 and win7, we can directly right-click the document we want to print to print, but in win11, we can't find how to print directly by right-clicking on the desktop. This is actually hidden in the secondary menu. Tutorial on how to print directly by right-clicking on the win11 desktop: 1. First, right-click the content you want to print. 2. Then click "Show more options" at the bottom. 3. Click "Print" to print it out. 4. Printing in this way will use the default printer, so we need to go to the "Printers and Scanners" of Bluetooth first. 5. Choose the printer you want to use in advance. 6. Set it as default

In Win7 system, many users want to delete personalized desktop background images, but do not know how to delete them. This article will show you how to delete personalized background images in Win7 system. 1. First, open the control panel interface of the Win7 system and click to enter the "Appearance and Personalization" settings; 2. Then, in the opened interface, click the "Change Desktop Background" setting; 3. Then, click below "Desktop background" option; 4. Then, select Select all, and then click Clear all. Of course, you can also use it under "Customize", right-click the theme you want to delete, and then click &q on the shortcut menu

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and
