[英]How do I prevent my java GUI buttons from shrinking (GIF included)?
I made a GIF of my situation: 我做了我的情况的GIF:
Forgive the speed of it, I made it too fast 原谅它的速度,我做得太快了
I thought that there was a function like repaint() or such? 我认为有一个像repaint()这样的功能? Is there a way to keep the buttons always fixed?
有没有办法使按钮始终固定?
Here's where I add Buttons: 这是我添加按钮的地方:
guiFrame.add(but2, BorderLayout.LINE_START);
guiFrame.add(but, BorderLayout.CENTER);
guiFrame.add(but3, BorderLayout.LINE_END);
guiFrame.add(combo2, BorderLayout.NORTH);
guiFrame.setVisible(true);
Here's my code , alternatively here 这是我的代码 ,或者在这里
thanks 谢谢
Put your JTextArea inside a JScrollPane
and add the scroll pane to your frame's content pane: 将JTextArea放在
JScrollPane
,并将滚动窗格添加到框架的内容窗格中:
textArea = new JTextArea(5, 20); JScrollPane scrollPane = new JScrollPane(textArea); getContentPane().add(scrollPane, BorderLayout.CENTER);
Put your three buttons inside another JPanel
: buttonPanel
with suitable layout manager
. 将您的三个按钮放在另一个
JPanel
: buttonPanel
并使用合适的layout manager
。 Add this buttonPanel
to the frame's content pane with BorderLayout.PAGE_END
使用
BorderLayout.PAGE_END
将此buttonPanel
添加到框架的内容窗格中
getContentPane().add(buttonPanel, BorderLayout.PAGE_END);
I thought that there was a function like repaint() or such?
我认为有一个像repaint()这样的功能? Is there a way to keep the buttons always fixed?
有没有办法让按钮始终固定?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.