Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > close swing form application

Reply
Thread Tools

close swing form application

 
 
column
Guest
Posts: n/a
 
      06-19-2008
Hello,

What is the correct way to close java visual aplication based on swing
components. I would like to do this using jMenuItem. I use NetBeans
IDE

Thank you
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-19-2008
On Jun 20, 3:24*am, column <column.col...@gmail.com> wrote:

> What is the correct way to close java visual aplication based on swing
> components.


Java and Swing are proper names, hence upper
case first letter.

Please be very specific about these matters,
instead of 'talking like your IDE'.

>..I would like to do this using jMenuItem.


There is no such class in the J2SE. Did you
mean a JMenuItem?

>..I use NetBeans IDE


Yes.. If you used *Java* you would probably
already have found the JavaDocs, and
answered your own question.

If you mean JFrame/JMenuItem..
- add an ActionListener to the menu item.
- In the actionPerformed(ActionEvent) method,
call JFrame.setVisible(boolean).
- Since the default behaviour of a JFrame is to
hide it when the user clicks the 'close button'
in the JFrame, you will also need to call the
setDefaultCloseOperation(int) with an appropriate
value.

--
Andrew Thompson
http://pscode.org/
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      06-19-2008
Andrew Thompson wrote:
> Java and Swing are proper names, hence upper
> case first letter.


"Java" is a trademark, not a proper noun. As Sun explains on
<http://www.sun.com/policies/trademarks/>
> Trademarks are adjectives.
> Use them, at least in your initial and most prominent references and otherwise as needed for clarity,
> with generic nouns that identify a Sun product, technology, program, or service.
> For example, use "Java technology" or "the Solaris operating system" instead of using "Java" or
> "Solaris" on its own.


However, you are absolutely correct that "Java", as a trademark, must
be spelled with an upper-case "J".

--
Lew
 
Reply With Quote
 
Mark Space
Guest
Posts: n/a
 
      06-19-2008
Lew wrote:
> Andrew Thompson wrote:
>> Java and Swing are proper names, hence upper
>> case first letter.

>
> "Java" is a trademark, not a proper noun. As Sun explains on
> <http://www.sun.com/policies/trademarks/>
>> Trademarks are adjectives.
>> Use them, at least in your initial and most prominent references and otherwise as needed for clarity,
>> with generic nouns that identify a Sun product, technology, program, or service.
>> For example, use "Java technology" or "the Solaris operating system" instead of using "Java" or
>> "Solaris" on its own.

>
> However, you are absolutely correct that "Java", as a trademark, must
> be spelled with an upper-case "J".
>
> --
> Lew


Similar info here:

http://www.accessmylibrary.com/coms2...6-21206027_ITM


"Trademarks are proper adjectives, never nouns, and at least once in
every context in which they appear trademarks should be followed by, and
modify, the generic names of the goods and services they identify."

Note that proper adjectives are capitalized, just like proper nouns.
Eg., "the English language." Good stuff, I didn't know that trademarks
are "proper adjectives" and I consider myself a bit of an English
language maven too.
 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      06-19-2008
Andrew Thompson wrote:
> On Jun 20, 3:24 am, column <column.col...@gmail.com> wrote:
>
>> What is the correct way to close java visual aplication based on swing
>> components.

>
> Java and Swing are proper names, hence upper
> case first letter.
>
> Please be very specific about these matters,
> instead of 'talking like your IDE'.
>
>> ..I would like to do this using jMenuItem.

>
> There is no such class in the J2SE. Did you
> mean a JMenuItem?
>
>> ..I use NetBeans IDE

>
> Yes.. If you used *Java* you would probably
> already have found the JavaDocs, and
> answered your own question.
>
> If you mean JFrame/JMenuItem..
> - add an ActionListener to the menu item.
> - In the actionPerformed(ActionEvent) method,
> call JFrame.setVisible(boolean).
> - Since the default behaviour of a JFrame is to
> hide it when the user clicks the 'close button'
> in the JFrame, you will also need to call the
> setDefaultCloseOperation(int) with an appropriate
> value.
>
> --
> Andrew Thompson
> http://pscode.org/


