Java 无法将滚动条添加到jframe或动态调整屏幕大小
首先,对不起我的语言我是法国人,英语不是最好的 我是java swing新手,但我必须修复一个程序。这不是我的代码,所以我很难理解所有这些。我有一个Jframe和一些JButton、JLabel、Jtable。。。问题:对于某些电脑屏幕,宽度太大,我们看不到几个元素。 我曾尝试使用滚动条ou动态调整屏幕大小,但正如我所说,我是swing新手 我不能给你看代码,但我会尽力恢复这种情况Java 无法将滚动条添加到jframe或动态调整屏幕大小,java,swing,jframe,jpanel,Java,Swing,Jframe,Jpanel,首先,对不起我的语言我是法国人,英语不是最好的 我是java swing新手,但我必须修复一个程序。这不是我的代码,所以我很难理解所有这些。我有一个Jframe和一些JButton、JLabel、Jtable。。。问题:对于某些电脑屏幕,宽度太大,我们看不到几个元素。 我曾尝试使用滚动条ou动态调整屏幕大小,但正如我所说,我是swing新手 我不能给你看代码,但我会尽力恢复这种情况 public class maClasse extends JFrame { public static
public class maClasse extends JFrame {
public static void updateProgressBar(final Integer type) {
final SwingWorker<Integer, Void> worker = new SwingWorker<Integer, Void>() {
@Override
public Integer doInBackground() {
try {
fenetrePrincipale = new Calcul(false);
fenetreIntro.setLocationRelativeTo(fenetreIntro
.getParent());
fenetrePrincipale
.setLocationRelativeTo(fenetrePrincipale
.getParent());
fenetrePrincipale.setVisible(true);
fenetrePrincipale
.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public
void
windowClosing(final java.awt.event.WindowEvent windowEvent) {
Log.ecrire(new File(Chemin
.getCheminLog()),
"INFO",
"Programme quitté! (Code retour 1)");
System.exit(1);
}
});
private static Calcul fenetrePrincipale;
//more private ...
public Calcul(final boolean loader) {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
if (loader) {
setTitle("Calcul de d\u00E9pendances");
// setBounds(100, 100, 1058, 709);
setExtendedState(Frame.MAXIMIZED_BOTH);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new MigLayout(
"",
"[91.00px,grow][25.00][7.00px,grow][grow][][][][][][][][][][][231.00][][][][26.00][][-33.00][][41.00][231.00][][][][][-16.00][][][][-29.00][][-15.00]",
"[44px][][][][][][239.00,grow][-231.00][][][245.00,grow][96.00,grow][]"));
//a lot of Jbutton, Jlabel, Jtable with the command
//contentPane.add(btnJbutton) ...
setContentPane(contentPane);
}
}
我想JFrame的所有代码都在这里。你能帮我使用滚动条或者动态调整Jframe的大小吗
多亏了你1。初始大小的JFrame.setVisibletrue之前的JFrame.pack MigLayout返回正确的getPreferredSize,2。JFrame.pack也可以在运行时调整大小,但JComponents必须向您返回正确的getPreferredSizeThanks,这是可行的。我已经尝试过使用pack,但我不知道如何使用它创建JFrame作为局部变量,然后删除extends JFrame,如果不是所有java类的静态可设置项,那么这个实例是可访问的