import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Sample {
public static String audioName;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setTitle("Frame");
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
device.setFullScreenWindow(frame);
device.setDisplayMode(new DisplayMode(800, 600, 32, 60));
frame.setVisible(true);
JButton btn = new JButton();
btn.setText("Button");
JPanel panel = new JPanel();
panel.add(btn);
frame.add(panel);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
int returnName = chooser.showOpenDialog(frame);
if (returnName == JFileChooser.APPROVE_OPTION) {
System.out.println("Sample");
}
}
});
}
}
如何在全屏幕中显示JFileChooser?我不熟悉JInternalFrame/JDesktopPane,你认为这会解决这个问题还是有另一种方法呢?JFileChooser外部显示完全屏蔽JFrame
如果Java应用程序更改我的Windows显示设置,我将永远不会再使用该应用程序。 –
@GilbertLeBlanc,java只会在运行应用程序时将其临时更改。 – Jong
@GilbertLeBlanc可能已经注意到同样的效果,让我对这段代码非常感兴趣。每次运行它时,它都会将屏幕最右侧的两个屏幕WinAmp强制放置在新屏幕大小的限制范围内。这让我意识到,看起来全屏模式在每一步都能捕捉到你。什么是这个应用程序非常重要。它应该是'全屏'? –