File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Trouble implementing a GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Trouble implementing a GUI" Watch "Trouble implementing a GUI" New topic
Author

Trouble implementing a GUI

John Meehan
Greenhorn

Joined: Oct 28, 2011
Posts: 12

Hi everyone, I'm having some issues with a programming assignment. I'm trying to implement a GUI for some backend code our professor gave us, but I can't seem to get anything to show. Basically the GUI is supposed to have some image manipulation buttons (implemented by the backend) up top, open/save buttons at the bottom, and an image in the center using ImageIcon, which only appears after an image has been opened. I'm trying to make a big JPanel with a Border Layout, and smaller JPanels with FlowLayout to contain the buttons and image icon. When I run the code the JPanel opens, but there's nothing inside. I'm thinking the smaller panels are implementing, but not getting placed into the larger one. Any way you guys could help would be appreciated.



I'm not trying to implement the backend yet, just get the GUI to look correct. The ImageIcon for the center hasn't been implemented yet either, I'm working on that now.
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

You're absolutely right, the smaller panels aren't getting placed into the larger one. You have to add the panel in your SnapShopPanel to the SnapShopPanel itself.

Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
John Meehan
Greenhorn

Joined: Oct 28, 2011
Posts: 12

Ah, I new it was something simple I was missing. How would I go about doing that? Do I just add another pack(); at the end of SnapShopPanel, then call add(SnapShopPanel.panel); instead of add(panel);?
John Meehan
Greenhorn

Joined: Oct 28, 2011
Posts: 12

Actually, I think part of my problem is I'm going too hog wild on the helper classes. I'll try to make things a little more contained, see if that helps.

Edit: nevermind, I've got it now. Instead of adding to panel in SnapShopPanel I should have just added. Oh well, at least things will go quicker now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38756
    
  23
Welcome to the Ranch

I think I shall move this discussion to our GUIs forum.
You ought to consider developing the backend first. Get it working from the command line, then you can put the display on top of it. You should also consider starting very small with GUIs. Your first GUI should be very simple, like this one. Beware: you will have to scroll down to find out what the two errors in that code are. When building a bigger GUI, you should compile and run it after adding every component. That way you will see early that something is wrong, and be able to correct it sooner.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble implementing a GUI