473,503 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

public JMenu add(JMenu c)

-
there is a "public JMenu add(JMenu c)" method in JMenuBar.

i'm not good in programming and am wondering whether someone can provide
me with a clarification why Sun chooses to return a JMenu, rather than a
boolean or simply a void? returning a void won't be useful in
determining whether it is added hence that is understood.

in what scenario does returning the JMenu?
Jul 17 '05 #1
1 1831

"-" <no****@hoem.com> wrote in message
news:42********@news.starhub.net.sg...
there is a "public JMenu add(JMenu c)" method in JMenuBar.

i'm not good in programming and am wondering whether someone can provide
me with a clarification why Sun chooses to return a JMenu, rather than a
boolean or simply a void? returning a void won't be useful in determining
whether it is added hence that is understood.

in what scenario does returning the JMenu?


It's just a design decision. Returning a boolean for success or failure
is more of a C/C++ style of programming. In Java, it's typically better to
throw an exception if a failure occured.

As for why not returning void, if I designed the JMenuBar class, I'd
probably make it void. Still, I could see how it might be useful to have it
return the JMenu just added. Compare the following too pieces of code:

JMenu theJMenuThatIWantToSave = createSomeJMenuObject();
someInstanceOfJMenuBar.add(theJMenuThatIWantToSave );

.... versus ...

JMenu theJMenuThatIWantToSave =
someInstanceOfJMenuBar.add(createSomeJMenuObject() );

- Oliver
Aug 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2846
by: Alex Ostrikov | last post by:
Hello, all !!! I have JFrame with JTabbedPane and JMenu. Each tab of JTabbedPane has JApplet on it. And when I choose any menu item (File -> DoSmth), my JApplet covers the part of menu so...
0
1896
by: dawntildusk | last post by:
I am trying to get cut and paste to work from menu. Below is code I have can someone point me where I am going wrong I have the same problem with File selection to open and save using JFileChooser. ...
4
3622
by: cnixuser | last post by:
Hello, I am posting reguarding some modifications I made to a text editor program that I wrote in my java class at my school today. The file I was modifying is a very simple java text editor with...
0
1011
by: sandyw | last post by:
Hello Everyone: I need some help with a GUI project. What I want to do is when someone select the File Menu and chose New a Jpanel will open. I have tried to write the code which is called class...
9
9809
by: aleplgr | last post by:
Hi! I'm trying to let the end-user select the language of the menues I'm showing him. To do that I've got this Selector class that shows the end user a combo box, a label and a button. In the combo...
2
5655
by: thesti | last post by:
hi, is it possible for each of the JMenu in my app have an icon. or is there any workaround? thx
1
1322
by: nt5515 | last post by:
hey Im trying to make a game of pairs (the memory game) i have set up a grid which displays a graphic for the card back. im trying to link the edit menu to choose the graphic to be displayed. i've...
6
1652
crystal2005
by: crystal2005 | last post by:
Hi there, I need some help to correct my code. I would like to create a menu bar with the implementation of OO. So, i think i can edit and change it easyly if i use some classes. package...
5
2523
by: brendanmcdonagh | last post by:
Hi, I am accessing my jtable via sf1.setText((String)table.getValueAt(selectedRow, 1)); sf2.setText((String)table.getValueAt(selectedRow, 2)); ...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.