Swing & awt 2 Flashcards
(64 cards)
What does EmptyBorder class do in Java Swing?
It provides transparent, empty space around a component to improve visual separation and readability.
The ___ class (found in ___) is a concrete implementation of the Border interface that provides __, __ around a component.
- EmptyBorder
- javax.swing.border
- transparent
- empty space
Its primary use is to add __ or __, improving the __ ___ and ___ of UI elements.
- padding or margins
- visual separation and readability
What are the problems with a monolithic approach to GUI development in Java?
It causes poor readability, reduced maintainability, and increases the risk of bugs in unrelated parts of the GUI.
___ arises when a single class has thousands of lines of code for various GUI elements, making it hard to identify specific actions or layouts, leading to __ and ___ tasks.
Lack of readability
- tedious
- error-prone
___: ___ or ___ in a large codebase increase the risk of introducing __ in unrelated GUI parts.
- Reduced Maintainability
- Bugs or new features
- defects
The solution lies in applying ___ principles, particularly ___, by defining separate classes for distinct GUI elements or functional parts of your interface.
- Object-Oriented Programming (OOP)
- encapsulation
What is the benefit of creating GUIs as separate classes?
It improves modularity, readability, maintainability, collaboration, and testability.
___ refers to the __ to which a system’s components can be __ and __. When you create GUIs as classes, you achieve __ modularity.
- Modularity
- degree
- separated and combined
- high modularity
What are the benefits of achieving high modularity?
- Improved Readability and Organization
- Enhanced Maintainability and Debugging
- Facilitates Team Collaboration
- Testability
___ : Each class has a ___, making the codebase easier to __ and __. Developers can quickly locate the relevant code for a specific __ element or feature.
- Improved Readability and Organization
- single responsibility
- navigate and understand
- specific UI
___ : Changes or bug fixes can be __ to a specific __ (class) without affecting unrelated parts of the GUI. This reduces the risk of introducing new __ and simplifies the __ process.
- Enhanced Maintainability and Debugging
- isolated
- specific module
- errors
- debugging
__ : In larger projects, different team members can work on separate __ classes concurrently, leading to more __ cycles and __ conflicts.
- Facilitates Team Collaboration
- GUI
- efficient development
- fewer merge
__: Individual __ components or __ can be more easily tested in __, promoting the creation of __ and reliable __.
- Testability
- GUI
- panels
- isolation
- creation of robust
- reliable UIs
It is used for password input. Characters typed are not shown.
- JPasswordField
What does the JPasswordField do?
It allows secure text input where characters appear as asterisks(*) or another character.
How do you import JPasswordField?
import javax.swing.JPasswordField;
What is the syntax for creating a JPasswordField with a specified width?
JPasswordField passwordField = new JPasswordField(int columns);
How wide the field is in number of characters (optional).
- columns
It is used when you want the user to enter multiple lines of text, like comments or descriptions.
- JTextArea
What component is used for multi-line text input?
- JTextArea
How do you import JTextArea?
- import javax.swing.JTextArea;
How do you declare a JTextArea?
JTextArea textArea = new JTextArea(int rows, int columns);
It lets users select multiple options from a list.
- JCheckBox