🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
5 messages
5 total messages Started by marcellovin.martinelli Tue, 06 Mar 2007 16:52
Swing Problem
#235
Author: marcellovin.martinelli
Date: Tue, 06 Mar 2007 16:52
15 lines
1722 bytes
Hi,

i've created a GUI for my application through Swing components
i've exported as an executable jar and i tried to run my app on others
computers
on a Windows OSx computer i found a problem
some frames appear to be empty or black ( -.- ) and if i resize them,
jbutton and text areas ( and all others Swing components) appear.
I've set components position through setBounds() method
i would like to ask if there is a method to set the absolute position
of my swing components ( i thought setBounds() was up to this but -
_- )?

I'll appriciate any help
Thx Marcello
Re: Swing Problem
#236
Author: Paul Nichols[TeamB]
Date: Fri, 09 Mar 2007 23:48
16 lines
1697 bytes
marcellovin.martinelli@gmail.com wrote:
> Hi,
> 
> i've created a GUI for my application through Swing components
> i've exported as an executable jar and i tried to run my app on others
> computers
> on a Windows OSx computer i found a problem
> some frames appear to be empty or black ( -.- ) and if i resize them,
> jbutton and text areas ( and all others Swing components) appear.
> I've set components position through setBounds() method
> i would like to ask if there is a method to set the absolute position
> of my swing components ( i thought setBounds() was up to this but -
> _- )?
> 
What Layout Manager are you using? Please do not tell me XYLayout, 
because you will always have this problem.
Re: Swing Problem
#237
Author: marcellovin.martinelli
Date: Sat, 10 Mar 2007 18:10
30 lines
2338 bytes
On Mar 10, 12:48 am, "Paul Nichols[TeamB]" <p...@comp.net> wrote:
> marcellovin.martine...@gmail.com wrote:
> > Hi,
>
> > i've created a GUI for my application through Swing components
> > i've exported as an executable jar and i tried to run my app on others
> > computers
> > on a Windows OSx computer i found a problem
> > some frames appear to be empty or black ( -.- ) and if i resize them,
> > jbutton and text areas ( and all others Swing components) appear.
> > I've set components position through setBounds() method
> > i would like to ask if there is a method to set the absolute position
> > of my swing components ( i thought setBounds() was up to this but -
> > _- )?
>
> What Layout Manager are you using? Please do not tell me XYLayout,
> because you will always have this problem.



no layout
i add components in this way
jPanel.add(component_name,null);

and then sets position with
component_name.setBounds(x,y,width,height);

that's way changing screen resolution all mess:P

thx for your tip :p
Re: Swing Problem
#238
Author: Paul Furbacher [TeamB]
Date: Sat, 10 Mar 2007 20:03
65 lines
2958 bytes
marcellovin.martinelli@gmail.com wrote:

> On Mar 10, 12:48 am, "Paul Nichols[TeamB]" <p...@comp.net> wrote:
>> marcellovin.martine...@gmail.com wrote:
>>> Hi,
>>> i've created a GUI for my application through Swing components
>>> i've exported as an executable jar and i tried to run my app on others
>>> computers
>>> on a Windows OSx computer i found a problem

"Windows OSx"?!

>>> some frames appear to be empty or black ( -.- ) and if i resize them,
>>> jbutton and text areas ( and all others Swing components) appear.
>>> I've set components position through setBounds() method
>>> i would like to ask if there is a method to set the absolute position
>>> of my swing components ( i thought setBounds() was up to this but -
>>> _- )?
>> What Layout Manager are you using? Please do not tell me XYLayout,
>> because you will always have this problem.
> 
> 
> 
> no layout
> i add components in this way
> jPanel.add(component_name,null);
> 
> and then sets position with
> component_name.setBounds(x,y,width,height);
> 
> that's way changing screen resolution all mess:P

You can say that again.

You need to read up on Swing layout managers and
follow the advice given in any tutorial on the subject.

Google

   +swing +layout +managers +tutorial

See hits:

   http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html

   http://home.cogeco.ca/~ve3ll/jatutorc.htm


Hint: GridBagLayout, though quite difficult, is your friend indeed.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://info.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Re: Swing Problem
#239
Author: Paul Nichols[TeamB]
Date: Sat, 10 Mar 2007 23:34
36 lines
2363 bytes
marcellovin.martinelli@gmail.com wrote:

> no layout
> i add components in this way
> jPanel.add(component_name,null);
> 
> and then sets position with
> component_name.setBounds(x,y,width,height);
> 
> that's way changing screen resolution all mess:P
> 
> thx for your tip :p
>

Yes, this will NEVER work. Resolutions and screens change dramatically 
across different Operating Systems. They even change on the same OS with 
different video cards and screen resolutions.

You need to use a layout manager, if you want an XPlatform application. 
Which one you use is up to you, but for most, I generally follow the 
following pattern.

   Frame Layouts: Layout type BorderLayout
     JPanel1 added to frame as BorderLayout.NORTH
     JPanel2 added to frame as BorderLayout.CENTER
     JPanel3 added to fram as BorderLayout.SOUTH

     Inside JPanel1, add another Panel. Set it to GirdBagLayout, You can 
design using null for layoyt, but change the inner panel to JPanel1 to 
GridbagLayout internally. This way the JPanel1 will retain NORTH 
Locations within the ContentPane of the JFrame.

Do the same for all other Panels. This makes your application or applet 
pretty portable across platforms. Easy to say, hard to teach online.

Look as Paul F. stated at the Layout Tutorials.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads