• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

ComboBox GUI

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble with this GUI. I am trying to use a gridbaglayout for all the components in the center panel, although, I am not sure my understanding of gridbaglayout is the best. I can get this code to show a panel but nothing shows up on the panel. If anything is out of place or commented out it's all a part of me trying to debug and play with the code.





 
Ranch Hand
Posts: 74
5
Eclipse IDE Python Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your class BaseballLine extends JFrame yet you create a separate JFrame "jfrm" inside your class and add every GUI component to it. In the end though you invoke setVisible() on your BaseballLine instance and not on jfrm which has all the components added to it. For a start you could remove your declaration of "jfrm" and replace all occurrences of it with "this". That should solve your problem. I would also consider refactoring your code. You have a lot of copy paste elements which makes it hard to read and hard to enhance later on.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would go the other way and not have your BaseballLine class extend JFrame. There's normally no need to extend JFrame as you are not actually extending the functionality of the class, just adding things to it. Extending it is a bit like extending ArrayList simply to populate it with entries.

Just use the jfrm instance, and display that. You might want to make it an instance variable of the BaseballLine class rather than a local variable, though that may not be necessary.
 
Dale Herring
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea thanks, I didn't realize I was instantiating the JFrame again and that's what was screwing me. I've got a few other issues to clean up with my actionlisteners and layouts but you really helped me out.
 
Right! We're on it! Let's get to work tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic