• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble implementing a GUI

 
John Meehan
Greenhorn
Posts: 12
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Meehan
Greenhorn
Posts: 12
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50175
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic