Form Load Form

Source: Internet
Author: User

The duplicate form Add button to create the Getset method on the toolbar of the form you want to replicate to get the toolbar object on the hosted form

1.

Public JToolBar getjToolBar1 () {
return jToolBar1;
}

public void SetjToolBar1 (JToolBar jToolBar1) {
This.jtoolbar1 = jToolBar1;
}

2.//Calling the Add button method in the constructor method

Public Dgeditdeclarant () {
Initcomponents ();
Pndeclarant = new Pndeclarant ();
AddButton ();
This.add (Pndeclarant, Java.awt.BorderLayout.CENTER);
}

3.//Add button

private void AddButton () {
JToolBar TB = PNDECLARANT.GETJTOOLBAR1 ();
Jbbutton btn = new Jbbutton ();
Btn.seticon (New Javax.swing.ImageIcon (GetClass () getresource ("/com/bsw/esp/client/images/35_ OK. png")); noi18n
Btn.settext ("OK");
Btn.setauthorityid ("");
Btn.setborderpainted (FALSE);
Btn.setfocusable (FALSE);
Btn.sethorizontaltextposition (0);
Btn.seticontextgap (0);
Btn.setverticaltextposition (3);
Btn.addactionlistener (new ActionListener () {
@Override
public void actionperformed (ActionEvent e) {
Selectdata = (declarant) Pndeclarant.gettablemodel (). Getcheckedrow ();
if (Selectdata = = null) {
Joptionpane.showmessagedialog (RootPane, "Please select data");
Return
} else {
IsOk = true;
Dispose ();
}
}
});
Tb.add (BTN);
}

4.//calling a hosted form

Dgeditdeclarant dg = new Dgeditdeclarant ();
Dg.setvisible (TRUE);
if (Dg.getisok ()) {
Declarant declarant = Dg.getselectdata ();
if (declarant! = null) {
Initdeclarant ();
ItemProperty it = new ItemProperty (Declarant.getcode (), Declarant.getname ());
Cbbdeclarant.setselecteditem (IT);
}
} else {
Initdeclarant ();
}

Hosting form code

public class Dgeditdeclarant extends Jdialogbase {

Private Pndeclarant pndeclarant;
Private Boolean isOk = false;
Private declarant Selectdata;

/**
* Creates new form Newjdialog
*/
Public Dgeditdeclarant () {
Initcomponents ();
Pndeclarant = new Pndeclarant ();
AddButton ();
This.add (Pndeclarant, Java.awt.BorderLayout.CENTER);
}

@Override
public void setvisible (Boolean b) {
if (b) {
super.setvisible (b);//to change body of generated Methods, choose Tools | Templates.
}
}

private void AddButton () {
JToolBar TB = pndeclarant.getjtoolbar1 ();
Jbbutton btn = new Jbbutton ();
Btn.seticon (New Javax.swing.ImageIcon (GetClass () getresource ("/com/bsw/esp/client/images/35_ OK. png")); noi18n
Btn.settext ("OK");
Btn.setauthorityid ("");
Btn.setborderpainted (FALSE);
Btn.setfocusable (FALSE);
Btn.sethorizontaltextposition (0);
Btn.seticontextgap (0);
Btn.setverticaltextposition (3);
Btn.addactionlistener (New ActionListener () {
@Override
public void actionperformed (ActionEvent e) {
Selectdata = (declarant) Pndeclarant.gettablemodel (). Getcheckedrow ();
if (selectdata = = null) {
Joptionpane.showmessagedialog (rootpane, "select data");
return;
} else {
IsOk = t Rue
Dispose ();
}
}
});
Tb.add (BTN);
}

/**
* This method was called from within the constructor to initialize the form.
* Warning:do not modify this code. The content of this method was always
* Regenerated by the Form Editor.
*/
@SuppressWarnings ("Unchecked")
<editor-fold defaultstate= "collapsed" desc= "Generated Code" >
private void Initcomponents () {

Setdefaultcloseoperation (Javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

SetBounds (0, 0, 500, 373);
}//</editor-fold>

Public Boolean Getisok () {
return isOk;
}

public void Setisok (Boolean isOk) {
This.isok = isOk;
}

Public declarant Getselectdata () {
return selectdata;
}

public void Setselectdata (declarant selectdata) {
This.selectdata = Selectdata;
}

Variables declaration-do not modify
End of variables Declaration
}

Form Loading form

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.