Use UDP protocol to send a datagram to the other party. You must set the port number for receiving data each time you start it. The IP address and port sent can be modified after it is started.
PackedCode:
Http://115.com/file/e7jb7noz #Qq.zip
The main idea is simple:
1. Set your own receiving port
2. Set the peer IP address and port
3. send and receive data
The following is the main code:
Import Java.net .* ; Import Java. AWT .* ; Import Java. AWT. event .* ; Import Javax.
rectangle object// If other images need to be drawn, you can define them here first, and then use g2 as the paint brush in the next section to draw 16 double leftX = 50; 17 double topY = 50; 18 double width = 200; 19 double height = 150; 20 Rectangle2D rect = new Rectangle2D. double (leftX, topY, width, height); 21// Use paint brush g2 to draw text and rectangular images 22 g2.drawString ("Not a hello, World program", MESSAGE_X, MESSAGE_Y); 23 g2.draw (rect); 24 25} 26// Override this function
reasons, * This method is called in the event invocation thread. */ Private Static voidCreateandshowgui() { Make sure a nice look style JFrame.setdefaultlookandfeeldecorated(True); Creating and setting windows JFrameFrame= New JFrame("Helloworldswing");Frame.Setdefaultcloseoperation(JFrame.Exit_on_close); Add "Hello World" tab JLabelLabel= New JLabel("Hello World");Frame.Getcontentpane().Add(Label); Display windowFrame.Pack();Frame.setvisible(True);
toolbar.Select Java in the Categories pane of the Pop-up window, and in the Projects pane, select Java application. Click "Next";Type numberaddition in the project name and type the local file directory in the project location to save the project;The Confirm check box "set as Main project" is checked. And make sure that the check box "Create main class" is not checked.Click "Finish"Step 2: Build the interfaceContinue to create our interface. We need a Java container to place other GUI component
Requirement: Local AAR file uploaded to Maven libraryRefer to my previous blog Gradle uploading local files to a remote MAVEN library (Nexus server)Here is the Java graphical tool code PackageCom.jinkejoy.build_aar;Importjava.awt.FlowLayout;Importjava.awt.event.ActionEvent;ImportJava.awt.event.ActionListener;ImportJava.io.File;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJavax.swing.JButton;ImportJavax.swing.JFileChooser;ImportJavax.swing.JFr
the Swing component's display font to what we set in Vfont. 1.1 to Better center the window
Whether it's a top-level component JFrame or a dialog box JDialog, it's a common problem to have their windows centered, because they always bounce from the top left corner, which is too bad. For this issue, the JBuilder Application Generation Wizard gives the solution:
Dimension screensize = Toolkit.getdefaulttoolkit (). Getscreensize ();
Dimension framesize
XXX", such as "site:apihome.cn Java API JTextField"English: Baidu search "site:docs.oracle.com Java API XXX", such as "Site:docs.oracle.com Java API JTextField"3. Summarize the working principle of Java event-driven, refer to and rewrite the textbook example 6-1 (p115-116), rewrite the applet as JFrame.
4. Why do I need to "knock" code? See Bowen to all BBS students: How to learn a good way. It's easier to go to the stupid method of Python. Item Two:
just added. The author calls a Send method in the event, as shown in the Figure 2 code area. The specific message sent by the author of the code here will not be implemented.
The same method, you can add an event for another button "clear".
To use a custom component in a program
Before we designed our own Java components, let's look at how to invoke this component in our own program--a window.
Using the method described earlier, click on the "New Java Class" button on the toolbar to create
How to Use swing to create a BeatBox and swing to create a beatboxFirst, we need to review some content (14:32:14): 1. Swing component
Swing components (component, or component) are more accurate terms than Widgets. They are things placed on the GUI (Graphical User Interface, these components are visible to some users and interact with them, such as Text Field, Button, scrollable, list, and radio button. These components are inherited from java. swing. JComponent;
In Swing, almost all components
GUI (graphics user Interface) graphical UI, which allows the user to look at the interface operation, is more intuitive than the console program and can provide richer functionality.In Java, the support API for GUI operations is generally stored in the java.awt and javax.swing packages, but generally we choose javax.swing because the Swing interface development API is more powerful than AWT.
First, use the window(i) using the JFrame Type Develop
The main idea is simple:1. Set up your own receive Port2. Set the other IP and port3. Sending data and receiving dataHere's the main code:Import java.net.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;p ublic class Qqframe extends JFrame implements runnable{private JTextArea Sendarea = new JTextArea (20,20); Private JTextArea Showarea = new JTextArea (10,20); Private JButton Sendbutton = new JButton ("send")
different objects. This is an object-oriented approach to understanding a graph. An object is a natural way to describe a graphic. Object-oriented programming has been a very successful application in computer graphics.a simple GUIJava's GUI functionality is mainly concentrated in the AWT and swing two packages. AWT is the GUI bottom package. Swing packages are high-rise packages that are easier to port. This will focus more on swing packages.Import javax.swing.*;Import java.awt.*;PublicClasshe
Graphics | Show Basic Concepts!
screen Resolution: The screen area in pixel, such as 800*600
bit Depth: Displays the number of colors. such as 8-bit 256-color, 16-bit 65536-color
refresh rate: unit Hz
a useful Object!
Window object: Represents the screen content and can be viewed as a drawing canvas, such as JFrame is a subclass of window
DisplayMode object: Used to specify screen resolution, bit depth, and refresh rate
GraphicsDevice o
correctly.
JFrame
The JFrame class is a top-level window and a container that allows you to add other components to it, organize them, and present them to the user. It has many other benefits, we first look at the simplest picture:
JFrame actually allows you to not only put the components in there and present them to the user. It is actually the most complex com
Java creates transparent and any shape windows
I. Basic knowledge of Java 2D graphics
Since the release of Java swing, Java's graphics capabilities have been greatly improved. The advanced version of JDK 6 began to support the creation
Jframe with custom shapes can be created based on Java 2D image APIs. When
Java 2 provides the following basic shapes:
Currently, Java provides major operations for 2D graphics, such as cropping and path coverage. Java
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.