close swing form application

C

column

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
 
A

Andrew Thompson

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.
 
L

Lew

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

"Java" is a trademark, not a proper noun. As Sun explains on
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".
 
M

Mark Space

Lew said:
"Java" is a trademark, not a proper noun. As Sun explains on


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

Similar info here:

http://www.accessmylibrary.com/coms2/summary_0286-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.
 
K

Knute Johnson

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

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


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


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.

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).
 
A

Andrew Thompson

On Jun 20, 9:22 am, Knute Johnson <[email protected]>
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.
 
R

Roedy Green

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.
 
M

Mark Space

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.
 
N

Neil Coffey

Lew said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top