473,326 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Swing dilemma

Can anyone explain to me the benefit of using a JPanel and adding it to a
JFrame ; where all the components(buttons,etc.) are added to JPanel.
Compared to skipping the JPanel and just adding the components to a JFrame.
I find that the book I am reading seems to use JPanels quite a bit but
doesn't state why. Thank you in advance.


Jul 17 '05 #1
2 1481
Compartmentalizing your swing components allows you to take advantage of the
many layout managers at your disposal. As for pros and cons, I think that
you must decide what is right for your application. A simple GUI may not
need so much layering, you know?
"Joseph" <na@na.ca> wrote in message
news:pt****************@twister01.bloor.is.net.cab le.rogers.com...
Can anyone explain to me the benefit of using a JPanel and adding it to a
JFrame ; where all the components(buttons,etc.) are added to JPanel.
Compared to skipping the JPanel and just adding the components to a JFrame. I find that the book I am reading seems to use JPanels quite a bit but
doesn't state why. Thank you in advance.

Jul 17 '05 #2

"Joseph" <na@na.ca> wrote in message
news:pt****************@twister01.bloor.is.net.cab le.rogers.com...
Can anyone explain to me the benefit of using a JPanel and adding it to a
JFrame ; where all the components(buttons,etc.) are added to JPanel.
Compared to skipping the JPanel and just adding the components to a JFrame. I find that the book I am reading seems to use JPanels quite a bit but
doesn't state why. Thank you in advance.


Programming onto a panel delays the choice for making it a top-level
component (inside JFrame), embedded component (inside JInternalFrame) or
perhaps even an applet (inside JApplet). In other words it gives you more
flexibility at hardly any cost.

Silvio Bierman
Jul 17 '05 #3

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

Similar topics

0
by: Scott Khan | last post by:
We have a Java Swing position. Need consultants ASAP. Position : Java Swing XML / SOAP - FX / Brokerage Requirements : Swing - JTrees / Jtables. other swing classes. etc. Java/ J2EE. JDK...
5
by: Chris | last post by:
Having been traumatised many years ago when using MFC/C++ to develop front-end code, I've religiously avoided GUI work since and stuck to back-end / server-side projects. So I'm a bit of a novice...
6
by: Joseph | last post by:
hi 1) i plan on having an awt canvas component (to draw graphs) on a JFrame with other swing components..will this be okay? i've read that swing and awt aren't compatible.. 2)Also, if i...
3
by: bergel | last post by:
Hello, Does anyone already have some experience in mixing AWT and Swing? Is it conceptually doable? Does the design of Swing prevent interaction between an AWT and a Swing widget? Regards,...
3
by: Sherrod Faulks | last post by:
I'm using Jython and in the python script I do: from javax import swing result = javax.swing.JOptionPane.showInputDialog(wC, cmd,"Prompt from " + client.serverName, JOptionPane.PLAIN_MESSAGE) ...
1
by: Nandan | last post by:
hello, can I ask a jython question here? when I use the jython interpreter I have no problem with the statement: from java import lang from javax import swing but when I put this in a...
2
by: asj | last post by:
I have to honestly say I was flabbergasted by this report. Obviously, I have no problems asserting that Java is #1 in the enterprise (JEE), or in the mobile space (JME), and I do know it's made...
3
by: Nuwang | last post by:
Hai, I'm using a swing to connect database with swing application... 1. How this swing connect with access database... 2. Important thing is how change Button size and Font size Still I...
6
by: r035198x | last post by:
I have put together this article to give people starting Swing an awareness of issues that need to be considered when creating a Swing application. Most of the Swing tutorials that I have seen just...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.