Jar Advanced (bottom)

Source: Internet
Author: User

The basic usage of the jar I saw from the last article doesn't seem to make anyone feel that the presence of the jar is a new beginning for the application of applets. But you may have read the following, you will be slightly agree with the jar.

Many of the Java enthusiasts who tried to do applets in JBuilder know that the applet's interface layout is a relatively complicated problem, far from such as VB inside the control into the interface so simple, even with the most "advanced" grid bag layout manager, To put more than one control on it, you need to adjust and adjust it. And even in the jbuilder inside still see can accept, but in the browser may be another look, of course, there are good, when after all, it takes time and experience, but in JBuilder if the backplane does not select Grid Bag layout Manager Instead of XY layout, it's really easy to put the control on top of it. Unfortunately, the XY layout called the class is com.borland.jbcl.layout below, is written by the Borland company itself, it is obvious that the written applet is easy to write, the pain of the application, because it is impossible to just recognize the jdk1.0 of IE to know Borland write class , then really only write to yourself, now with the jar, you will find that if you follow the steps below, it is easy to let others see you write applets containing non-JDK standard classes.

We add a few more buttons to the first step of the screen. First the layout of the backplane from the grid bag changed to XY, and then add a few buttons, the button right click event also set to pop-up menu, the following is the source program, in the JBuilder generated code to simplify, remove the temporary code and some comments , but guaranteed to work,

Package test1
Import java.awt.*;
import java.awt.event.*;
import java.applet.*;
Import com.borland.jbcl.layout.*;
public class Applet1 extends Applet {
Boolean isstandalone = false;
PopupMenu popupMenu1 = new PopupMenu ();
MenuItem menuItem1 = new MenuItem ();
MenuItem menuItem2 = new MenuItem ();
MenuItem menuItem3 = new MenuItem ();
Button button1 = New button ();
Xylayout xYLayout1 = new Xylayout ();/* Panel changed to Xylayout layout, using a non-JDK standard class */
Button button2 = New button ();
Button Button3 = New button ()/* Add three buttons */
public void init () {
Menuitem1.setlabel ("1");
Menuitem2.setlabel ("2 ");
Menuitem3.setlabel ("3");
Button1.setlabel ("Button1");
Button1.addmouselistener (New Java.awt.event.MouseAdapter () {
public void mousepressed (MouseEvent e) {
Button1_mousepressed (e);
}
});
This.setlayout (XYLAYOUT1);
Button2.setlabel ("Button2");
Button2.addmouselistener (New Java.awt.event.MouseAdapter () {
public void mousepressed (MouseEvent e) {
button1_mousepressed (e);
}
});
Button3.setlabel ("Button3");
Button3.addmouselistener () The right key event for the new Java.awt.event.MouseAdapter () {/* three buttons is a */
public void mousepressed ( MouseEvent e) {
button1_mousepressed (e);
}
});
Popupmenu1.add (MENUITEM1);
Popupmenu1.add (MENUITEM2);
Popupmenu1.add (MENUITEM3);
This.add (button1, New Xyconstraints (155, 5,-1,-1));
Add (POPUPMENU1);
This.add (button2, New Xyconstraints (49, 94, 101, 32));
This.add (Button3, New Xyconstraints (235, 92, 98, 36));
}
void button1_mousepressed (MouseEvent e) {
int mods=e.getmodifiers ();
if (mods& Inputevent.button3_mask)!=0
{
Popupmenu1.show (Button1,e.getx (), e.gety ());
}
}
}

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.