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--
Editor to share with you when full-screen mode will be used in Java, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!
When will full screen mode be used?
There may be few opportunities to use it, but jdk still provides us with this feature. Like the print preview function in many software, and in some text editors, full-screen mode is also used in order to get a larger editing picture, if you are interested in writing a software like ACDSee, using full-screen mode allows users to see a larger picture.
How do I use full-screen mode?
The key is the two display device-related classes in java.awt.*: GraphicsEnvironment and GraphicsDevice.
GraphicsEnvironment provides platform-specific GraphicsDevice for Java applications
Objects and Font object collections. 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 GraphicsEnvironment's constructor 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 screen device:
GraphicsDevice gd = ge.getDefaultScreenDevice ()
Do it yourself.
With the introduction above, write an example to experience it:
Import java.awt.*
Import java.awt.event.*
Import javax.swing.*
Public class FullScreenTest
{
Public static void main (String [] args)
{
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment ()
GraphicsDevice gd = ge.getDefaultScreenDevice ()
FullScreenWindow myWindow = new FullScreenWindow ()
If (gd.isfullScreenSupported ())
Gd.setFullScreenWindow (myWindow)
Else
System.out.println ("Unsupported full screen.")
}
}
Class FullScreenWindow extends JWindow
{
Public FullScreenWindow ()
{
This.addMouseListener (new MouseAdapter ()
{
Public void mousePressed (MouseEvent evt)
{
Quit ()
}
});
}
Public void quit ()
{
This.dispose ()
}
Public void paint (Graphics g)
{
G.setFont (new Font ("Arial", Font.BOLD,30))
G.setColor (Color.RED)
G.drawString ("this is full screen mode", 100100)
}
}
The above is all the content of the article "when will full screen mode be used in Java?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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.