

It inherits the JComponent class and is used to show pop up menu of choices. It is used for placing text in a container. It inherits JComponent class, the object of JList class represents a list of text items.ĭefaultListModel l = new DefaultListModel() 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.
#Java gui popup window windows#
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. Swing in java is part of Java foundation class which is lightweight and platform independent.
