• Post Reply Bookmark Topic Watch Topic
  • New Topic

When I close out my singleton JFrame and then open it again, the Components are gone  RSS feed

 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made UpdateInmateDisplayer a Singleton so that I could access it from the private class ButtonHandler. It works to display the first inmate's number on the screen but when I close out the window and click the Book Inmate button in CurInmatesDisplayer again, it only shows a blank window. I've tried adding the components again from the ButtonHandler in CurInmatesDisplayer but it doesn't work.

I've been working on this for a couple hours and I'm at a loss for what to do. It's a final project due in 2 days so any help with this issue is greatly appreciated.

 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought I attached files to this but I don't see them so I'll copy and paste them here.

CurInmatesDisplayer



UpdateInmateDisplayer.java



ContentDisplayer.java
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Bob,

I must say: this whole code looks very complicated to me. Can you tell us, in simple words,
what all these classes do (or are supposed to do), and how they interact?
What is your main frame and where can I find it? Which 'public static void main(..)' is getting called?

Greetz,
Piet
 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the uml which may not be completely updated but I tried my best to update the important parts of it before posting it here

https://creately.com/diagram/i1timf8k1/tlTcFfW9C6CS8qbEbNAT4djBoOc%3D

These are the classes I'm using right now and I have not even created the other classes:

UserInterface: main window that contains the JTabbedPane

ContentDisplayer: I might make this class abstract. I don't actually instantiate it but the purpose of it is to accept a JPanel in the constructor as a parameter, and add a border layout to it and JPanels for north, south, east and west. All my GUI classes besides UserInterface and Screen inherit from ContentDisplayer, directly or indirectly.

Screen: this is a singleton that extends textarea and is used by other classes to write to the screen and clear it.

ContainerDisplayer: I use this to display a Screen in the center. The Screen is used to display a Map. (I haven't bothered trying to do released inmates. I'm only working on displaying a table with all current inmates for now. But I'm doing that with the CurInmatesDisplayer class that inherits from this one.)

CurInmatesDisplayer: This is used to write a table of all current inmates to the screen. It also has a book button which brings up a new window where you can add inmate information. This window is an instance of UpdateInmateDisplayer.

UpdateInmateDisplayer: extends Content Displayer and lets you input information about a new inmate. It is passed a JFrame and components used to add a new inmate are added to the JFrame. Pressing the Book Inmate button here creates a new inmate.

Inmate: The inmates are created and displayed on the screen. I'm also supposed to update them but I'll get to that later (if I have time)

Prison: Singleton that holds the map of current inmates. Holds other containers as well but Current inmates is what I'm concerning myself with right now. I may also use this later to write to and read from files but haven't gotten to that yet.

Sorry about leaving in my commented out non-working code with the other files. I deleted that this time.


Sheriff_booking_system.java (Main)



UserInterface.java

 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, I realized that the title is misleading because UpdateInmateDisplayer does not extend JFrame. It just accepts a JFrame as a parameter.
 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UPDATE: Fixed the problem by making it not a singleton. I still let it have a reference to itself though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!