在表单中央显示 JInternalFrame 数据。

huangapple go评论132阅读模式
英文:

Show the JInternalFrame data in the middle of the form

问题

我正在使用包含三个部分的JFrame。第一个部分是Pane,其中包含6个菜单按钮(位于左侧)。第二个部分也是Pane,在顶部显示公司的标志。第三个部分是DesktopPane,在其中我在DesktopPane中使用(调用)JInternalFrame。如何才能始终将JInternalFrame的内容(表单数据)显示在DesktopPane的中央?

在表单中央显示 JInternalFrame 数据。

英文:

I am using JFrame which contains three sections. 1st section is Pane, which contains the 6 menu button (left side). 2nd section is also Pane, which displays the logo of the company on the top. The third section is DesktopPane in which I am using (calling) JInterenalFrame in the DesktopPane.
How to always show the JInterenalFrame content (form data) into the middle of DesktopPane?

在表单中央显示 JInternalFrame 数据。

答案1

得分: 2

第三部分是 DesktopPane,在其中我在 DesktopPane 中使用(调用)JInternalFrame。

一个 JDesktopPane 用于显示多个 JInternalFrame。可以在桌面窗格中拖动 JInternalFrame。

根据您的图片,看起来您在那个区域只有一个单独的 JPanel。因此,您不应该使用 JDesktopPanel 和 JInternalFrame。

相反,您可以使用一个带有 CardLayout 的常规 JPanel。通过这种方式,您可以根据左侧菜单的选择替换每个面板。

有关更多信息,请参阅How to Use CardLayout

将数据显示在表单的中间位置

最简单的方法是使用带有 GridBagLayout 的 JPanel。

因此,您需要在一个带有 GridBagLayout 的面板中包装您当前的面板。

基本代码如下:

JPanel welcomePanel = new JPanel(new GridBagLayout());

welcomePanel.add(currentPanel, new GridBagConstraints());

现在您的 "currentPanel" 将居中显示在 "welcomePanel" 中,后者已添加到您的面板中使用 CardLayout。

英文:

> Third section is DesktopPane in which I am using(calling) JInterenalFrame in the DesktopPane.

A JDesktopPane is used to display multiple JInternalFrames. A JInternalFrame can be dragged around the desktop pane.

From your picture it looks like you just have a single JPanel in that area. Therefore you should not be using JDesktopPanel and JInternalFrame.

Instead you just use a regular JPanel with a CardLayout. This you can replace each panel based on the selection from your menu on the left.

See How to Use CardLayout for more information.

> Show the data into middle of the form

The easiest way to do this is to use a JPanel with a GridBagLayout.

So you need to wrap your current panel in a panel with the GridBagLayout.

So the basic code is:

JPanel welcomePanel. = new JPanel( new GridBagLayout() );

welcomePanel.add(currentPanel, new GridBagConstraints());

Now your "currentPanel" will be centered in the "welcomePanel", which has been added to your panel using the CardLayout.

huangapple
  • 本文由 发表于 2020年4月4日 23:14:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/61030214.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定