Skip to main content

Menu dialog Size?

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

Hi all.

I have a form with 4 commands. When invoking the menu on small display phones (176x208) only 3 of them are shown on the dialog, then a vertical scrollbar appears.
On larger display phones all 4 commands are shown.

Even on the small screens there is plenty of space to display all the 4 commands.

Is there a way to set the preferred size for the menu dialog?
(I suppose actually is set as a total screen height * K or something realted to screen size)

Best Regards
Fabio

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
okaner
Offline
Joined: 2009-10-01
Points: 0

Shai Almog could you help me to put that code to change menu size... for example i have such code

public class BasketContentDisplay implements ActionListener {

private static BasketContentDisplay basketContentDisplay=null;

private CmdAction cmdaction=null;

private Command save=null;
private Command mainMenu=null;
private Command rename=null;
private Command removeItem=null;
private Command addMediaItem=null;
private Command goToBasketBrowser=null;
private Command goToFileBrowser=null;
private Command tagOperation=null;
private Command saveAndUpload=null;

private Button focusedButton=null;

private ListActionButton listActionButton=null;
private ListFocusButton listFocusButton=null;
private Container ccont=null;

private TextField TbasketName=null;
private Container TbasketNameCont=null;
private Label TbasketNameLabel=null;

private TextField TbasketNo=null;
private Container TbasketNoCont=null;
private Label TbasketNoLabel=null;

private TextField TpositionLatitude=null;
private Container positionCont=null;
private Button positionLabel=null;
private TextField TpositionLongitude=null;

private TextField Ttitle=null;
private Container TtitleCont=null;
private Label TtitleLabel=null;

private TextArea Tdescription=null;
private Container TdescriptionCont=null;
private Label TdescriptionLabel=null;

private Form f=null;
private int findex=0;

public BasketContentDisplay() {

cmdaction= new CmdAction();

save= new Command("Save");
mainMenu= new Command("Main Menu");
rename= new Command("Rename");
removeItem= new Command("Remove Item");
addMediaItem= new Command("Add Media Item");
goToBasketBrowser= new Command("Go to Basket Browser");
goToFileBrowser= new Command("Go to File Browser");
tagOperation= new Command("Tag Operation");
saveAndUpload= new Command("Save and UPLOAD");

f= new Form("BASKET Content Display");
f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
f.setEnabled(false);
f.setScrollable(false);

listActionButton= new ListActionButton();
listFocusButton=new ListFocusButton();

setComponents();

f.addCommand(save);
f.addCommand(mainMenu);
f.addCommand(rename);
f.addCommand(removeItem);
f.addCommand(addMediaItem);
f.addCommand(goToBasketBrowser);
f.addCommand(goToFileBrowser);
f.addCommand(tagOperation);
f.addCommand(saveAndUpload);

listBasketContent();
}

private void setComponents()
{

}
public void show()
{
f.show();
}
public static BasketContentDisplay getInstance()
{
if (basketContentDisplay == null) {
basketContentDisplay = new BasketContentDisplay();
}
return basketContentDisplay;
}
public static BasketContentDisplay getNewInstance()
{
basketContentDisplay = new BasketContentDisplay();
return basketContentDisplay;
}
public void refresh()
{
listBasketContent();
setDisplay();
f.show();
}
private void setDisplay()
{
}

private void listBasketContent()
{
}
private Container getComp(String compName)
{
}

}

fabiobond
Offline
Joined: 2004-12-20
Points: 0

Great, it works.

many thanks
Fabio

mrrubinos
Offline
Joined: 2007-01-18
Points: 0

Hi all,

I know is a quite old thread this, but when I search on the internet looking for automatic height menus in LWUIT I find this thread. Starting from code posted in this thread I think I have a real automatic sized menus solution.

Hope it helps,

Miguel

---------------------------------------------------------------------------------------------
Form form = new Form(title) {
protected Command showMenuDialog(Dialog menu) {
int marginLeft = (int) (this.getWidth() * 0.25f);
int marginRight = 0;
if (isReverseSoftButtons()) {
marginRight = marginLeft;
marginLeft = 0;
}

int commandCount = this.getCommandCount();
int height = (menu.getContentPane().getComponentAt(0).getPreferredSize().getHeight()/commandCount)*(commandCount+1);
height = height +5;

height = this.getHeight() - height;
if (height < 0) {
height = 0;
}
return menu.show(height, 0, marginLeft, marginRight, true);
}
};

okaner
Offline
Joined: 2009-10-01
Points: 0

Miguel thank you for your solution it really works... i have also one more problem about menus... aproximately i have 8-9 items in my menu when i scroll, transitions are really so slow in wtk(emulator) , a lil faster in cell phone ... does anybody know any solution????

Shai Almog

Hi Fabio,
sure there is.
Derive the form and override showMenuDialog like that. Change the
topMargin argument to a lower number to increase the height further:
protected Command showMenuDialog(Dialog menu) {
int marginLeft = (int) (Form.this.getWidth() * 0.25f);
int marginRight = 0;
if (isReverseSoftButtons()) {
marginRight = marginLeft;
marginLeft = 0;
}
int topMargin = Form.this.getHeight() / 3;
return menu.show(topMargin, 0, marginLeft, marginRight, true);
}

Thanks.

On Jul 31, 2008, at 10:42 AM, lwuit-users@mobileandembedded.org wrote:

> Hi all.
>
> I have a form with 4 commands. When invoking the menu on small
> display phones (176x208) only 3 of them are shown on the dialog,
> then a vertical scrollbar appears.
> On larger display phones all 4 commands are shown.
>
> Even on the small screens there is plenty of space to display all
> the 4 commands.
>
> Is there a way to set the preferred size for the menu dialog?
> (I suppose actually is set as a total screen height * K or
> something realted to screen size)
>
> Best Regards
> Fabio
> [Message sent by forum member 'fabiobond' (fabiobond)]
>
> http://forums.java.net/jive/thread.jspa?messageID=290527
>
> ---------------------------------------------------------------------
> 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]

iman-tung
Offline
Joined: 2011-10-14
Points: 0

Hi Shai,

at LWUIT 1.5, showMenuDialog(...) not longer exist in Form and it's under MenuBar class now. Is there work around to customize menu dialog.

drdth
Offline
Joined: 2003-06-16
Points: 0

Is this still the official way of dealing with 'long' menus or is this possible via the API now ?

Shai Almog

What API would you suggest?
Notice that some devices change orientation in runtime (e.g. N95) so
set menu size won't be an appropriate API.

> Is this still the official way of dealing with 'long' menus or is
> this possible via the API now ?
> [Message sent by forum member 'drdth' (drdth)]
>
> http://forums.java.net/jive/thread.jspa?messageID=308659
>
> ---------------------------------------------------------------------
> 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]

drdth
Offline
Joined: 2003-06-16
Points: 0

Well, most convenient would be if the dialog size was defined automatically so all menu entries fit regardless of their number. If they don't fit, then a scroll could appear ?