如何将标签移动到中心
How to move the label to center
我想在按下选项卡按钮时运行该应用程序,结果(网站)将显示在中心。现在的结果是这样的结果显示在下面:
但我想要这样的结果:
例如,当我按下主页时,将显示 google 网站,然后当我按下视频选项卡时,它将变为 youtube 网站。
这是我的编码:
public void start()
{
if(current != null)
{
current.show();
return;
}
Toolbar.setGlobalToolbar(true);
Form page = new Form("Apps", new BorderLayout());
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_BORDER_ALL, s);
page.getToolbar().addCommandToRightBar("", icon, (e) -> Log.p("Right"));
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://google.com");
page.add(BorderLayout.CENTER, browser);
Tabs t = new Tabs();
Style st = UIManager.getInstance().getComponentStyle("Tab");
FontImage home = FontImage.createMaterial(FontImage.MATERIAL_HOME, st);
FontImage dash = FontImage.createMaterial(FontImage.MATERIAL_MUSIC_VIDEO, st);
FontImage cal = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, st);
t.addTab("Home", home, new Label("website 1"));
t.addTab("Video", dash, new Label("website 2"));
t.addTab("Search", cal, new Label("website 3"));
page.add(BorderLayout.SOUTH, t);
page.show();
}
你能帮帮我吗?谢谢
您正在使用选项卡,但没有向其中添加任何内容。 Tabs
替换屏幕的全部内容,这不适合您要完成的任务。你一定混淆了我在不同形式下的评论,我提到了选项卡容器的底部模式。
不使用选项卡,而是使用切换按钮:
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://google.com");
page.add(BorderLayout.CENTER, browser);
FontImage home = FontImage.createMaterial(FontImage.MATERIAL_HOME, st);
FontImage dash = FontImage.createMaterial(FontImage.MATERIAL_MUSIC_VIDEO, st);
FontImage cal = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, st);
ButtonGroup bg = new ButtonGroup();
RadioButton home = RadioButton.createToggle("Home", bg);
home.setMaterialIcon(FontImage.MATERIAL_HOME);
RadioButton dash = RadioButton.createToggle("Video", bg);
dash.setMaterialIcon(FontImage.MATERIAL_MUSIC_VIDEO);
RadioButton cal = RadioButton.createToggle("Search", bg);
cal.setMaterialIcon(FontImage.MATERIAL_SEARCH);
page.add(BorderLayout.SOUTH, GridLayout.encloseIn(3, home, dash, cal));
dash.addActionListener(e -> browser.setURL("https://youtube.com/"));
我想在按下选项卡按钮时运行该应用程序,结果(网站)将显示在中心。现在的结果是这样的结果显示在下面:
但我想要这样的结果:
例如,当我按下主页时,将显示 google 网站,然后当我按下视频选项卡时,它将变为 youtube 网站。
这是我的编码:
public void start()
{
if(current != null)
{
current.show();
return;
}
Toolbar.setGlobalToolbar(true);
Form page = new Form("Apps", new BorderLayout());
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_BORDER_ALL, s);
page.getToolbar().addCommandToRightBar("", icon, (e) -> Log.p("Right"));
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://google.com");
page.add(BorderLayout.CENTER, browser);
Tabs t = new Tabs();
Style st = UIManager.getInstance().getComponentStyle("Tab");
FontImage home = FontImage.createMaterial(FontImage.MATERIAL_HOME, st);
FontImage dash = FontImage.createMaterial(FontImage.MATERIAL_MUSIC_VIDEO, st);
FontImage cal = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, st);
t.addTab("Home", home, new Label("website 1"));
t.addTab("Video", dash, new Label("website 2"));
t.addTab("Search", cal, new Label("website 3"));
page.add(BorderLayout.SOUTH, t);
page.show();
}
你能帮帮我吗?谢谢
您正在使用选项卡,但没有向其中添加任何内容。 Tabs
替换屏幕的全部内容,这不适合您要完成的任务。你一定混淆了我在不同形式下的评论,我提到了选项卡容器的底部模式。
不使用选项卡,而是使用切换按钮:
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://google.com");
page.add(BorderLayout.CENTER, browser);
FontImage home = FontImage.createMaterial(FontImage.MATERIAL_HOME, st);
FontImage dash = FontImage.createMaterial(FontImage.MATERIAL_MUSIC_VIDEO, st);
FontImage cal = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, st);
ButtonGroup bg = new ButtonGroup();
RadioButton home = RadioButton.createToggle("Home", bg);
home.setMaterialIcon(FontImage.MATERIAL_HOME);
RadioButton dash = RadioButton.createToggle("Video", bg);
dash.setMaterialIcon(FontImage.MATERIAL_MUSIC_VIDEO);
RadioButton cal = RadioButton.createToggle("Search", bg);
cal.setMaterialIcon(FontImage.MATERIAL_SEARCH);
page.add(BorderLayout.SOUTH, GridLayout.encloseIn(3, home, dash, cal));
dash.addActionListener(e -> browser.setURL("https://youtube.com/"));