Overview of the Swing library in Java:
The part of the Java system that contains classes that enable less structured information to be input and output is known as the Swing library. It contains pre-built classes of graphical interface elements. While it is possible to build an interface from scratch using the basic drawing primitives (rectangle, line, text) you will, for simplicity and consistency, mainly rely on the tools that the Java language provides.
As with other parts of this course, we do not aim to provide a fully comprehensive coverage of all of the Swing classes. There are numerous Swing classes, which contain many methods, but this unit will provide you with enough knowledge and experience to use the javax.swing class library and other related libraries.
The Swing library is an extension of Java's Abstract Windowing Toolkit (AWT). The AWT is the part of the Java run-time system that is responsible for user interaction with window objects. The AWT does have its own set of visual components but, among other things, they suffer from the disadvantage of not looking the same on all platforms. This is due to the display of the components being closely tied to the underlying operating system. In this course, we will make use of components from the Swing library only, although we will need to import parts of the underlying AWT library.
The Swing library components look the same on every platform and so you do not have to worry about any inconsistencies between platforms. Unlike the AWT components, Swing components are not so closely tied to the underlying operating system.
Swing can be broken down into groups of related classes. In this section, we will make a quick tour of each of the following groups and then return to them later by describing some small examples that illustrate them.
- Containers. A container is a component that can hold other components. Among the containers provided by Swing we will use two in particular; these are JFrame and JPanel. The class JFrame maintains a Container called the content pane. This contains all of the visual components, including other containers such as JPanel, through which the user interacts with the computer program. A panel groups elements in an area of a window and is then added to a JFrame component.
- Layout managers. These are used with containers to arrange embedded components into a particular layout style; for example, laying the components out in a grid. The various layout managers are used to ensure consistent spacing or alignment and include BorderLayout, FlowLayout, GridLayout, GridBagLayout and BoxLayout. You will meet a number of these in this unit.
- Visual components. This group of components provides the means by which users will usually interact with your applications. They include controls such as buttons. They form the backbone of the Swing library and will be the building blocks of most Java applications that require user interfaces.
The Swing library classes have class names that start with a J, such as JButton or JMenuBar. An exception is AbstractButton, which is part of Swing, but doesn't start with a J. As this diagram shows, the Swing components inherit a great deal of their methods and behaviours from other classes. When you use the Java API library to look up methods and behaviours of components, you should also look at the classes from which a component inherits.
There are a number of aspects to programming an interface:
1 the GUI components that you use;
2 the way that these components are laid out on a screen;
3 the way that the program that uses the interface responds to events that occur with an interface, such as a mouse being clicked or text being entered into a text field.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Overview of the Swing library in Java homework and assignments? Live Overview of the Swing library in Java experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Overview of the Swing library in Java homework help, java assignment help and Overview of the Swing library in Java projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours