Java中容器内的swing容器
我有一个Java程序,它有一个BorderLayout
,到目前为止运行良好。
我想在下面添加一个JTextArea
,在我点击run按钮后显示out put
有人能给我举个例子,说明实现我想做的事情的最佳方法吗?
我应该定义一个2X1的GridLayout
,上面是我的BorderLayout
,下面是我的JTextArea
我愿意接受建议
以下是我到目前为止的照片:
下面--我想有一个文本区域,一旦我点击run按钮,它就会捕捉输出
你可以在下面搜索框中键入要查询的问题!
我有一个Java程序,它有一个BorderLayout
,到目前为止运行良好。
我想在下面添加一个JTextArea
,在我点击run按钮后显示out put
有人能给我举个例子,说明实现我想做的事情的最佳方法吗?
我应该定义一个2X1的GridLayout
,上面是我的BorderLayout
,下面是我的JTextArea
我愿意接受建议
以下是我到目前为止的照片:
下面--我想有一个文本区域,一旦我点击run按钮,它就会捕捉输出
# 1 楼答案
使用
border layout
将现有GUI添加到
panel
并将其添加到frame
的center
和border layout
的TextArea
上代码片段:
# 2 楼答案
正如我在评论中所说。。。那么像这样的事情呢:
通过在{}上添加{}和{},你的{}将扮演某种控制台的角色,如果我理解正确的话,这就是你问题的目标
# 3 楼答案
如果我有这个想法,当你点击跑步按钮时,你想在整个东西下面添加一个文本区域
我建议使用两个面板。把你所有的东西都放在一个面板中(这个面板会有borderLayout),然后把另一个面板放在下面,当你点击Run按钮时,你可以通过编程的方式添加JtextArea
编辑
比如: