简体   繁体   English

如何防止我的java GUI按钮缩小(包括GIF)?

[英]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 谢谢

  1. 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); 
  2. Put your three buttons inside another JPanel : buttonPanel with suitable layout manager . 将您的三个按钮放在另一个JPanelbuttonPanel并使用合适的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? 有没有办法让按钮始终固定?

  • everything depends of used LayoutManager , for better help sooner post an SSCCE , short, runnable, compilable, caused am issue 一切都取决于使用的LayoutManager ,以便于更快地发布SSCCE来获得更好的帮助,它简短,可运行,可编译,引起问题

  • put floating JComponent to JScrollPane 将浮动JComponent放到JScrollPane

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM