- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有 JFileChooser 和 JTextArea 的窗口。JFileChooser 位于 BorderLayout 的北部。JTextArea 位于 BorderLayout 的中心部分。
我想将我的所有 JFileChooser 向左对齐,但它不会像我想要的那样移动并保持居中。此外,我希望我的 JFileChooser 占据窗口的所有长度。
编辑
这是主要代码
public class MainServer
{
public static void main(String[] args)
{
ServerBoard frame=new ServerBoard(1000, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
这是窗口代码
public class ServerBoard extends JFrame
{
private JButton startserver;
private JButton senddata;
private JButton sendgps;
private JTextArea messagearea;
public ServerBoard(int l, int h)
{
super("ServerBoard");
this.initialize();
this.setSize(l,h);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public void initialize()
{
// Define a panel
Container c=this.getContentPane();
this.messagearea=new JTextArea(40,60);
c.add(this.createNorth(), BorderLayout.NORTH);
c.add(messagearea, BorderLayout.CENTER);
}
public JPanel createNorth()
{
JPanel panelnorth=new JPanel();
JToolBar toolbarnorth=new JToolBar();
panelnorth.add(toolbarnorth);
this.startserver=new JButton("START SERVER");
startserver.addActionListener(new ServerBoardListener());
toolbarnorth.add(startserver);
this.senddata=new JButton("SEND DATA");
senddata.addActionListener(new ServerBoardListener());
toolbarnorth.add(senddata);
this.sendgps=new JButton("SEND GPS FRAME");
sendgps.addActionListener(new ServerBoardListener());
toolbarnorth.add(sendgps);
return panelnorth;
}
}
这是我的窗口
我真的很想使用这个 JFileChooser。你能帮我一下吗?
提前非常感谢您的回答。
最佳答案
简单地嵌套您的 JPanel。创建一个新的 JPanel(例如称为 NorthPanel),它使用 BorderLayout,并将其添加到主窗口的 BorderLayout.NORTH 位置,然后将 JFIleChooser 添加到此 NorthPanel JPanel 的 BorderLayout.WEST 位置。
选项2:给northPanel一个沿线轴定向的BoxLayout,添加JFileChooser,并添加胶水。
关于java - 无法将 JFileChooser 与 BorderLayout.NORTH 的左侧对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21284497/
我有一个 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
我是一名优秀的程序员,十分优秀!