Article

SWING JFrame basics, how to create JFrame

Topic: Coach Training and CertificationPublished April 25, 2018
No ratings yet512 viewsSign in to rate
This instructional exercise clarifies JFrame nuts and bolts from creation to customization.rnWhat is JFrame? rnJFrame is a class of javax.swing bundle reached out by java.awt.frame; it includes bolster for JFC/SWING part design. It is the best level window, with fringe and a title bar. JFrame class has numerous strategies which can be utilized to alter it. Making a JFrame rnJFrame class has numerous constructors used to make a JFrame. Following is the portrayal.rnJFrame (): makes an edge which is imperceptiblernJFrame (Graphics Configuration gc): makes an edge with a clear title and illustrations arrangement of screen gadget.rnJFrame (String title): makes a JFrame with a title.rnJFrame (String title, Graphics Configuration gc): makes a JFrame with particular Graphics setup and Java course in Bangalore determined title. Here is the simplest example just to make a JFrame. Package Example;rnImport java.awt.GraphicsConfiguration;rnImport javax.swing.JFrame;rnPublic class JFrameExample {rnStatic GraphicsConfiguration gc;rnPublic static void main(String[] args){rnJFrame frame= new JFrame (gc);rnframe.setVisible (true); } } Set title of JFrame rnTo set the title of a JFrame, you can utilize JFrame.setTitle(String title). Here is the code rnpackage Example;rnimport java.awt.GraphicsConfiguration;rnimport javax.swing.JFrame;rnpublic class JFrameExample {rnstatic GraphicsConfiguration gc;rnpublic static void main(String[] args){rnJFrame frame= new JFrame (gc);rnframe.setTitle("Welecome to JavaTutorial.net");rnframe.setVisible(true); } } Change window size of a JFrame To resize an edge, JFrame gives a strategy JFrame.setSize(int width, int stature), it takes two parameters width and tallness. Here is what code looks like at this point package Example;rnimport java.awt.GraphicsConfiguration;rnimport javax.swing.JFrame;rnpublic class JFrameExample {rnstatic GraphicsConfiguration gc;rnpublic static void main(String[] args){rnJFrame frame= new JFrame(gc);rnframe.setTitle("Welecome to JavaTutorial.net");rnframe.setSize(600, 400);rnframe.setVisible(true); } } Resize a JFrame rnIn the wake of the setting size of a JFrame, you will see you can even now change it measure by essentially putting the cursor at the corners and dragging it. Or then again on the off chance that you press resize choice alongside close at the upper right corner, it will amplify to the measure of full screen. This Java Training in Bangalore happens on the grounds that resize is set valid as a matter of course. You can just make false as Shutting a JFrame rnYou can undoubtedly close your JFrame by tapping on the X (cross) at the upper left corner of JFrame. However JFrame.setDefaultCloseOperation (int) is a strategy gave by JFrame class, you can set the task that will happen when client taps on a cross. Java Training in Bangalore On the off chance that "0" is given as a parameter, JFrame won't close even subsequent to tapping on the cross.rnThe best practice is to utilize JFrame.EXIT_ON_CLOSE; it exits the application (JFrame) and discharges memory.rnJFrame.HIDE_ON_CLOSE: It doesn't close JFrame, basically conceals it.rnJFrame.DISPOSE_ON_CLOSE: It arranges the edge off, yet it continues running and expands memory.rnJFrame.DO_NOTHING_ON_CLOSE: It does nothing when client taps on close. Here’s how the final code looks like package Examplernimport java.awt.GraphicsConfiguration;rnimport javax.swing.JFrame;rnpublic class JFrameExample {rnstatic GraphicsConfiguration gc;rnpublic static void main(String[] args){rnJFrame frame= new JFrame(gc);rnframe.setTitle("Welecome to JavaTutorial.net");rnframe.setSize(600, 400);rnframe.setLocation(200, 200);rnframe.setVisible(true);rnframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rnframe.setResizable(false); } }

Further reading

Further Reading

4 total

Article

How Coaching Turns Knowledge Into Change Walk into any bookstore or scroll through your favorite podcast feed, and you’ll see the same thing: endless tips, strategies, and “life hacks” promising transformation.rnWe devour them. We highlight paragraphs. We even try to practice what we’ve learned. But somehow, the big shifts never stick. Weeks later, the old patterns creep back in.rnSo why does it happen? Why do so many smart, motivated people keep getting stuck — eve

October 6, 2025

Article

grinding and cutting a variety of materials across numerous industries. Understanding their construction, types and safety precautions is mandatory for anyone working with these powerful tools. This article will explore the basics of abrasive wheels, offering insights into their components, maintenance and legal requirements to ensure both effective and safe usage. Exploring the Basics of Abrasive Wheels Abrasive wheels are critical tools in various industrial applications, f

March 6, 2025

Article

The internet we use daily, known as the surface web, represents only a fraction of the entire digital landscape. Beneath this visible layer lies the deep web and the dark web, where anonymity, privacy, and unrestricted information exchange thrive. Among the most well-known directories for accessing dark web content is the Uncensored Hidden Wiki . This article delves into the history, significance, risks, and access methods of the Uncensored Hidden Wiki, providing a comprehens

January 31, 2025

Article

If you're searching for exceptional piano classes near you, there are several excellent options in Toronto to consider. For those eager to learn the piano, finding a school or instructor that offers expert guidance, comprehensive lesson plans, and a supportive environment is key. Catering to both beginners and advanced players, many schools in the Toronto area provide tailored lessons to help students achieve their musical aspirations. What to Look for in Piano Lessons When

January 1, 2025