About Modal Forms
Only JDialog in Swing can be set to a Modal form, whose methods can be passed in a constructor (such as "JDialog (Frame owner, Boolean Modal)"), or by using the Setmodal (Boolean) method, which A method is inherited from the Dialog class.
In the JFrame class, the Modal form cannot be set through a method such as JDialog, where a friend tries to simulate a windowdeiconified form by Requestfocus () at Modal (), as follows:
public
use internal classes to solve this problem. The form of the inner class is as follows:
Class Outer {
int outer_int;
Class Inner {
int inner_int;
}
One advantage of using an inner class is that in an inner class, you can directly use the properties and methods in the external class. We use the following code to try to implement this design task. 3. Code Version1
Import javax.swing.*;
Import java.awt.*;
Import java.awt.event.*;
public class Newtwobuttons {
drawn by drawing in its container window through Java drawing techniques because it is painted. Therefore, it can realize the "transparent" effect of the component, and it can achieve the performance on different platforms, and the cost of component drawing and event processing is much smaller, which improves the efficiency of program running.
4. Because lightweight components must be drawn in their own windows and eventually included in a weight container, several top-level containers in swin
(string[] args) {hellocsdnframe frame=new hellocsdnframe (); Frame.setdefaultcloseoperation (Jframe.exit_on_close); Frame.show (); }//Part II class Hellocsdnframe extends jframe{public hellocsdnframe () {settitle ("Hello csdn.net"); SetSize (Width,height); Hellocsdnpanel panel=new Hellocsdnpanel (); Container C=getcontentpane (); C.add (panel); public static final int width=300; public static final int height=200; //Part III cl
1. This is a Portal framework class for student information systems. Studentframe is the top-level window frame. Through seven button controls to enter the different classes, different departments of the student information system.
Class Studentmanageframe extends JPanel {private static final long serialversionuid = 1L;
static final int WIDTH = 400;
static final int HEIGHT = 200;
JFrame Studentframe;
Public Studentmanageframe () {studentfr
the interface, declare the control, and then start editing the interface. For the interface, the first is a frame frame, for frame, you can set its title settitle (); (the title can also be created when the caption is determined in the constructor.) ), and then the window size, which may be a headache for beginners, in the end to set how much? In fact, it is very simple, in the Java core volume a function, you can get the actual size of the PC window, according to this value to adjust the line.
1. Structural Partitioning There are two types of Swing components, one is the JComponent class and one is the Windows class. Where the Windows class contains components that can be displayed independently, and the JComponent class contains components that cannot be displayed independently . What are components that can be displayed independently, and components that cannot be displayed independently? components that can be displayed independently : When you run a program, components that can b
How to add a background image in Java and add a background image in Java
First, import the related packages:
Import java. awt. BorderLayout;
Import java. awt. Container;
Import javax. swing. ImageIcon;
Import javax. swing. JFrame;
Import javax. swing. JLabel;
Import javax. swing. JPanel;
You can also use:
Import java. awt .*;
Import javax. swing .*;
Create a Java form object and set it to visible
Eg: JFram frame =
; var jframe = This. gethideframe (); try {form. submit (); form. reset (); // do not forget to call the reset method. Otherwise, the change event cannot be triggered when the file is selected for the second time.} catch (e) {jframe. ATTR ("src", "/m2012/html/blank.htm L "). load (function () {jframe. unbind ("LOAD", arguments. callee); form. submit (); form. res
! ") ;}}); JFrame fm = new JFrame (" simple event "); fm. setContentPane (pn); fm. setSize (300,100); fm. setVisible (true) ;}} console output result: AWT-EventQueue-0-do action... indicates that the message thread is processing
Using SwingUtilities. invokeAndWait ()
The developers of the Swing toolkit realized that there wocould be times when an external thread wowould need to make changes to Swing compone
jtable (model );Rowsorter sorter = new tablerowsorter (model );Table. setrowsorter (sorter );
The code above first creates a tablemodel, and then passes the tablemodel instance to both jtable and rowsorter. The following is a simple example of using jtable sorting.
Import javax. Swing .*;Import javax. Swing. Table .*;Import java. AWT .*;Public class testsortedtable{Public static void main (string ARGs []){Jframe frame = new
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.