An alternate option to Andrew's excellent suggestion, is to dispose()
all windows and the program should exit on its own (assuming there are
no other threads running that are keeping it going).

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      06-20-2008
On Jun 20, 9:22*am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
...
> An alternate option ... is to dispose()
> all windows and the program should exit on its own (assuming there are
> no other threads running that are keeping it going).


'Should', yes. But I have found a number of
situations where the JRE/Sun APIs tend to make
'go on forever' threads. JavaSound is (or at
least was) notorious for it.

As a safeguard, I would also recommend (in
addition to Knute's excellent alternative)
explicitly calling System.exit(int) on the
'root' JFrame.

--
Andrew Thompson
http://pscode.org/
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-20-2008
On Thu, 19 Jun 2008 10:24:24 -0700 (PDT), column
<> wrote, quoted or indirectly quoted someone
who said :

>What is the correct way to close java visual aplication based on swing
>components. I would like to do this using jMenuItem. I use NetBeans
>IDE


I posted code yesterday for Hybrid for AWT and Swing that has the
shutdown code.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      06-21-2008
On Jun 21, 1:47*pm, Lew <l...@lewscanon.com> wrote:
...
> However, in the vernacular "Java" is a proper noun. *


However, in the ocean "Java" is an island.
<http://en.wikipedia.org/wiki/Java>

It still irritates me that American(?) slang for
coffee, and then Sun, effectively stole the name
of an existing place.

>.. *Yet Sun has refrained from suing us over that.


Maybe the island should sue ..someone.

--
Andrew T.
 
Reply With Quote
 
Mark Space
Guest
Posts: n/a
 
      06-21-2008
Lew wrote:
> Mark Space wrote:
>> Similar info here:
>>
>> http://www.accessmylibrary.com/coms2...6-21206027_ITM


>
> However, in the vernacular "Java" is a proper noun. I don't think I see
> one place in a hundred that uses the word "Java" and "at least once in
> every context ... [is] followed by ... the generic name" of whatever.
> Yet Sun has refrained from suing us over that.
>


It should probably be "the Java language" but you're right, Sun seems to
use it as a noun. Sun also doesn't list Java with a TM symbol on their
front page, you have to click on a link to see their list of trademarks.

The link above talks about the importance of using trademarks properly,
lest the owner loose them. ("Ping pong" ... Wikipedia doesn't even list
an entry for the trademark name.) I can't help but think Sun maybe
flirting with disaster to not use their mark properly, but I guess they
have their own legal council.
 
Reply With Quote
 
Neil Coffey
Guest
Posts: n/a
 
      06-24-2008
Lew wrote:
> Mark Space wrote:


>> Note that proper adjectives are capitalized, just like proper nouns.
>> Eg., "the English language." Good stuff, I didn't know that
>> trademarks are "proper adjectives" and I consider myself a bit of an
>> English language maven too.

>
> However, in the vernacular "Java" is a proper noun. I don't think I see
> one place in a hundred that uses the word "Java" and "at least once in
> every context ... [is] followed by ... the generic name" of whatever.
> Yet Sun has refrained from suing us over that.


Linguists don't have a single, clear-cut, universally agreed
upon definition of "adjective" (let alone "proper adjective").
If there was ever a court case involving whether a given usage
constituted a "proper adjective" and there was a syntactician
present (which clearly there wasn't when this law was drawn up),
then I think just about anything could get argued.

FWIW, my personal viewpoint is that "Java" pretty much has
to be a noun. In cases such as "Java language", "Java" is still
a noun -- and you have a noun+noun compound. (Consider, for example,
that it's not grammatical to say "*the Java language and the C++ one",
but it is grammatical to say "the object-oriented language and the
procedural one".)

Neil
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a TCP socket? (TCPSocket#close doesn't close it) IƱaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
Why not using javax.swing.event with swing? S.T Java 2 05-25-2007 12:10 AM
javax.swing.Popup, javax.swing.PopupFactory lizard Java 0 01-30-2006 09:34 PM
Swing Model Classes Updating Swing Components on a Thread Other Than AWT mkrause Java 0 05-06-2005 04:32 PM
Java 1.2 Swing vs. Java 1.5 Swing Big Daddy Java 2 04-16-2005 01:14 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57