我正试图摆脱用于滚动带有BoxY布局的Container的拉伸阻力。
代码:
f.setScrollable(false);
appendExit(f);
String form_uuid = "";
Container tlist = new Container(new BoxLayout(BoxLayout.Y_AXIS));
tlist.setScrollableY(false);
tlist.setTensileDragEnabled(false);
Container tocCntn = new Container(new BoxLayout(BoxLayout.Y_AXIS));
tlist.setUIID("toc");
BorderLayout bl = new BorderLayout();
bl.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
Container tocH = new Container(bl);
Label lic = new Label(AppState.res.getImage("Menu_Icon.png"));
lic.setUIID("Container");
lic.getStyle().setMargin(Component.LEFT, 10);
tocH.addComponent(BorderLayout.WEST, lic);
Label l_h = new Label("Contents");
l_h.setUIID("typelabel");
tocH.addComponent(BorderLayout.CENTER, l_h);
tlist.addComponent(tocH);
TopicParser parser = new TopicParser();
switch (AppState.topic_type) {
case 1:
AppState.typelabel = "Listening Skills";
form_uuid = "lbg";
AppState.icon = AppState.res.getImage("licon.png");
brandface = AppState.res.getImage("list_girl.png");
AppState.current_topics = parser.parse(AppState.l_topics);
tocH.setUIID("ltoc");
break;
case 2:
AppState.typelabel = "Speaking Skills";
form_uuid = "rbg";
brandface = AppState.res.getImage("speak_girl.png");
AppState.icon = AppState.res.getImage("sicon.png");
AppState.current_topics = parser.parse(AppState.s_topics);
tocH.setUIID("stoc");
break;
case 3:
AppState.typelabel = "Reading Skills";
form_uuid = "rbg";
AppState.icon = AppState.res.getImage("ricon.png");
brandface = AppState.res.getImage("reading_boy.png");
AppState.current_topics = parser.parse(AppState.r_topics);
tocH.setUIID("rtoc");
break;
case 4:
AppState.typelabel = "Writing Skills";
form_uuid = "rbg";
brandface = AppState.res.getImage("writing_girl.png");
AppState.icon = AppState.res.getImage("wicon.png");
AppState.current_topics = parser.parse(AppState.w_topics);
tocH.setUIID("wtoc");
break;
}
int i = 0;
for (final Topic topic : AppState.current_topics) {
i++;
Container topicC = new Container(new BoxLayout(BoxLayout.Y_AXIS));
//topicC.setUIID("wbg");
if (topic.getTopic_name().trim().equals("")) {
Label l = new Label(" ");
l.setUIID("toclbl");
topicC.addComponent(l);
} else {
Button topicB = new Button(i + ". " + topic.getTopic_name());
topicB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
AppState.current_topic = topic;
showForm("player", null);
}
});
topicB.setUIID("toclbl");
topicC.addComponent(topicB);
}
tocCntn.addComponent(topicC);
}
tocCntn.setScrollableY(true);
tocCntn.setScrollVisible(false);
tocCntn.setTensileDragEnabled(false);
tlist.addComponent(tocCntn);
f.addComponent(BorderLayout.CENTER, tlist);
findTypename(f).setText(AppState.typelabel);
findTypeiconimg(f).setIcon(AppState.icon);
f.setGlassPane(new Painter() {
public void paint(Graphics g, Rectangle rect) {
g.drawImage(brandface, f.getLayoutWidth()-brandface.getWidth(), f.getLayoutHeight()-brandface.getHeight()-findTopicFooter(f).getLayoutHeight());
}
});
然而它似乎没有用。
答案 0 :(得分:1)
setTensileDragEnabled应该做的伎俩,我假设你看到了Form本身的拉伸阻力,而不是你的tocCntn容器。
试试这个:
Form f = new Form();
f.setLayout(new BorderLayout());
f.setScrollable(false);
Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
cnt.setScrollableY(true);
cnt.setTensileDragEnabled(false);
//add Components to the cnt Container
...
f.addComponent(BorderLayout.CENTER, cnt);
f.show();
答案 1 :(得分:0)
UIManager.getInstance().getLookAndFeel().setDefaultTensileDrag(false);
做了这个伎俩