- This topic has 3 replies, 2 voices, and was last updated 18 years, 3 months ago by Riyad Kalla.
-
AuthorPosts
-
kingzaszMemberI am using matisse to build a GUI for a java app I’m working on. I am new to Java, so I am having some problems.
I have a few questions, so here I go:
1) I created a form for my basic GUI, and I put in all my menu items (ex. I have file -> open, file -> properties, etc) Now when I go to work on the JPanel for “file -> properties”, I add it to “other components” instead of creating a new form, correct? Or do I make a form class for everything?
2) I added a “JFileChooser” to “other components”, and I’ve been trying to link the file -> open to the JFileChooser, so when someone goes file -> open, it opens the file choser dialog box. How would I do that?
3) I would also like to show only 1 file type, but I can probably figure that out myself…
Thanks in advance!
Riyad KallaMember1) You will create a new form and it sounds like you probably want a JDialog Form (since it will popup after the person clicks properties)
2) Right click on your Open menu item, go to Events and add an action -> actionListener event to pop open the dialog. There are visual ways to connect the two using the designer but I usually code the event handlers by hand in this fashion instead.
3) Try the down arrow in the package explorer and then Filters… I don’t know if it will give you what you want though.
kingzaszMemberOk thanks! Got most the stuff figured out.
I’m still confused with the forms. If I create a different form for everything, every class will have its own main(String args) method. Do I just delete that from all but my main GUI window class?
I’ve also created an action listener to listen for a menu item to be clicked on, but what code would you use to pop up a JTabbedPane? JFileChooser has methods to open the dialog boxes, but I’m not sure about JTabbedPane. I though setVisible would work, but it didn’t…
Sorry for all the questions, thanks in advance
Riyad KallaMemberI’m still confused with the forms. If I create a different form for everything, every class will have its own main(String args) method. Do I just delete that from all but my main GUI window class?
Basically, that is just put there so it’s easier for you to test your form by clickng “Run”, you definately only need one.
I’ve also created an action listener to listen for a menu item to be clicked on, but what code would you use to pop up a JTabbedPane? JFileChooser has methods to open the dialog boxes, but I’m not sure about JTabbedPane. I though setVisible would work, but it didn’t…
I don’t understand this question really. JTabbedPane is a component, so it has to be added to a top level container before it can be shown (like a JDialog, JWindow, JFrame) or inside of a JPanel that is already inside of a top level container. Maybe explain what you are trying to do and I will see if I can help.
-
AuthorPosts