Results 1 to 11 of 11
Thread: how to set modal to JFrame
- 02-16-2010, 01:29 PM #1
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
how to set modal to JFrame
I have JFrame and needs to be set modal ..
my below codes already made jf as modal .. but jf doesnot have contents of FrmSerial..
what I missed?
JFrame jf = new FrmSerial();
JDialog jd = new JDialog(jf);
jd.setModal(true);
jd.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
jd.setLocationByPlatform(false);
jd.setLocation(location);
jd.pack();
jd.setVisible(true);
-
- 02-16-2010, 01:49 PM #3
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
could you please advise.. how to use JDialog in NetBeans?..
thanks a lot in advance
-
By reading the tutorial: How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
and the JDialog API: (I"ll let you look it up).
Word of advice: It's fine to use NetBeans as an IDE, but don't use NetBeans for Swing code generation, not unless you want to not learn how to code in Swing.
- 02-16-2010, 05:09 PM #5
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
hi. thanks for the clue, I tried it .. but I need to show dialog with some labels:
ie.
COM Port
Speed
Parity
Databit
Stopbit
I am using below codes, but I only able to show label "COM Port" and I dont know how to display another labels and their combo boxes.. as newbie ..I really need your advise
thanks and regards
Winanjaya
Object[] com = {"Select COM","COM1", "COM2", "COM3"};
Object[] speed = {"Select Speed","1200","2400","4800"};
Object[] parity = {"Select Parity","None","Even","Mark"}
Object[] databit = {"Select Databit","8","7"}
Object[] stopbit = {"Select Databit","1","2"}
String s = (String)JOptionPane.showInputDialog(
this,
"COM Port:",
"Serial COM Setup Dialog",
JOptionPane.PLAIN_MESSAGE,
null,
com,
"Select COM");
-
Two choices and both involve creating a JPanel with all your labels and what nots. Then you can display the JPanel in the JOptionPane similar to what you have right above, or you can put the JPanel into a JDialog, similar to how you'd put a JPanel into a JFrame -- but with a different constructor. The API will give you the legal JDialog constructors.
Please don't forget code tags when posting code here.
- 02-17-2010, 08:46 AM #7
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
could you please advise, where can I download simple example for this? ..
many thanks in advance
Regards
- 02-17-2010, 08:56 AM #8
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Open the link that was posted for you above already in reply #4.
It was posted so that you can open it.
- 02-17-2010, 01:51 PM #9
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
still not working.. what I missed?
Java Code:PnlSerial pnlSerial = new PnlSerial(); JDialog jd = new JDialog(); jd.add(pnlSerial); jd.setModal(true); jd.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); jd.setLocationByPlatform(false); jd.pack(); jd.setVisible(true);
- 02-17-2010, 02:07 PM #10
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What did you expect to happen and hapened instead?
Did you open that link and read the text that appears on the opened page?
- 02-17-2010, 03:30 PM #11
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
Similar Threads
-
How to make a modal JFrame?
By surot in forum New To JavaReplies: 20Last Post: 06-11-2011, 11:31 PM -
How to set Modal to JFrame
By newbiejava in forum New To JavaReplies: 3Last Post: 02-02-2010, 01:49 PM -
How to position a modal dialog box at the center of the screen?
By javaexplorer in forum AWT / SwingReplies: 3Last Post: 01-16-2010, 07:14 PM -
Extract Simulink modal data to Conqat Library
By madarapu in forum EclipseReplies: 0Last Post: 12-22-2009, 12:07 PM -
Can't edit JTextField after modal dialog
By JavaNerd in forum Java AppletsReplies: 0Last Post: 02-07-2008, 09:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks