In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use Java's container JFrame", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use Java's container JFrame" article.
The common operation methods of the basic container JFrameJFrame class use public JFrame () throws HeadlessException to create a common form object public JFrame (String title) throws HeadlessException to create a form object And specify title public void setSize (int width,int height) set form size public void setSize (Dimension d) set form size public void setBackground (Color c) set form background color public void setLocation (int x) through Dimension Int y) sets the display position of the component public void setLocation (Point P) sets the display position of the component through Point (boolean b) shows or hides the component public Component add (Component comp) adds components to the container public void setLayout (LayoutManager mgr) sets layout manager public void pack () resizes the window public Container getContentPanc () returns the container object of this form to create the form import javax.swing.* Import java.awt.*;public class Hello {public static void main (String [] args) {JFrame a = new JFrame ("first form"); a.setSize (1000500); a.setBackground (Color.black); a.setLocation (200300); a.setVisible (true);}}
In JFrame, you can use the Dimension class to set the size of the form, which encapsulates the display width and height of the component
Method uses public Dimension () to create an Demension instance public void setSize (double width,double height) sets the width and height of the display public void setSize (int width,int height) sets the width and height of the display public double getWidth () returns the width of the component () returns the height of the component
The Point class encapsulates the X and Y coordinates of the display location.
The method uses public Point () to create an object at the coordinate origin public Point (int xmaginy) to create an object at the specified coordinate point public void setLocation (double xmaginy) to set the X and Y coordinates public void setLocation (int xreint y) to set the X and Y coordinates public void move (int xpenint y) to move the component to the point where the specified coordinate position public void translate (int dx,int dy) translation (xjiny) is located. Translate dx along the x-axis, translate dy along the y-axis, and get the point after moving.
Use the Dimension and Point classes to set the component size and display location
Import javax.swing.*;import java.awt.*;public class Hello {public static void main (String [] args) {JFrame a = new JFrame ("one"); Dimension d = new Dimension (); d.setSize (1000500); a.setSize (d); a.setBackground (Color.black); Point p = new Point (200300); a.setLocation (p); a.setVisible (true) }}
The above is about the content of this article on "how to use Java's container JFrame". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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.