Skip to main content

bug on TabbedPane?

2 replies [Last post]
dtondo
Offline
Joined: 2008-06-14
Points: 0

when i try create a TabbedPane with "createPair" function (the same that lwuitDEMO):

protected Container createPair(String label, Component c, int minWidth) {
Container pair = new Container(new BorderLayout());
Label l= new Label(label);
l.setPreferredW(Math.max(l.getPreferredW(), minWidth));
l.getStyle().setBgTransparency(100);
pair.addComponent(BorderLayout.WEST,l);
pair.addComponent(BorderLayout.CENTER, c);
return pair;
}

combined with CheckBox component, i got this image:
http://img180.imageshack.us/img180/3959/tempsssos2.jpg

********************************All code****************************************
package Options;

import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import Util.GetServerXml;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.CheckBox;
import com.sun.lwuit.TabbedPane;

public class Options{

private Form mainOptions;

public void start(final Form lastForm) {

mainOptions = new Form("Options");
mainOptions.setLayout(new BorderLayout());

final Container generalContainer = new Container();
CheckBox firstCB = new CheckBox("First CheckBox");
firstCB.getStyle().setMargin(Component.TOP, 1);
firstCB.getStyle().setMargin(Component.BOTTOM, 0);
CheckBox secondCB = new CheckBox("Second CheckBox");
secondCB.getStyle().setMargin(0, 5, 2, 2);

generalContainer.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
Container generalContainerPair = createPair("isopore:", firstCB, 30);
generalContainer.addComponent(createPair("isopor:", secondCB, 30));
generalContainer.addComponent(generalContainerPair);

TabbedPane tabbedPane = new TabbedPane();
tabbedPane.addTab("Geral", generalContainer);

mainOptions.addComponent(BorderLayout.CENTER, tabbedPane);
mainOptions.show();
}
/**
* Helper method that allows us to create a pair of components label and the given
* component in a horizontal layout with a minimum label width
*/
protected Container createPair(String label, Component c, int minWidth) {
Container pair = new Container(new BorderLayout());
Label l= new Label(label);
l.setPreferredW(Math.max(l.getPreferredW(), minWidth));
l.getStyle().setBgTransparency(100);
pair.addComponent(BorderLayout.WEST,l);
pair.addComponent(BorderLayout.CENTER, c);
return pair;
}
/**
* Helper method that allows us to create a pair of components label and the given
* component in a horizontal layout
*/
protected Container createPair(String label, Component c) {
return createPair(label,c,0);
}
public static String connect(String xmlRequest, String viewName)throws Exception {
try {
GetServerXml getXml = new GetServerXml(xmlRequest, viewName);
return getXml.start();
} catch (Exception ex) {
throw new Exception(ex.getMessage());
}
}

}
********************************end of code****************************************

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
you set the top margin of the checkbox to 0:
secondCB.getStyle().setMargin(0, 5, 2, 2);

So it draws on top of the line, set it to 1 or higher and it will
solve your problem.

Thanks.

> when i try create a TabbedPane with "createPair" function (the same
> that lwuitDEMO):
>
>
> http://forums.java.net/jive/thread.jspa?messageID=289032
>
> ---------------------------------------------------------------------
> 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]

dtondo
Offline
Joined: 2008-06-14
Points: 0

Thanks to answer so quickly, Shai Almog. Problem Solved!