- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为我的应用程序使用BorderLayout
。setLayout(new BorderLayout());
我需要在 JPanel
的 "NORTH"
左右对齐两个 JLabels
。
这是我的代码:
JPanel top = new JPanel();
top.add(topTxtLabel);
top.add(logoutTxtLabel);
add(BorderLayout.PAGE_START, top);
所以我需要左侧的topTxtLabel和右侧的logoutTxtLabel。我尝试再次实现边框布局以使用“WEST”和“EAST”,但没有成功。有想法吗?
最佳答案
假设您的应用程序包含 JFrame
与 BorderLayout
你可以试试这个:设置 JPanel
的布局模式再次访问BorderLayout
。在框架的北部添加面板。然后添加 2 JLabels
在东部和西部。您还可以替换 JFrame
与另一个JPanel
.
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Main
{
public static void main(String[] args)
{
new Main();
}
Main()
{
JFrame frame = new JFrame("MyFrame");
frame.setLayout(new BorderLayout());
JPanel panel = new JPanel(new BorderLayout());
JLabel left = new JLabel("LEFT");
JLabel right = new JLabel("RIGHT");
JPanel top = new JPanel(new BorderLayout());
top.add(left, BorderLayout.WEST);
top.add(right, BorderLayout.EAST);
panel.add(top, BorderLayout.NORTH);
frame.add(panel, BorderLayout.NORTH);
frame.add(new JLabel("Another dummy Label"), BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
关于java - 在 "North"BorderLayout 中左右对齐两个 JLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28675266/
我有一个 JFrame-descendant 窗口,带有一个 JMenuBar 和两个存储在 JPanel 中的组件。一个是占据屏幕大部分的 JTabbedPane,另一个是包含一系列按钮的小 JPa
我在我的主用户界面中使用 primefaces 4.3。 我想把北单元的背景颜色改成红色由于某种原因,它的颜色只有单元的前 80% .ui-layout-north .ui-layout-unit-c
我们可以在 North 小部件中创建 2 个内容面板吗? BorderLayoutContainer con = new BorderLayoutContainer(); ContentPanel c
我有一个带有 BorderLayout 的 JFrame。我在 JFrame 的北侧添加了一个 JPanel。在此面板中,我想以绝对定位向其添加组件。在 JFrame 的中心一侧,我添加了另一个 JP
我正在为我的应用程序使用BorderLayout。setLayout(new BorderLayout());我需要在 JPanel 的 "NORTH" 左右对齐两个 JLabels。 这是我的代码:
我是 map v2 的新手...我想知道如何从谷歌地图的 View 中删除北方指示器。 这个: 最佳答案 您可以使用将其关闭 UiSettings.setCompassEnabled(false);
同事。 我正在尝试用 Java 构建简单的 GUI,其中 JFrame 具有边框布局。我想把带有 JTable 的 JScrollPane 放在 CENTER,没有布局的 JPanel 放在 NORT
我对如何实现“个人指南针”感到困惑,即指向特定方位而不是标准“北极”的指南针......不幸的是,我目前的尝试出现了错误(不是指向给定的方位角)。它还与加速器连接,能够根据用户转动的方式动态调整自身。
我使用 geopandas 创建了一张 map ,但我无法在 map 上添加“指北针”。 创建 map 后,我尝试使用 matplotlib.image 模块添加“指北针”并尝试了不同的方法(参见下面
我正在尝试将应用程序中的 Azure 区域列入白名单。我从这里下载了这些区域的IP:https://www.microsoft.com/en-us/download/details.aspx?id=4
下面的代码生成一个隐藏的滚动 Pane ,如图所示。 /image/miuDk.png add(new JScrollPane(queryLabel), BorderLayout.NORTH); ad
我为基于文本的游戏编写了此代码,但收到一条错误消息 line 1, in userInput = input("Please enter a direction in which to trave
我有一个带有 JFileChooser 和 JTextArea 的窗口。JFileChooser 位于 BorderLayout 的北部。JTextArea 位于 BorderLayout 的中心部分
我一直在 Unity 中使用 ARCore。 我想要实现的是根据输入的 GPS 坐标和当前 GPS 位置生成对象(例如,对象应该在 x.xxxxx、y.yyyyy 坐标处生成,这些坐标在 Unity
我的应用程序有一个问题,我想知道从当前纬度和经度到纬度和经度的方向 -(void)showDirection { CGFloat latitude = Lat; if (latitude @in
我想要一个像边框布局管理器一样的布局管理器,除了只有一个区域:北。 边框布局管理器的北部区域对我来说工作正常(即占用正确的空间),但是中心占用了所有可用空间(请参见下面的蓝色区域)。理想情况下,我希望
所以,我有这个 BorderLayout 框架,在北有一个面板 pnlLogo。在该面板中,我在标签中有一张图像。问题是:我想把它放在那个北的左上角。但是当我 setLayout(null) 和 se
在我的 Swing 应用程序中,我希望有以下屏幕布局: 在这里我们使用 BorderLayout 放置了三个面板:SOUTH、CENTER、NORTH。 为南面板和北面板选择哪种布局? North 有
我想知道是否有办法移动 Mapbox 生成的“重置北”按钮的位置。它位于我的 EditText(搜索)所在的屏幕右上角,因此我的 EditText 阻止了它。 最佳答案 您可以通过以下方式更改指南针的
如何删除顶部 layoutUnit 和中间 layoutUnit 之间的 ui-resizer?我不明白它为什么会出现,我试过使用 closable、resizable,但它不起作用。 这是我的ind
我是一名优秀的程序员,十分优秀!