implementation of the KeyListener interface will be the KeyListener interface to rewrite all the methods, but the real use of only one method, so rewrite the other methods but it is not necessary to do without effort * * Class Keymonitor extends Ke
yadapter{public void keypressed (KeyEvent e) {int keycode = E.getkeycode ();
/* Use the getKeyCode () method to get the virtual code for the key./* If the virtual code of the key that is acquired is equal to the UP key is the virtual code that
1. Graphical User Interfacejava objects that are provided for the GUI exist in Java. AWT and javax. Swing two packages in Java. Awt:abstract window Toolkit Abstract Windows Toolkit needs to invoke Local System method implementation functions, poor portability, dependent system. Heavy-weight control javax. Swing's set of graphical interface systems, based on AWT,
");//Label JLabel = new JLabel ("select"); JLabel2 = new JLabel ("Environment");//CheckJCheckBox1 = new Jcheckbox ("Python"), JCheckBox2 = new Jcheckbox ("Java"); jCheckBox3 = new Jcheckbox ("Python");// Radio Jradiobutton = new Jradiobutton ("Linux"), JRadioButton2 = new Jradiobutton ("Unix"); JRadioButton3 = new Jradiobutton (" Windows "); jRadioButton4 = new Jradiobutton (" Mac OS ");//Radio Box Groupbuttongroup = new Buttongroup (); Buttongroup.ad
Panel assembly (Jpanel). An interface with only one jframe, but can have multiple JPanel components and JPanel components can be placed FlowLayout, borderlayout,gridlayout components, such a combination of use to achieve more complex layout effects such as: package gui;import java.awt.borderlayout;import Java.awt.gridlayout;import java.awt.FlowLayout;import Javax.swing.jbutton;import javax.swing.jframe;import javax.swing.jpanel;/** Panel assembly * C
those who require the user to do something (such as clicking on a drop-down menu items) only appear dialog box, this dialog is dialog.Ii. Components and Containers (component and container) 2.1.Frame Frame Example:1 package cn.javastudy.summary; 2 3/** Learn Java GUI programming the first graphical interface window */4 import java.awt.*; 5 6 Public class Tes
Swing's button component. In the Widgets class. To use a button, you must import Jbuttonimport Javax.swing.JButton; the button needs to be added to the Frame inside the package Gui;import Java.awt.frame;import Javax.swing.jframe;import javax.swing.jbutton;/*** Created by admin on 2017/6/30.* Java GUI learning */public class G
"); This.setresizable (false); This.setlocation (this.setsize); this.setdefaultcloseoperation (jframe.exit_on_close);; This.setvisible (True);}} //An area for drawing and displaying drawings//Inheriting the parent class Jpanelclass Mypanel extends jpanel{//JPanel There is a method (paint) inherited after the need to rewrite//graphics is a brush is an important class of drawing class/ /This method does not need to be explicitly called, run time system will automatically call//the following condit
To place a picture in the graphical interface, you need to use the window splitter JSplitPane (belonging to the container class component) to the interface above the imageicon. Split the window into two columns. A column is JList, inside entered some text, a column is jlable, above place the picture. The layout uses the Borderlayoutpackage gui;import java.awt.borderlayout;import javax.swing.jframe;import Javax.swing.jlabel;import Javax.swing.jsplitpan
(40 0, 500,BUFFEREDIMAGE.TYPE_INT_RGB);//double-buffered private jlabel[] Lbls = new Jlabel[4];p ublic clock () {This.settitle ("clock"); This.setsize (+), this.setdefaultcloseoperation (exit_on_close); this.setresizable(false); This.setlocationrelativeto (null); This.setlayout (null); timer = new Timer (n, this); lbl = new JLabel (str); Displays the digital time Lbl.setfont (new Font ("Consolas", Font.plain, Panax Notoginseng)), Lbl.setbounds ((), This.add (LBL); for (int i = 0; i
need to implement ActionListener method actionperformed Complete Event listening process private JPanel panel;private JButton jButton1, jbutton2;public static void Main (string[] args) {Events events = new events (); Public Events () {panel = new JPanel (); jButton1 = new JButton ("Switch to red") JButton2 = new JButton ("Switch to Blue"); This.add (JButton1, B Orderlayout.north); This.add (panel, borderlayout.center); This.add (JButton2, Borderlayout.south);//register for monitoring, monitorin
There are currently three creation templates to generate the application form:The first type: Public class Implements actionlistener{// your component (member variable) Public Menudemo () {// constructor method JFrame frame=new JFrame ("menu form"); Frame.setsize (300,300); Frame.setlocation (300,200); Frame.setresizable (false); Frame.setvisible (true);The second type: public class Demodemo "extends jframe{ // your component pu
GUI Graphics user Interrface graphical UI that allows users to do what they want by clicking the mouse.The main is the practice interface settings Interface layout Add component settings component interface Rewrite listenerTo make a semaphore, click on the radio button below to specify the signal lights, the code is as follows:Package Com.lovo.homework1;import Java.awt.color;import Java.awt.graphics;import java.awt.event.itemevent;import Java.awt.even
Swing was a GUI framework developed by Sun, and at the outset sun was developing the AWT framework. However, the AWT framework has LCD problems. As a result, Sun continued to develop swing on the basis of AWT. Swing is a class that inherits the AWT common components: Text text component Menus menu component Widgets Widget component Top-level-windows Top-level window Management sub-windows child windowOne of the Ja
1.awt:component: Buttons, icons, etc. that can be displayedwindow can be displayed independently, the panel can accommodate other elements, but it cannot be displayed as a separate window for the application.Applets are not usedThe basic difference between AWT and swing: AWT is a local method-based C/s + + program that runs faster, and swing is an AWT-based Java program that runs slower. For an embeddedApplications, the hardware resources of the targe
layout manager by: setlayout (NULL);*/Import java.awt.*;public class Testnestedlayout {public static void main (string[] args) {frame f = new Frame ("Testnestedla Yout "); f.setlocation (+); f.setsize (+); f.setbackground (New Color ( 204, 204, 255); f.setlayout (New GridLayout (2, 1)); panel P1 = new Panel (new BorderLayout ()); panel P2 = new Panel (new BorderLayout ()); panel p3 = new Panel (new GridLayout (2, 1 ); panel P4 = new Panel (New GridLayout (2, 2)) p1.add (New button ("button"), b
, the axis settings are arranged horizontally (Boxlayout.x_axis) or vertically (boxlayout.y_ AXIS).A container--box class that specifically uses boxlayout is defined in the Javax.swing package.To create a box static method:public static Boxcreatehorizontalbox (): horizontal-oriented boxlayout.public static Boxcreatevertitcalbox (): BoxLayout in the vertical direction.Ways to create a box invisible component:The function is to increase the distance between courseware components.public static Comp
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.