hi i am using jframe,
i have a main() class on login page, when people logon than i use
adminForm = new AdminForm();
adminForm.setVisible(true);
this.dispose();
now i can set visible my adminForm, i have an edit and add button on the adminForm, when people push the add button, i want to open new frame
yAdmin = new Add();
yAdmin.setVisible(true);
now i want people just edit yAdmin, people can see the adminForm but they cant touch it before the yAdmin closed.
Instead of JFrame
use a JDialog
for yAdmin
, make it modal with adminForm
as its owner:
yAdmin = new JDialog(adminForm,true);
or let Add
extend JDialog accordingly.
JFrame frame = new JFrame ();
frame.setAlwaysOnTop (true);
or you can use modal dialogue:
JDialog dialog = new JDialog ();
dialog.setModal (true);
dialog.setAlwaysOnTop (true);
dialog.setModalityType (ModalityType.APPLICATION_MODAL);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.