Java GUI (homework), javagui
The GUI teacher said that there will be little use in the future, so the notes are not very good, so I will not take them out, so I will share my homework today.
Job 1: Set a tool that can generate random numbers continuously. A button is required to pause or start.
Import java. awt. event
make it show in the playJLabel label = new JLabel ("Hello world!", jlabel.center);//center JustifieldAdd a label to the frame, set the frame sizeFrame.add (label);Frame.setsize (500, 300);Frame.setdefaultcloseoperation (jframe.exit_on_close);//end process when user exitsFrame.setvisible (TRUE);//Set frame visibility}}650) this.width=650; "style=" WIDTH:400PX;HEIGHT:237PX; "src=" http://s3.51cto.com/wyfs02/M00/73/10/ Wkiom1xzknsybw6aaabc2ofcjii047.jpg "title=" frame. png "alt=" wkiom1xzknsybw6aa
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
JAVA: GUI Implementation of the remote Intersection Algorithm
Compiling environment:
Operating System: Win8.1 64-bit
IDE platform: Visual Studio 2013 Ultimate
I. Principles
Observe the distance S1, S2, and S3 on the P to be tested, and then determine the plane coordinates of P:
Ii. Code Implementation
Frontend rendezvous. java
Package text; import
Java GUI Development 99 multiplication table(1) Achieve the goal:Using the Java-brought AWT package, the base control develops a 99 multiplication table, which can be clicked to display the corresponding multiplication formula.(2) Control selection:Click--buttonShow--textfield(3) interface design: Overall design layout(4) Main form writingDisplay the program in t
Atitit.Atitit. Gui Controls and panels -----service-side controls Java struts implementation best practices1. Category 1 for server controls1.1. Data control: This class of controls can be subdivided into two types: data source controls and data-bound controls. 11.2. Site Navigation controls: 11.3. WebParts Controls:11.4. Login CONTROLS: 11.5. Ajax Controls 12. JSF 23. Apache ECS 24. Custom UI Control ...
"); 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
figure3. Code public interface Builder { void Buildparta (); void Buildpartb (); void Buildpartc (); Product getresult (); } //Concrete Build Tool public class ConcreteBuilder implements Builder { Part parta, PartB, PARTC; public void Buildparta () {//Here is the code that specifically constructs Parta }; public void Buildpartb () {//Here is the code specifically for how to build PARTB }; public
()). GetText ()); - } -}Run resultsThere are many deficiencies in this programming approach, such as readability, poor reusability, and so on. It's more popular now. Use inner classes, especially anonymous inner classes, to implement the Listener class interface.1 Importjava.awt.event.ActionEvent;2 ImportJava.awt.event.ActionListener;3 4 ImportJavax.swing.JButton;5 ImportJavax.swing.JFrame;6 7 Public classJButtonEvent1extendsJFrame {8 PublicJButtonEvent1 () {9JButton button=NewJBu
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
written in front:Top two blogs we introduced the basic structure of the simple Java GUI and the event monitoring mechanism respectively. This time we will introduce the dual event (multi event) listening mechanism and introduce the inner class. 1. Design Tasks
Design a GUI, including basic components: button (two), label (one), Random color Circle-panel (one), re
Item2:consider a builder when faced with many constructor parametersWhen a constructor method has more than one parameter, you can consider using the builder approach for processing.Instance code: Public classnutritionfacts {Private Final intservingsize; Private Final intservings; Private Final intcalories; Private Final intfat; Private Final intsodium; Private Final intcarbohydrate; Public Static classbui
. Do not know how to handle the reasonable?
In addition, after writing a few articles about implementing design Patterns in Java code, it is found that this builder builder pattern seems to combine abstract factory patterns with template method patterns. The above paragraph has said my doubts, as for the abstract factory model, I personally think the above code
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.