如何檢查這些類型的問題。當我檢查我的桌面應用程序的菜單時,有些顯示關閉按鈕的工具提示正確顯示,應該始終位於前面。但有些顯示在模態對話框的後面。模式對話框背後的工具提示
我種有同樣的問題作爲一個誰張貼這樣的:我們正在使用的Java Swing https://coderanch.com/t/460688/java/Glasspanes-tooltips
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
class GlassPaneContent extends JPanel {
GlassPaneContent() {
setSize(200, 50);
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
JButton button = new JButton("A button");
button.setToolTipText("A tooltip");
add(button);
}
}
class GlassPane extends JPanel {
private static final Color BG_COLOR = new Color(0, 0, 0, 96);
private GlassPaneContent content = new GlassPaneContent();
public GlassPane() {
setLayout(null);
setOpaque(false);
add(content);
}
@Override
protected void paintComponent(Graphics g) {
g.setColor(BG_COLOR);
g.fillRect(0, 0, getWidth(), getHeight());
int x = (getWidth() - content.getWidth())/2;
int y = (getHeight() - content.getHeight())/2;
content.setLocation(x, y);
super.paintComponent(g);
}
}
public class MainWindow extends JFrame {
public MainWindow() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(500, 500);
GlassPane gp = new GlassPane();
getRootPane().setGlassPane(gp);
gp.setVisible(true);
}
public static void main(String[] args) {
new MainWindow().setVisible(true);
}
}
。請在下面評論,如果我需要發佈代碼。謝謝!
請提供[SSCCE](http://sscce.org)和步驟重現它。 –