当我打开一个新的JFrame时,为什么我的组件会改变格式?

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

Why when i open a new JFrame my components changes format?

问题

当我启动Jframe“VentanaPrincipal”时,它看起来像这样:

当我打开一个新的JFrame时,为什么我的组件会改变格式?

但是当我从另一个Jframe中打开Jframe时,它会更改组件的格式:

当我打开一个新的JFrame时,为什么我的组件会改变格式?

我的代码是:

VentanaPrincipal vp = new VentanaPrincipal();
vp.setVisible(true);

你能帮助我吗?

英文:

When i start the Jframe "VentanaPrincipal" this one looks like this:

当我打开一个新的JFrame时,为什么我的组件会改变格式?

but when I open the Jframe from another Jframe, it changes the format of the components:

当我打开一个新的JFrame时,为什么我的组件会改变格式?

My code is:

 VentanaPrincipal vp = new VentanaPrincipal();
 vp.setVisible(true);

Can you please help me?

答案1

得分: 1

外观和感觉(LAF)正在改变。

Swing 组件在创建组件时使用 LAF。

似乎一个框架使用了不同的 LAF,所以第二个框架在创建时继承了该 LAF。

修复您的代码以使用相同的 LAF。

阅读 Swing 教程中关于修改外观和感觉的部分,获取更多信息。

英文:

The Look and Feel (LAF) is changing.

Swing components use the LAF at the time the component is created.

It would seem that one frame uses a different LAF so the second frame inherits that LAF when it is created.

Fix your code to use the same LAF.

Read the section from the Swing tutorial on Modifying the Look and Feel for more information.

huangapple
  • 本文由 发表于 2020年8月2日 22:31:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/63217188.html
匿名

发表评论

匿名网友

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

确定