Results 1 to 10 of 10
Thread: About Forms Properties
- 04-29-2010, 09:27 AM #1
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
About Forms Properties
Hi,
I have a form called frmMain i want this form to be a parent form. Then I created 2 button (button1 and button2). When button1 is click I want another form to show this if an internal form (a MDI child). then When button2 is click I want form2 (another MDI Child) to show and go on top of form1.
my questions are:
1. Is this the right way to make Parent and Child forms in java?
2. How can I set form on top of another form?
3. How can I divide the form? What I am trying to do is on main form's (parent form) left side is an internalform or frame and inside that is buttons. On the right side of Main form is Internal Form/s that shows and uload depends on the users click on buttons on left side.
Thanks and Sorry if my english is bad,
gejeLast edited by mine0926; 04-29-2010 at 09:36 AM.
- 04-29-2010, 09:38 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Will CardLayout help?
- 04-29-2010, 10:11 AM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
I do not know how to do CardLayout... It is not in the properties and when I type ".cardlayout" it show nothing.
Thanks for your reply.
- 04-30-2010, 04:25 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
I found CardLayout. Now I am trying to work with it. From class frmMain I declare CardLayout.
then set some properties base on this site:http://www.java-tips.org/java-se-tip...ardlayout.htmlJava Code:public class frmMain extends java.awt.Frame{ CardLayout cl = new CardLayout();
And here is the code when user click the buttonJava Code:public frmMain() { initComponents(); this.setExtendedState(MAXIMIZED_BOTH); LeftFrame.setSize(LeftFrame.getWidth(), this.getHeight()); //The Left part of the JFrame jPanel1.setSize(this.getWidth() - LeftFrame.getWidth(), this.getHeight() - LeftFrame.getHeight()); jPanel1.setLayout(cl); //HERE jPanel1.add(frmMaterials, 1); //HERE -- I try frmMaterials as a JPanel and Internal Frame component, I also try the index as string ("1") and as Integer (1) jPanel1.add(frmCustomer, 2); //HERE -- I try frmCustomer as a JPanel and Internal Frame component }
But, there is an error in compile. Mostly the error is in the GENERATED CODE, I think I missing something or a lot. :)Java Code:private void btnMaterialsMouseClicked(java.awt.event.MouseEvent evt) { cl.first(frmMaterials); cl.show(jPanel1, "1"); } private void btnCustomerMouseClicked(java.awt.event.MouseEvent evt) { cl.first(frmCustomer); cl.show(jPanel1, "2"); }
Please guide me.
Thanks in Advance,
gejeLast edited by mine0926; 04-30-2010 at 04:28 AM.
-
Look again at the CardLayout tutorial as you're using it all wrong. For one, you need to use a String as the second parameter when adding components to a container that uses card layout. Next of all, you are using the first method inappropriately and with the wrong parameter. Why are you calling it at all?
Edit: you also seem to be trying to mix AWT (Frame) with Swing (JPanel) components, and this is something that in general shouldn't be done unless you have a very good reason to do so (you don't). Best of luck.Last edited by Fubarable; 04-30-2010 at 04:45 AM.
- 04-30-2010, 05:20 AM #6
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Okay. I already figure it out. Thanks for pointing me to CardLayout.
My first mistake is I change
import javax.swing.JFrame.*; to import java.awt.Frame.*;
that's why there are errors in generated code.
Second:
cl.first(frmMaterials); should be cl.first(jPanel1);
It does not matter if I use JPanel or JInternalFrame for CardLayout. Both components are working great.
Is there a way or is it possible to show both JPanel or InternalFrame?
Because in CardLayout when I click button1 it shows form1 then when i click button2 it shows form2 and hides Form1
Is there any way to still show Form1 while Form2 is Active but they are still MDI Child forms.
*
* Hope you understad what I am trying to say...
Thank you very much,
geje
- 04-30-2010, 06:54 AM #7
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
I was able to figure the awt.Frame.* and the cl.first(jPanel1).
But I dont know what you mean by:
Thanks,Next of all, you are using the first method inappropriately and with the wrong parameter. Why are you calling it at all?
geje
- 04-30-2010, 06:59 AM #8
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
I was able to figure the awt.Frame.* and the cl.first(jPanel1).
But I dont know what you mean by:
I just follow the code on the link I said before. Also I cannot see CardLayout in Palette Form if that is what you meanNext of all, you are using the first method inappropriately and with the wrong parameter. Why are you calling it at all?
Thanks,
geje
- 04-30-2010, 12:56 PM #9
- 05-01-2010, 03:04 AM #10
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Similar Threads
-
Use multiple forms
By coco in forum Java AppletsReplies: 2Last Post: 06-14-2010, 05:14 AM -
Switch between forms.
By OMFGITSROHIT in forum AWT / SwingReplies: 9Last Post: 03-13-2010, 07:47 PM -
Forms in MultiPageEditorPart
By darie20 in forum SWT / JFaceReplies: 0Last Post: 02-01-2010, 12:22 PM -
How to make online jsp forms from Microsoft word forms in java
By jiten.mistry in forum Advanced JavaReplies: 2Last Post: 04-28-2008, 10:56 AM -
Forms in jsp
By bbq in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-05-2007, 04:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks