In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use Swing full-screen mode, the article is very detailed, has a certain reference value, interested friends must read it!
How do I use Swing full-screen mode?
The key is the two display device-related classes in java.awt.*: GraphicsEnvironment and GraphicsDevice.
GraphicsEnvironment provides platform-specific collections of GraphicsDevice and Font objects for Java applications. These GraphicsDevice can be the resources of a variety of local and remote machines, such as screens, printers, or Image Buffer, or even the target of Graphics2D drawing methods.
GraphicsDevice refers to a specific graphics environment, such as screens and printing devices. In this way, we can manipulate the screen with GraphicsDevice. The setFullScreenWindow () method provided by GraphicsDevice is used to set up the full screen.
Because the constructor of GraphicsEnvironment is protected, we cannot directly construct a GraphicsEnvironment object to get the GraphicsDevice object. Fortunately, it provides a getLocalGraphicsEnvironment () method to get an instance of GraphicsEnvironment:
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ()
With GraphicsEnvironment, you can call the getDefaultScreenDevice method to get the current Swing full-screen mode device:
GraphicsDevice gd = ge.getDefaultScreenDevice ()
Do it yourself.
With the introduction above, write an example to experience it:
Importjava.awt.Color; importjava.awt.Font; importjava.awt.Graphics; importjava.awt.GraphicsDevice; importjava.awt.GraphicsEnvironment; importjava.awt.event.MouseAdapter; importjava.awt.event.MouseEvent; importjavax.swing.JWindow; publicclassFullScreenTest {publicstaticvoidmain (String [] args) {GraphicsEnvironmentGraphicsEnvironmentge= GraphicsEnvironment.getLocalGraphicsEnvironment (); GraphicsDevicegd=ge.getDefaultScreenDevice (); FullScreenWindowmyWindow=newFullScreenWindow (); if (gd.isFullScreenSupported ()) gd.setFullScreenWindow (myWindow); else System.out.println ("Unsupportedfullscreen.") } staticclassFullScreenWindowextendsJWindow {publicFullScreenWindow () {this.addMouseListener (newMouseAdapter () {publicvoidmousePressed (MouseEventevt) {quit ();}});} publicvoidquit () {this.dispose ();} publicvoidpaint (Graphicsg) {g.setFont (newFont ("Arial", Font.BOLD,30)); g.setColor (Color.RED); g.drawString ("this is full screen mode", 100100) } these are all the contents of the article "how to use Swing full-screen mode". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.