Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3906 > unrolled thread

Window close & non-resiza

Started by"Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this>
First post2011-04-27 15:47 +0000
Last post2011-04-27 15:47 +0000
Articles 7 — 4 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Window close & non-resiza "Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
    Re: Window close & non-re "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
      Re: Window close & non-re "Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
    Re: Window close & non-re "Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
      Re: Window close & non-re "Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
        Re: Window close & non-re "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
      Re: Window close & non-re "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000

#3906 — Window close & non-resiza

From"Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectWindow close & non-resiza
Message-ID<op.ufguv0z0p9vcmo@macmini.local>
  To: comp.lang.java.gui

I've been hunting on google rather fruitlessly, trying to find out how to  
make a window non-resizable after creating a desktop application in  
Netbeans 6.1. The properties dialog for the frame don't have one that  
refers to the resizable property, so that's no use. I'm not sure how or  
where to put code to set it to non-resizable (if it's possible)

I'm also trying to find out how to catch the Window Close event so that I  
can save my settings to a file.
I can't find an events menu option that refers to it.

The code that usually comes up for a GUI is something like:
-------------------
public class DesktopApplication1View extends FrameView {

     public DesktopApplication1View(SingleFrameApplication app) {
         super(app);

         initComponents();

	//status bar code etc. (don't use this)

      }

	//about box code here - something else I don't use
	//along with all the other gui generated code.
}
-------------------

Then you've got the code that actually calls the applicationview:
-------------------
package desktopapplication1;

import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
  * The main class of the application.
  */
public class DesktopApplication1 extends SingleFrameApplication {

     /**
      * At startup create and show the main frame of the application.
      */
     @Override protected void startup() {
         show(new DesktopApplication1View(this));
     }

     /**
      * This method is to initialize the specified window by injecting  
resources.
      * Windows shown in our application come fully initialized from the GUI
      * builder, so this additional configuration is not needed.
      */
     @Override protected void configureWindow(java.awt.Window root) {
     }

     /**
      * A convenient static getter for the application instance.
      * @return the instance of DesktopApplication1
      */
     public static DesktopApplication1 getApplication() {
         return Application.getInstance(DesktopApplication1.class);
     }

     /**
      * Main method launching the application.
      */
     public static void main(String[] args) {
         launch(DesktopApplication1.class, args);
     }
}
-----------------

Obviously my application has all of the code it needs and is working,  
except for the irritating fact that the window is resizable (and needs to  
act more like a dialog or tool, rather than an editor window!) and I'm  
unable to catch the close event so that I can save my data.

Any help would be appreciated!

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#3909 — Re: Window close & non-re

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Window close & non-re
Message-ID<61563400-7ede-471f-9d55-e583acdb817d@l33g2000pri.googlegroups.com>
In reply to#3906
  To: comp.lang.java.gui
On Aug 6, 11:10=A0pm, "Rexx Magnus" <trash...@uk2.net> wrote:
> I've been hunting on google rather fruitlessly, ...

Perhaps you should try hunting the JavaDocs instead..

> ...refers to the resizable property, ...

=2E.for a set method on that attribute.

--
Andrew Thompson
http://pscode.org/

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3910 — Re: Window close & non-re

From"Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Window close & non-re
Message-ID<op.ufgw3xkbp9vcmo@macmini.local>
In reply to#3909
  To: comp.lang.java.gui
On Wed, 06 Aug 2008 14:49:48 +0100, Andrew Thompson  
<andrewthommo@gmail.com> wrote:

> On Aug 6, 11:10apm, "Rexx Magnus" <trash...@uk2.net> wrote:
>> I've been hunting on google rather fruitlessly, ...
>
> Perhaps you should try hunting the JavaDocs instead..
>

I looked there first, but don't know how to implement it, given that most  
(all in my case) of the GUI creation code is guarded.

>> ...refers to the resizable property, ...
>
> ..for a set method on that attribute.
>

Yes, I know there's a setResizable method for JFrames, but in the context  
of the code that the GUI designer creates, I don't know what to apply it  
to, which is why I'm stuck.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3911 — Re: Window close & non-re

From"Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Window close & non-re
Message-ID<op.ufgx4vvtp9vcmo@macmini.local>
In reply to#3906
  To: comp.lang.java.gui
On Wed, 06 Aug 2008 14:10:38 +0100, Rexx Magnus <trashcan@uk2.net> wrote:

>
> I've been hunting on google rather fruitlessly, trying to find out how  
> to make a window non-resizable after creating a desktop application in  
> Netbeans 6.1. The properties dialog for the frame don't have one that  
> refers to the resizable property, so that's no use. I'm not sure how or  
> where to put code to set it to non-resizable (if it's possible)
>
> I'm also trying to find out how to catch the Window Close event so that  
> I can save my settings to a file.
> I can't find an events menu option that refers to it.
>
> The code that usually comes up for a GUI is something like:
> -------------------
> public class DesktopApplication1View extends FrameView {
>
>      public DesktopApplication1View(SingleFrameApplication app) {
>          super(app);
>
>          initComponents();
>

Right, managed to sort this out:
this.getFrame().setResizable(false);
this.getFrame().setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.getFrame().addWindowListener(new Closer());


In just after the initComponents(); line and added my Closer() routine  
elsewhere. One problem remains now though, when you close the window via  
the close button, this works - except if you're on a Mac and exit via the  
Quit menu (system menu, not one in the frame) it bypasses the routine.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3912 — Re: Window close & non-re

From"Rexx Magnus" <rexx.magnus@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Window close & non-re
Message-ID<op.ufg4gi2mp9vcmo@macmini.local>
In reply to#3911
  To: comp.lang.java.gui
On Wed, 06 Aug 2008 15:20:45 +0100, Rexx Magnus <trashcan@uk2.net> wrote:

> Right, managed to sort this out:
> this.getFrame().setResizable(false);
> this.getFrame().setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
> this.getFrame().addWindowListener(new Closer());
>
>
> In just after the initComponents(); line and added my Closer() routine  
> elsewhere. One problem remains now though, when you close the window via  
> the close button, this works - except if you're on a Mac and exit via  
> the Quit menu (system menu, not one in the frame) it bypasses the  
> routine.

I've tried adding:
app.addExitListener(new myExit());

Just after it, to see if I can get an ExitListener to catch it, using the  
following based on an example in the javadocs:

  class myExit implements Application.ExitListener {
       public boolean canExit(EventObject e) {
          Object source = (e != null) ? e.getSource() : null;
          System.out.println("Canexit");
          Component owner = (source instanceof Component) ?  
(Component)source : null;
          int option = JOptionPane.showConfirmDialog(owner, "Really Exit?");
          return option == JOptionPane.YES_OPTION;
      }
       public void willExit(EventObject e) {
       System.out.println("Willexit");
       }
  }

However, it's not working as far as I can tell. I did try putting it into  
the other class directly as an override to the shutdown() method of the  
application, but couldn't get that to work either.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3956 — Re: Window close & non-re

From"tar" <tar@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Window close & non-re
Message-ID<ymiod3ze1py.fsf@blackcat.isi.edu>
In reply to#3912
  To: comp.lang.java.gui

On Wed, 06 Aug 2008 15:20:45 +0100, Rexx Magnus <trashcan@uk2.net> wrote:

> Right, managed to sort this out:
> this.getFrame().setResizable(false);
> this.getFrame().setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
> this.getFrame().addWindowListener(new Closer());
>
>
> In just after the initComponents(); line and added my Closer() routine
> elsewhere. One problem remains now though, when you close the window
> via  the close button, this works - except if you're on a Mac and exit
> via  the Quit menu (system menu, not one in the frame) it bypasses the
> routine.

To handle those events, I think you will need to use some Mac-specific
coding.  Apple has some examples which show how to handle that in a way
that works (and compiles) even on non-Mac systems that don't use the Mac
specific application adapters.  It relies on using the reflection
mechanism to find the Mac-specific code.

Look at the OSXAdapter sample code:

  <http://developer.apple.com/samplecode/OSXAdapter/index.html>

And for some more Mac-related background:

 <http://developer.apple.com/referencelibrary/API_Fundamentals/Java-fund-date.html>

 <http://developer.apple.com/samplecode/Java/index.html>



-- 
Thomas A. Russ,  USC/Information Sciences Institute

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3914 — Re: Window close & non-re

From"John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Window close & non-re
Message-ID<nospam-7AE7E3.12554706082008@web.aioe.org>
In reply to#3911
  To: comp.lang.java.gui
In article <op.ufgx4vvtp9vcmo@macmini.local>,
 "Rexx Magnus" <trashcan@uk2.net> wrote:

> On Wed, 06 Aug 2008 14:10:38 +0100, Rexx Magnus <trashcan@uk2.net> wrote:
> 
> >
> > I've been hunting on google rather fruitlessly, trying to find out how  
> > to make a window non-resizable after creating a desktop application in  
> > Netbeans 6.1. The properties dialog for the frame don't have one that  
> > refers to the resizable property, so that's no use. I'm not sure how or  
> > where to put code to set it to non-resizable (if it's possible)
> >
> > I'm also trying to find out how to catch the Window Close event so that  
> > I can save my settings to a file.
> > I can't find an events menu option that refers to it.
> >
> > The code that usually comes up for a GUI is something like:
> > -------------------
> > public class DesktopApplication1View extends FrameView {
> >
> >      public DesktopApplication1View(SingleFrameApplication app) {
> >          super(app);
> >
> >          initComponents();
> >
> 
> Right, managed to sort this out:
> this.getFrame().setResizable(false);
> this.getFrame().setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
> this.getFrame().addWindowListener(new Closer());
> 
> 
> In just after the initComponents(); line and added my Closer() routine  
> elsewhere. One problem remains now though, when you close the window via  
> the close button, this works - except if you're on a Mac and exit via the  
> Quit menu (system menu, not one in the frame) it bypasses the routine.

Preferences get flushed automatically, but you should be able to hook 
into the application menu's Quit functionality, as described here:

<http://developer.apple.com/samplecode/OSXAdapter/index.html>

You can determine if you're on Mac OS X at run-time:

<http://developer.apple.com/technotes/tn2002/tn2110.html>

Here's some recent guidelines:

<http://developer.apple.com/referencelibrary/Java/idxDesignGuidelines-dat
e.html>    

-- 
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web