Skip to main content

Customize Dialog's size?

11 replies [Last post]
fabiobond
Offline
Joined: 2004-12-20
Points: 0

Hi all,

I would like to display some progress dialogs but I found strange behaviours when trying to force a dialog's size.

Suppose to create a dialog with no title, no commands and just a label (with a custom paintBackground method that display the gauge)

Even calling setPrefereedWidth() on the dialog its size seems to be about 90% of the screen height.
If I try to call setHeight() or setSize() before the show(), the label is not displayed anymore.

Is this a bug or I'm not using dialog in a wrong way?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
iluminacja
Offline
Joined: 2010-01-08
Points: 0

// if the dialog includes a title you need this
dlgSize.setHeight(dlgSize.getHeight() + tempDG.getTitle.getPreferredH
());

And if dialog includes command? How check MenuBar size?

Message was edited by: iluminacja

vprise
Offline
Joined: 2003-11-07
Points: 0

[code]
int height = 0;
if(getSoftbuttonCount() > 1) {
height = getSoftbutton(0).getParent().getPreferredH();
}
[/code]

vprise
Offline
Joined: 2003-11-07
Points: 0

Hi Fabiobond,
look at the method Dialog.show(int, int, int, int) there is a thread about this in this form. It accepts margin from the 4 sides of the screen.

Thanks,
Shai.

sawal_xp
Offline
Joined: 2008-02-12
Points: 0

hi all.
i make the dialog, and then i want to place the dialog in center of my form. how to get it?
ex:
[code]
Dialog tempDG = new Dialog();
tempDG.setTitle(_title);
tempDG.setLayout(new BorderLayout());
Label tempLB = new Label(_message);
tempLB.getStyle().setBgTransparency(0);
tempDG.addComponent(BorderLayout.CENTER, tempLB);
tempDG.addCommand(_ok);
// how to get the margin size, so the dialog can show in center from my form
return tempDG.show(int i, int i, int i, int i, boolean a, boolean b);
[/code]

Shai Almog

Hi,
Dimension = dlgSize = tempDG.getContentPane().getPreferredSize();

// if the dialog includes a title you need this
dlgSize.setHeight(dlgSize.getHeight() + tempDG.getTitle.getPreferredH
());

Display d = Display.getInstance();
int topAndBottom = (d.getDisplayHeight() - dlgSize.getHeight()) / 2;
int leftAndRight = (d.getDisplayWidth() - dlgSize.geWidth()) / 2;

Use show appropriately to center the dialog.

Thanks.

> hi all.
> i make the dialog, and then i want to place the dialog in center of
> my form. how to get it?
> ex:
> [code]
> Dialog tempDG = new Dialog();
> tempDG.setTitle(_title);
> tempDG.setLayout(new BorderLayout());
> Label tempLB = new Label(_message);
> tempLB.getStyle().setBgTransparency(0);
> tempDG.addComponent(BorderLayout.CENTER, tempLB);
> tempDG.addCommand(_ok);
> // how to get the margin size, so the dialog can show in
> center from my form
> return tempDG.show(int i, int i, int i, int i, boolean a,
> boolean b);
> [/code]
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288892
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

sawal_xp
Offline
Joined: 2008-02-12
Points: 0

hi..

tempDG.show(int i, int i, int i, int i, boolean a, boolean b);
it's ok and work good...

but when we want to show dialog in modless mode,
how to set the size margin top, right, bottom, or left to this dialog.showmodeless()...?

i have try this:
dialg.getDialogStyle().setMargin(topAndBottom, topAndBottom, leftAndRight, leftAndRight);

but it doesn't work...:(

Shai Almog

Hi,
use the same show method here:
> tempDG.show(int i, int i, int i, int i, boolean a, boolean b);

Just set b (the last argument) to false which makes the dialog modeless.

On Aug 22, 2008, at 11:40 AM, lwuit-users@mobileandembedded.org wrote:

> hi..
>
> tempDG.show(int i, int i, int i, int i, boolean a, boolean b);
> it's ok and work good...
>
> but when we want to show dialog in modless mode,
> how to set the size margin top, right, bottom, or left to this
> dialog.showmodeless()...?
>
> i have try this:
> dialg.getDialogStyle().setMargin(topAndBottom, topAndBottom,
> leftAndRight, leftAndRight);
>
> but it doesn't work...:(
> [Message sent by forum member 'sawal_xp' (sawal_xp)]
>
> http://forums.java.net/jive/thread.jspa?messageID=294741
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

pakmee
Offline
Joined: 2008-09-01
Points: 0

Hi there sorry to reopen this but I was trying to centre my dialog and had issues with the dialog not showing anything then i browsed the forum and came across this post but it seems I was already doing the right thing so just to be sure, I copied the code below and tried it out and I still cannot get the dialog to display anything on the screen.

I tried dialog.show(topbottom,topbottom,leftright,leftright,boolean,boolean) with a label. The arguments make sense since its relative to top, bottom, left and right but nothing shows up for some weird reason.

I tried printing out the values, on my emulator,

leftandright = 96 and topbottom=130 which seems to b correct since my emulator height is 320 and width = 240 but for some reason, i cannot see any label on the screen. I tried the borderlayout the gridlayout(1,1) then aligning label but I still cannot see anything.

Can anyone try this out and let me know if they do see anything.

Many thanks.

pakmee
Offline
Joined: 2008-09-01
Points: 0

Ah one more thing. I also tried changing the 2nd argument and it showed up but obviously not in the centre. thanks.

pakmee
Offline
Joined: 2008-09-01
Points: 0

I don;t know if I missunderstood the 2nd argument which says from bottom of screen to bottom of component. In my opinion this is exactly the same as the top of the screen to the top of the component... I would appreciate some insight here.

Thanks.

Message was edited by: pakmee

pakmee
Offline
Joined: 2008-09-01
Points: 0

Ok after fiddling around , I found that the dialiog had to be set as non scrollable. Now it works perfectly. I guess , its due to the fact that neverything divided gets rounded up to the nearest number.