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 what is the use of Swing AWT, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Swing AWT Learning
The user interface of the program is designed using Swing AWT library. Most of them use the JFRAME window.
Inheritance structure of JFRAME:
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
Custom a class, create an instance of JFRAME (object) to call JFRAME methods, in order to design the interface window
// MyWindow: //Introduction of class libraries import java.awt.*; //class to be used by JFrame import java.awt.event.*; //event class import javax.swing.*; //contains JFrame class MyWindow{ JFrame jframe=new JFrame();//Create object JMenuBar jmb=new JMenuBar();//Create menu bar object JMenu jm1,jm2,jm3;//Menu JMenuItem jmi1,jmi2,jmi3,jmi4;//Menu item public MyWindow (String title){//construct initialization jframe.setTitle(title); //set title jframe.setSize (new Dimension(200,180));//Define window size} //Define methods, add menu bars and other controls viod setMyMenuBar(){ //Define menus jm1=new JMenu(File); jm2=new JMenu(Edit); jm3=new JMenu(Help);//add to menu bar jmb.add(jm1); jmb.add(jm2); jmb.add(jm3); //add menu items jm1.add(jmi1=new JMenuItme("Open")); jm1.add(jmi2=new JMenuItme("Exit")); jm2.add(jmi3=new JMenuItme("Copy")); jm3.add(jmi4=new JMenuItme("About")); . . . //add menu bar to window jframe.setJMenuBar(jmb); jframe.pack(); jframe.setVisible(true); } //Other methods... public static viod main(String args[]){ MyWindow mywin=new MyWindow("My Window"); mywin.setMyMenuBar(); } } Thank you for reading this article carefully. I hope that the article "Swing AWT is useful" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
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.