It inherits the JMenuItem class, and is a pull down menu component which is displayed from the menu bar. It inherits the JComponent class and provides space for an application which can attach any other component. It is used to add scroll bar, both horizontal and vertical. JTextField b = new JTextField("edureka") It inherits the JTextComponent class and it is used to allow editing of single line text. It inherits the AbstractButton class and is platform independent. Using the ActionListener it will result in some action when the button is pushed. Following are a few components with examples to understand how we can use them. Containers like JFrame and JDialog can only add a component to itself. Methods like setLayout override the default layout in each container. Basic swing components are the building blocks of any gui application. Containers are the windows like frame and dialog boxes. Does not support pluggable look and feelĮxplanation: All the components in swing like JButton, JComboBox, JList, JLabel are inherited from the JComponent class which can be added to the container classes.Panel – It is used to organize components on to a windowįrame – A fully functioning window with icons and titlesĭialog – It is like a pop up window but not fully functional like the frame For building GUI applications at least one container class is necessary.įollowing are the three types of container classes: Container ClassĪny classwhich has other components in it is called as a container class. This is helpful because we do not have to start from the scratch. It becomes easier to build applications since we already have GUI components like button, checkbox etc. It is platform independent unlike AWT and has lightweight components. It is build on top of the AWT API and entirely written in java. It is a part of the JFC( Java Foundation Classes). Swing in Java is a lightweight GUI toolkit which has a wide variety of widgets for building optimized window based applications. Following are the concepts discussed in this article: In this article, we will go through the concepts involved in the process of building applications using swing in Java. Putting together all these components makes a graphical user interface. It includes components like button, scroll bar, text field etc. It is used for creating window based applications. It returns the rootPane object for this frame.Swing in java is part of Java foundation class which is lightweight and platform independent. It sets the image to be displayed as the icon for this window. Provides a hint as to whether or not newly created JFrames should have their Window decorations (such as borders, widgets to close the window, title.) provided by the current look and feel. SetDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) It creates a JFrame with the specified title and the specified GraphicsConfiguration of a screen device.ĪddImpl(Component comp, Object constraints, int index)Ĭalled by the constructor methods to create the default rootPane.Ĭalled by the constructors to init the JFrame properly. JFrame(String title, GraphicsConfiguration gc) It creates a new, initially invisible Frame with the specified title. It creates a Frame in the specified GraphicsConfiguration of a screen device and a blank title. It constructs a new frame that is initially invisible. If true then calls to add and setLayout will be forwarded to the contentPane. The JRootPane instance that manages the contentPane and optional menuBar for this frame, as well as the glassPane. The exit application default window close operation. This class implements accessibility support for the JFrame class. Unlike Frame, JFrame has the option to hide or close the window with the help of setDefaultCloseOperation(int) method. JFrame works like the main window where components like labels, buttons, textfields are added to create a GUI. The class is a type of container which inherits the class.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |