简体   繁体   English

单击JTabbedPane上的选项卡时,组件不会立即显示

[英]When clicking a tab on a JTabbedPane the components don't appear immediately

I have an application that includes a JTabbedPane and two tabs with some components. 我有一个包含JTabbedPane和两个包含一些组件的选项卡的应用程序。 My problem is when I click on another tab, it's components do not appear immediately; 我的问题是,当我点击另一个标签时,它的组件不会立即出现; but when the mouse courser moves over each component ( JCheckBox , JButton and so on) of the tab, the components will appear but not correctly (see below image). 但是当鼠标光标移动到选项卡的每个组件( JCheckBoxJButton等)时,组件将出现但不正确(参见下图)。

alt text http://hivaonline.persiangig.com/1.gif 替代文字http://hivaonline.persiangig.com/1.gif

alt text http://hivaonline.persiangig.com/2.gif 替代文字http://hivaonline.persiangig.com/2.gif


This is my CODE . 这是我的CODE。 . .

Are you mixing some awt and swing stuff? 你在混合一些awt和摇摆的东西?

This could probably make such unpredictable effects. 这可能会产生如此不可预测的影响。

Can you see an exception on the console? 你能在控制台上看到异常吗? Exceptions in Event Dispatching Thread can cause such behavior. 事件调度线程中的异常可能导致此类行为。

As others have observed, your code is incomplete. 正如其他人所观察到的,您的代码不完整。 As a guide, consider this article on the benefits of a Short, Self Contained, Correct (Compilable), Example . 作为指南,请考虑这篇关于短,自包含,正确(可编译)的例子的文章 Several such examples are discussed in How to Use Tabbed Panes . 如何使用选项卡式窗格”中讨论了几个此类示例。 You might compare them with what you're doing. 你可以将它们与你正在做的事情进行比较。

感谢你的响应,问题是调用一个组件的repaint(),当我改变它的位置时,标记的位置必须在用户每次移动或页面事件发生时改变,所以我认为调用重绘( )导致循环和其他组件没有正确绘制。

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

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