• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Code to restore jPane from minimized down in toolbar?

 
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I manually minimize my GUI Pane ..... what is the java code to restore it back from the toolbar?
Untitled-77.JPG
[Thumbnail for Untitled-77.JPG]
Untitled-8.jpg
[Thumbnail for Untitled-8.jpg]
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can call the setState() or setExtendedState method of the owning Frame. setState() can only accept a NORMAL or ICONIFIED as a parameter whereas setExtendedState() accepts the following options:

The state is represented as a bitwise mask.
NORMAL - Indicates that no state bits are set.
ICONIFIED
MAXIMIZED_HORIZ
MAXIMIZED_VERT
MAXIMIZED_BOTH - Concatenates MAXIMIZED_HORIZ and MAXIMIZED_VERT.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having told you how to programmatically restore the iconified window I've realised I may not have fully understood what you are trying to do.
If the window has been manually iconified how will the program know when it needs to restore the GUI to a normal size, ie is it waiting for a trigger from an external source, using a timer or something else?

BTW if you need some to detect that the window has been iconified you can add a WindowStateListener and call the getNewState() method on the WindowEvent object.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!  .... I don't want to come back full screen! (see the size jPane is in now)... just want to return back as the size before I dropped it down to the toolbar.   The event that triggers this is a listener on the serial port and a parser seeing someone dialed "911".   Only then does the jPane need to "reappear" from the toolbar to display this notice.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still lost!   ..... I'm thinking that since I built my jFrame with Netbeans GUI builder, I have to do something within the generated code for this JFrame.

My event is created when A class sees a "911" call (String bb = "911" from a serial port ;  .... if (e911.equals(bb))  I do several things if true ,
set certain labels true, send an email of this event, etc.

I need to add code to this list of things to do, that will bring back my ICONIFIED JFrame so I can again see this JFrame.

I have no clue as to how to do this  : (  
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried calling setState() or setExtendedState() passing in the Frame.NORMAL constant.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any coding as such ..... the IDE say it cant find the JFrame!

I dont now how to make referance to my builder generated JFrame.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..... the class that this JFrame is in is "MainDisplay extends javax.swing.JFrame"
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
................. or with package name  "the class that this JFrame is in is "myNewSMDR.MainDisplay extends javax.swing.JFrame"
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..... still not working!  I'm lost here  :  (
 
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know if you're still stuck on this but is this what you're looking for?
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankyou! .... but I have several scripts like this.  The problem is this,  I have a working app where the GUI was built in Netbeans IDE builder. Should my running app been dropped down to the toolbar (Iconified I believe this is the term) and an event comes in (911 dialed call) a list of things to do is executed. In this list I need to bring back into view on the screen my apps GUI. I don't no how to make this request in code to my existing JDesktopPane in Netbeans.
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not familiar with NetBeans. Line 63 in my example is the key to deiconifying the frame. Any reason why you can't incorporate that into your project?
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..... 63??  :  (
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..... see in my code (line 7) thats as close I can can get, but that doesn't work  :  (
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
setState( Frame.NORMAL );

This works on JFrames. Perhaps it won't work for a JDesktopPane. If you want to iconify and the deiconify the whole program this should work. If you want to do that for a sub-pane then it won't.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PS: I'm just a beginner java  :  )
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're talking about this line, it is not proper Java syntax and won't compile, as I'm guessing you found out.

We're all beginners at one time. No problem. However I think your requirements will be a little tricky for a beginner.

When you create a Swing GUI it creates its own thread: Event Dispatch Thread (EDT). This thread is for handling GUI events. Your 911 event should probably end up in another thread that you create, and when it finds a 911 event it should call setState() on your JFrame object.

Is this making any sense?
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What instigates a 911 event?
Are you polling for a 911 event or are you using blocking IO to wait for it?
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
setState( Frame.NORMAL );     ..... that in of itself is not working  :  (    Isnt there some directive that goes before this as this code is in another class by itself requesting an action to my GUI in another class?
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a serial port listener is attached and listens for a string of data to come in,  when I do get this string, I parse this string for the digits dialed from the guest room telephone, Then I "if" is dialed number "911" ? .... if true, do my list of things to do.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.... the problem is if the GUI was dropped down to the toolbar(still running) I cant see the GUI when an emergency 911 call is detected and then displayed in my GUI JDesktopPane.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..... I want this JDesktopPane to pop back up!!
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My example extended JFrame so it had an implicit JFrame to operate on. If you have a reference to a JFrame then you'd write

 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the "event" conditions all are already cared for ,,,,on event, turns on warning labels,stores to derby database, sends out an email.... this all works fine ..... just cant see all this because my GUI is still down in the toolbar hidden.
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a JFrame object that contains your JDesktopPane object?

In your original screen snapshot I don't quite see where you have a JDesktopPane and JInternalFrames. What would be an example of one of your internal frames?
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rick Liberato wrote:

This code, does it reside inside a class that extends a JFrame? Does it have access to a reference to a JFrame or a subclass of JFrame?
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
....i'm lost!   am I "de-Iconifing" (pop back up with code) a "Pane" , "Frame" or a "JDesktopPane" ???  :  (
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rick Liberato wrote:....i'm lost!   am I "de-Iconifing" (pop back up with code) a "Pane" , "Frame" or a "JDesktopPane" ???  :  (



Pane: you can't iconify or minimize it

Frame: you can iconify this (minimize) and the icon ends up on the OS task-bar/tool-bar.

JDesktopPane: you can't iconify this directly, you can only iconify the JFrame that holds it.

JInternalFrame: you can minimize this but not iconify it.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is where I get stuck

Does it contain a JFrame reference or is it perhaps extending a JFrame? What exactly is a MainDisplay?

Is this code really Swing? I don't see any references to any Swing objects, e.g. JButton, JLabel, JTable, JTextField, etc.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.... these are the two significant classes
 
Carey Brown
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I guess that's all I have to offer. This doesn't look like any Swing I'm familiar with, perhaps it's a NetBeans thing or maybe a framework that your project is utilizing.
Good luck.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank-you! ... for your good help!
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do those two classes talk to each other?
I can't see a reference to either one in the other.
That could, of course, be down to the Netbeans generated code.
 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...... Here:  MainDisplay calling up TwoWaySerialComm

 
Rick Liberato
Ranch Hand
Posts: 104
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
.... yes!  ....both have "main" classes. MainDisplay is the lead class.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So... you have a JFrame object which does all the GUI business for your application. And then it creates a TwoWaySerialComm object and calls its connect() method; after that it doesn't have a reference to that object any more. So it follows that the TwoWaySerialComm object knows nothing about your GUI either. But your design appears to want something to happen to the GUI when a particular event happens in the TwoWaySerialComm object, which is impossible since neither of the two knows about the other.

If I have understood that right, the easiest way to move forward would be for the GUI to add some kind of listener to the TwoWaySerialComm object, so that it gets notified of events happening in that class. Does TwoWaySerialComm support listeners?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic