JDialog 没有出现在新计算机上?
JDialog not showing up on new computer?
我一直在研究全屏摇摆程序,最近购买了一台新笔记本电脑。
在这台新笔记本电脑上,字体在程序中显示的不同,我认为这意味着字体 "MT Footlight light" 没有安装在这台计算机上。然而,更重要的是,即使在调用 toFront() 或 requestFocus() 之后,我创建的 JDialog 也不会出现在屏幕前面。
我可以提供一个 SSCCE,但代码在我用过的其他计算机上工作正常,它们具有相同的 OS (Windows 8) 和不同的 (Windows 7 ),所以如果有人知道问题出在哪里,请告诉我
编辑:
虽然我还没有真正使用 JDialog 编辑这些部分,但它开始看起来可能不是新计算机,但这里有几乎所有影响 JDialog 的东西的 SSCCE
public class Runner {
public static void main(String[] args){
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
new MainFrame(devices[0]);
}
}
public MainFrame(GraphicsDevice graphicsDevice){
super();
this.setGraphicsDevice(graphicsDevice);
this.setOrigDisplay(graphicsDevice.getDisplayMode());
//Sets the panel to its default start screen, the main menu
setPanel(new MainMenuPanel(this));
//Resizes to full-screen
if (graphicsDevice.isFullScreenSupported()){
this.dispose();
setUndecorated(true);
setResizable(false);
graphicsDevice.setFullScreenWindow(this);
//this.setVisible(false);
revalidate();
}else{
System.out.println("Full-screen mode not supported");
}
//Applies the custom theme
try {
Theme.loadTheme(new File("res/IS.theme"));
UIManager.setLookAndFeel(new TinyLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
SwingUtilities.updateComponentTreeUI(this);
Toolkit.getDefaultToolkit().setDynamicLayout(false);
System.setProperty("sun.awt.noerasebackground", "true");
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds(0, 0, size.width, size.height);
}
public class OptionsPanel extends JPanel{
private final MainFrame context;
private SetupDialog setup;
public OptionsPanel(final MainFrame m){
super();
setLayout(new GridBagLayout());
this.context = m;
JButton setupButton = new JButton("Run set-up");
setupButton.setFont(Constants.FONT_BIG);
setupButton.setMargin(new Insets(20,20,20,20));
setupButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//TODO
setup = new SetupDialog(context);
}
});
//Other options stuff
}
}
public class SetupDialog extends JDialog{
private MainFrame context;
private JList<Info> midiSystemList;
private int instruction;
private NoteListener n;
public SetupDialog(MainFrame m){
super(m);
this.context = m;
//setTitle("Set-up");
this.setUndecorated(false);
this.setLocationRelativeTo(null);
//Does setup stuff
this.setUndecorated(true);
pack();
setModal(true);
setVisible(true);
}
}
我设法通过使用
从实际的全屏模式更改为另一种模式来解决我的问题
this.setExtendedState(JFrame.EXTENDED_BOTH);
this.setUndecorated(true);
我仍然不确定发生了什么变化,因为我以前能够在常规全屏模式下使用 JDialogs,但是这个解决方案仍然有效
我一直在研究全屏摇摆程序,最近购买了一台新笔记本电脑。
在这台新笔记本电脑上,字体在程序中显示的不同,我认为这意味着字体 "MT Footlight light" 没有安装在这台计算机上。然而,更重要的是,即使在调用 toFront() 或 requestFocus() 之后,我创建的 JDialog 也不会出现在屏幕前面。
我可以提供一个 SSCCE,但代码在我用过的其他计算机上工作正常,它们具有相同的 OS (Windows 8) 和不同的 (Windows 7 ),所以如果有人知道问题出在哪里,请告诉我
编辑:
虽然我还没有真正使用 JDialog 编辑这些部分,但它开始看起来可能不是新计算机,但这里有几乎所有影响 JDialog 的东西的 SSCCE
public class Runner {
public static void main(String[] args){
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
new MainFrame(devices[0]);
}
}
public MainFrame(GraphicsDevice graphicsDevice){
super();
this.setGraphicsDevice(graphicsDevice);
this.setOrigDisplay(graphicsDevice.getDisplayMode());
//Sets the panel to its default start screen, the main menu
setPanel(new MainMenuPanel(this));
//Resizes to full-screen
if (graphicsDevice.isFullScreenSupported()){
this.dispose();
setUndecorated(true);
setResizable(false);
graphicsDevice.setFullScreenWindow(this);
//this.setVisible(false);
revalidate();
}else{
System.out.println("Full-screen mode not supported");
}
//Applies the custom theme
try {
Theme.loadTheme(new File("res/IS.theme"));
UIManager.setLookAndFeel(new TinyLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
SwingUtilities.updateComponentTreeUI(this);
Toolkit.getDefaultToolkit().setDynamicLayout(false);
System.setProperty("sun.awt.noerasebackground", "true");
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
this.setBounds(0, 0, size.width, size.height);
}
public class OptionsPanel extends JPanel{
private final MainFrame context;
private SetupDialog setup;
public OptionsPanel(final MainFrame m){
super();
setLayout(new GridBagLayout());
this.context = m;
JButton setupButton = new JButton("Run set-up");
setupButton.setFont(Constants.FONT_BIG);
setupButton.setMargin(new Insets(20,20,20,20));
setupButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//TODO
setup = new SetupDialog(context);
}
});
//Other options stuff
}
}
public class SetupDialog extends JDialog{
private MainFrame context;
private JList<Info> midiSystemList;
private int instruction;
private NoteListener n;
public SetupDialog(MainFrame m){
super(m);
this.context = m;
//setTitle("Set-up");
this.setUndecorated(false);
this.setLocationRelativeTo(null);
//Does setup stuff
this.setUndecorated(true);
pack();
setModal(true);
setVisible(true);
}
}
我设法通过使用
从实际的全屏模式更改为另一种模式来解决我的问题this.setExtendedState(JFrame.EXTENDED_BOTH);
this.setUndecorated(true);
我仍然不确定发生了什么变化,因为我以前能够在常规全屏模式下使用 JDialogs,但是这个解决方案仍然有效