loading a picture file into the programThe class provided in 1-2 above is the class of the javax.swing package. You must add the package name when you write.FlowLayout and dimension are under the java.awt package.ImageIcon is under the javax.swing package.3. Implement a login interface1. Create a new Login.java class, and then define the main function and the method of initializing the interface in the class.2. In the main function, instantiate the object of the login class and invoke the metho
opposite case, We can inherit our work only when the task ends and the return value is returned. We can use the public static void invokeAndWait (Runnable runnable) method of EventQueue. The code for getting the value should be completed by us, rather than the return value of the invokeAndWait () method.
To demonstrate how to create a Swing-based program, list 2-1 shows the source code of an optional button.
Import javax. swing .*;Import java. awt .*;Import java. awt. event .*;Public class Butt
another main frame (home) if (User_field.gettext (). Equals (userName) Password_ Field.gettext (). Equals (password)) { Joptionpane.showmessagedialog (null, "Login succeeded", "login", Joptionpane.information_message); //Claim home JFrame home_page = new JFrame ("Student Information Management System"); Home_page.setresizable (FALSE); Home_page.setsize (600, 600);//Set the size of the window Home_pa
aspects.Well, let's see what we have to say in class today.Swing Container ComponentsSwing container components are functionally divided into the following categories:Bottom containers: Jframe,japplet,jwindow and JDialogNormal container: Jpanel,jscrollpane,jsplitpane, also called intermediate containerSpecial containers: Jinternalframe,jlayerpane,jrootpane and JToolBar,A container that can play a special role3 most commonly used containersJFrameJPane
Package com.swing;import Java.awt.Color;import Java.awt.Container;import java.awt.event.ActionEvent;import Java.awt.event.ActionListener;import Javax.swing.JButton;import Javax.swing.JDialog;import Javax.swing.JFrame;import Javax.swing.JLabel;import javax.swing.WindowConstants;/*** 1:jdialog form when a dialog box is in the swing component,* The function of JDialog is to eject another form from one form, just like the OK dialog box that pops up when using a browser* * 2:jdialog forms are similar
Java GUI implements the student achievement management system,
I have been learning java for more than a year and have been doing web exercises. In a project, I found that the GUI-related knowledge is required and the results cannot be obtained, there are not many articles in this area on the Internet, so I had to learn them from the beginning. However, I found that the GUI is very interesting, he does not rely on the Internet like a WEB program, and there are still many la s which are not very
Swing programs use JFrame objects to implement their windows. The JFrame class is a subclass of the AWT Frame class.It also adds some unique features of Swing. In Hello Swing, the code for processing JFrame is as follows:Public HelloSwing (){JFrame;JPanel jPanel;.....JFrame
more complex User Interface programs.
Figure 1
Figure 2
First, we use a single listener to implement this program. We define a class named Simple1 to include all the code. All user actions (such as clicking a button) are performed by actionreceivmed in the SimpleListenner of a listener.
Method
. The following code is used:
/** Simple1.java-first method for event processing* In this example, an actionlistener is used to listen to events generated by the event source.* Use some if st
everyone to focus on Swing learning, we also put the resources required for game development in the download file. After downloading, You can compile and run the game and see the execution results.
1. Top-layer container
What is a top-level container? When we use Java for graph programming, where can we draw a graph? We need a container that provides graphic rendering. This container is called a top-layer container. You can also think of it as a window. The top-layer container is the basis fo
model associated with the editor.Gettext ()Returns the text contained in textcomponent.Iseditable ()Returns a Boolean that indicates whether the textcomponent can be edited.Setdragenabled (Boolean B)Set the dragenabled attribute. This attribute must be set to true to enable automatic drag processing for this component (the first part of the drag-and-drop operation ).Seteditable (Boolean B)Sets the specified Boolean variable to indicate whether the textcomponent should be editable.Settext (strin
resources required for game development in the download file. After downloading, You can compile and run the game and see the execution results. (Download game source files)
1. Top-layer container
What is a top-level container? When we use Java for graph programming, where can we draw a graph? We need a container that provides graphic rendering. This container is called a top-layer container. You can also think of it as a window. The top-layer container is the basis for Graphic programming. All
panels on any platform. The disadvantage of lightweight components is that it is slower to perform, with the advantage that uniform behavior can be applied across all platforms.
Hello World Program
The Helloworldswing.java file code is as follows:
Import javax.swing.*;
The public class Helloworldswing {
/**{
* Creates and displays the GUI. For thread-safe consideration,
This method is invoked in the event call thread.
* *
private static void Createandshowgui () {
//en
). We can reuse the line class to generate (different properties) straight lines and combine them into different objects.
This is to understand a graph in an object-oriented way. An object is a natural way to describe a graph. Object-Oriented programming has been widely used in computer graphics.
A simple Gui
Java GUI functions are mainly concentrated in the AWT and swing packages. AWT is the underlying GUI package. The swing package is a high-level package, which is easier to transpla
Let's look at the example below: The following button is used as a command
Package command; import Java. AWT. event. actionevent; import Java. AWT. event. actionlistener; import javax. swing. jbutton; import javax. swing. jframe; import javax. swing. jpanel; public class buttonpanel extends jpanel implements actionlistener {Private Static final long serialversionuid = 4715122374780095560l; private jbutton Bt1, bt2, bt3; Public buttonpanel () {Bt1 = ne
Javax.swing.JPanel;
Import Javax.swing.JTextField;
Import Javax.swing.UIManager;
Import javax.swing.UnsupportedLookAndFeelException;
public class MyFrame extends JFrame {JPanel Mainpanel = new JPanel ();
JButton add = new JButton ();
JButton left = new JButton ();
JButton right = new JButton ();
JLabel label = new JLabel ();
JTextField field = new JTextField ();
Defaultlistmodel Leftmodel = new Defau
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.