Mid Term Act1
Mid Term Act1
B. Swing Controls
1. Label
Properties: text – The string of text displayed by the label.
icon – An image displayed alongside or instead of the text.
horizontalAlignment – Aligns the text horizontally (left, center, right).
verticalAlignment – Aligns the text vertically (top, center, bottom).
horizontalTextPosition – Positions the text horizontally relative to the icon.
verticalTextPosition – Positions the text vertically relative to the icon.
font – Sets the font style (type, size, weight) of the text.
foreground – Changes the text color.
background – Sets background color, usually only visible if opaque is true.
opaque – If check, allows the background to be painted.
toolTipText – Shows help text when mouse hovers over the label.
name – Internal identifier used in code.
visible – Controls whether the label is shown or hidden.
enabled – If check, greys out the label and disables updates.
2. Check Box
Properties:
text – Label displayed beside the checkbox.
selected – Whether it’s initially checked or not.
icon – Image used instead of the checkbox box.
font – Font of the label.
foreground – Label text color.
background – Background behind the box and label.
border – Edge around the checkbox.
toolTipText – Mouse over help text.
name – Internal identifier.
visible – Controls visibility.
enabled – Determines if the box can be checked or unchecked.
3. Combo Box
Properties:
model – The list of items in the dropdown.
selectedItem – The item that is currently selected.
editable – Allows the user to type their own value if true.
font – Font of the text and items.
foreground – Color of the selected text.
background – Background of the dropdown.
toolTipText – Hover hint.
name – Internal reference.
visible – Show or hide combo box.
enabled – Enable or disable user interaction.
4. Text Area
Properties:
text – Text shown in the area.
columns – Width in character columns.
rows – Height in number of rows.
lineWrap – Enables automatic wrapping of long lines.
wrapStyleWord – Wraps at word boundaries instead of in the middle of words.
editable – Determines if the user can type or change the text.
font – Changes the font of the text.
foreground – Text color.
background – Background color.
border – Edge appearance.
toolTipText – Hover-help text.
name – Internal name for code reference.
visible – Controls visibility.
enabled – Enables or disables input.
5. Progress Bar
Properties:
value – Current progress.
minimum – Start value.
maximum – End value.
orientation – Horizontal/vertical.
stringPainted – Displays percentage as text.
foreground – Color of progress fill.
background – Background color.
font – Font of progress text.
toolTipText – Help on hover.
name – Code name.
visible – Show/hide.
enabled – Not interactive, just display.
6.Spinner
Properties:
model – The data model (numbers, dates, or list).
value – Current value displayed.
editor – Customizes text editor.
font – Font style.
foreground – Text color.
background – Background color.
toolTipText – Description on hover.
border – Border around spinner.
name – Reference name.
visible – Visibility toggle.
enabled – Enables or disables use.
7. Editor Pane
Properties:
contentType – Sets MIME type (e.g., text/html).
text – Content inside the editor.
editable – Whether user can change text.
font – Text font.
foreground – Text color.
background – Background color.
toolTipText – Hover description.
name – Reference name.
visible – Show/hide.
enabled – Enables/disables typing.
8. Button
Properties:
text – Text displayed on the button.
icon – Image shown on the button.
pressedIcon – Image displayed when the button is clicked.
rolloverIcon – Image shown when mouse hovers over the button.
selected – Sets whether the button appears selected (true or false).
enabled – Enables or disables the button (user can't click when false).
mnemonic – Sets a keyboard shortcut key (Alt + key).
actionCommand – Command string sent with events for identification.
font – Changes the text font on the button.
foreground – Changes the text color.
background – Changes the button’s background color.
border – Adds a border around the button.
toolTipText – Hint text when hovering over the button.
name – Internal name used in code.
visible – Shows or hides the button.
opaque – Determines whether the background is painted.
9. Radio Button
Properties:
text – Label displayed beside the button.
selected – If true, the button is selected.
buttonGroup – Grouping of buttons so only one can be selected.
icon – Image displayed with the button.
font – Text style.
foreground – Text color.
background – Background color.
border – Visual edge.
toolTipText – Hover-help text.
name – Code name.
visible – Shown or hidden.
enabled – Can or cannot be selected.
10. List
Properties:
model – The items in the list.
selectedIndex – The selected item’s index.
selectionMode – Allows single or multiple selection.
visibleRowCount – Number of visible rows without scrolling.
font – Font of list items.
foreground – Text color.
background – Background color.
border – Visual edge.
toolTipText – Help shown on hover.
name – Reference ID for coding.
visible – Show/hide the list.
enabled – Can/can’t interact with the list.
11. Scroll Bar
Properties:
value: The current scroll position.
minimum: The starting position of the scroll bar.
maximum: The ending position of the scroll bar.
orientation: Whether the scroll bar is horizontal or vertical.
visibleAmount: The amount of content that is visible in the viewport.
unitIncrement: The amount of scrolling when the user clicks the arrow buttons.
blockIncrement: The amount of scrolling when the user clicks the track area.
toolTipText: Text displayed when the user hovers over the scroll bar.
12. Formatted Field
Properties:
value – The formatted value.
formatterFactory – Defines the format (e.g., date, number).
editable – Allows user input.
font – Text style.
foreground – Text color.
background – Field color.
toolTipText – Hover help.
border – Field outline.
name – Used in code.
visible – Show/hide.
enabled – Enable/disable interaction.
13. Separator
Properties:
orientation – Vertical or horizontal line.
foreground – Line color.
background – Color behind line.
toolTipText – Description when hovering.
name – Code reference.
visible – Shows or hides the line.
enabled – Non-interactive, always enabled.
14. Tree
Properties:
model – Data model for nodes.
rootVisible – Whether the root node is shown.
showsRootHandles – Show +/- handles.
editable – Allows text editing of nodes.
font – Text style.
foreground – Node label color.
background – Tree background.
toolTipText – Description text.
border – Outline border.
name – Reference ID.
visible – Show/hide.
enabled – Allows selection or not.
15. Toggle Button
Properties:
text – Label text.
selected – Shows whether the button is toggled on or off.
icon – Icon shown with button.
pressedIcon – Icon when pressed.
rolloverIcon – Icon when hovered.
font – Font style of label.
foreground – Text color.
background – Background color.
border – Frame around the button.
toolTipText – Hint on hover.
name – Internal identifier.
visible – Show or hide toggle button.
enabled – Enable or disable interaction.
16. Button Group
Properties:
Contains no properties, but it’s used to group Radio Button so that only one button in the
group can be selected at a time.
17. Text Field
Properties:
text – The text displayed in the field.
columns – Number of character columns wide the field should be.
editable – If false, text can't be changed by the user.
font – Sets font of the text.
foreground – Sets the color of the text.
background – Sets the background color.
border – Sets the visual edge around the field.
toolTipText – Shows help text on mouse hover.
name – Reference name used in code.
visible – If false, hides the field.
enabled – If false, disables typing and greys out the field.
caretPosition – Position of the text cursor.
18. Slider
Properties:
value: The current slider position.
minimum: The minimum value of the slider.
maximum: The maximum value of the slider.
orientation: Whether the slider is horizontal or vertical.
majorTickSpacing: The spacing between major ticks.
minorTickSpacing: The spacing between minor ticks.
paintTicks: Whether to paint tick marks on the slider.
paintLabels: Whether to paint labels on the slider.
toolTipText: Text displayed when the user hovers over the slider.
19. Password Field
Properties:
echoChar – Character shown instead of actual password characters.
text – Gets/sets the value entered (not usually visible).
columns – Width in character columns.
editable – Allows or prevents user input.
font – Font of the characters.
foreground – Color of password dots or characters.
background – Field background color.
border – Visual edge.
toolTipText – Hover hint.
name – Reference name in code.
visible – Determines if the field is shown.
enabled – Allows or disallows typing.
20. Text Pane
Properties:
text: The content displayed in the text pane.
contentType: The type of content, such as plain text or HTML.
editable: Whether the text can be edited.
font: The font style of the text.
foreground: The color of the text.
background: The background color of the text pane.
toolTipText: Text displayed when the user hovers over the text pane.
21. Table
Properties:
model: The data model holding the table’s rows and columns.
rowHeight: The height of the rows in the table.
gridColor: The color of the grid lines.
selectionMode: The selection mode for rows (single or multiple).
font: The font style of the table’s text.
foreground: The color of the text in the table.
background: The background color of the table.
toolTipText: Text displayed when the user hovers over the table.
C. Swing Menus
1. Menu Bar
Properties:
background - The background color of the menu bar.
foreground - The color of the text in the menu bar.
font - The font style used for the text in the menu bar.
toolTipText - Text displayed when the user hovers over the menu bar.
border - Defines the border style around the menu bar.
menus - A list of Menu objects added to the menu bar.
2. Menu Item
Properties:
text - The label or name of the menu item.
icon - An image displayed alongside the menu item text.
mnemonic - The keyboard shortcut associated with the menu item.
accelerator - The key combination used to invoke the menu itme.
enabled - Determines whether the menu item is enabled (true) or disabled (false).
selected - Indicates whether the item is selected, for toggle items.
font - The font style for the menu item text.
foreground - The color of the text in the menu item.
background - The background color of the menu item.
toolTipText - Text displayed when the user hovers over the menu item.
3. Menu Item/Radio Button
Properties:
text - The label of the radio button item.
selected - Indicates whether the radio button is selected (true) or not (false).
mnemonic - The keyboard shortcut for the radio button item.
font - The font style of the radio button's text.
foreground - The color of the radio button's text.
background - The color of the radio button's background.
group - The Button Group this radio button belongs to.
toolTipText - The text shown when the user hovers over the radio button.
4. Separator
Properties:
foreground - The color of the separator line.
background - The background color behind the separator.
orientation - Defines whether the separator is vertical or horizontal.
toolTipText - Text displayed when the user hovers over the separator.
5. Menu
Properties:
text - The label of the menu.
font - The font style of the menu’s text.
foreground - The color of the menu’s text.
background - The background color of the menu.
mnemonic - The keyboard shortcut to open the menu.
enabled - Whether the menu is enabled or disabled.
toolTipText - Text displayed when the user hovers over the menu.
items - A collection of Menu Item objects that belong to this menu.
6. Menu Item / Check Box
Properties:
text - The label of the checkbox menu item.
selected - Indicates whether the checkbox is selected (checked) or deselected (unchecked).
mnemonic - The keyboard shortcut associated with the checkbox item.
font - The font style of the checkbox menu item’s text.
foreground - The color of the text in the checkbox menu item.
background - The background color of the checkbox menu item.
toolTipText - Text displayed when the user hovers over the checkbox item.
7. Popup Menu
items - A collection of Menu Item objects that make up the popup menu.
font - The font style for the popup menu items.
foreground - The color of the text in the popup menu items.
background - The background color of the popup menu.
enabled - Whether the popup menu is enabled or disabled.
toolTipText - Text displayed when the user hovers over the popup menu.
D. Swing Windows
1. Dialog
Properties:
background - The background color of the dialog window.
foreground - The color of the text in the dialog.
font - The font style used for the text in the dialog.
toolTipText - Text displayed when the user hovers over the dialog.
modal - Defines whether the dialog blocks input to other windows (true) or not (false).
title - The title of the dialog window.
size - Defines the size of the dialog.
location - The position of the dialog on the screen.
resizable - Whether the dialog is resizable by the user (true) or not (false).
visible - Whether the dialog is visible (true) or hidden (false).
defaultCloseOperation - Defines the operation when the dialog is closed.
2. File Chooser
Properties:
background - The background color of the file chooser.
foreground - The color of the text in the file chooser.
font - The font style used for the text in the file chooser.
toolTipText - Text displayed when the user hovers over the file chooser.
currentDirectory - The current directory the file chooser starts in.
selectedFile - The file that is selected in the file chooser.
fileFilter - A filter used to display files with specific extensions.
multiSelectionEnabled - Whether multiple files can be selected (true) or not (false).
dialogTitle - The title of the file chooser dialog window.
approveButtonText - The text of the button that approves the file selection.
3. Frame
Properties:
background - The background color of the frame.
foreground - The color of the text in the frame.
font - The font style used for the text in the frame.
toolTipText - Text displayed when the user hovers over the frame.
title - The title of the frame window.
size - Defines the size of the frame.
location - The position of the frame on the screen.
resizable - Whether the frame is resizable by the user (true) or not (false).
visible - Whether the frame is visible (true) or hidden (false).
iconImage - The image icon for the frame.
4. Option Pane
Properties:
background - The background color of the option pane.
foreground - The color of the text in the option pane.
font - The font style used for the text in the option pane.
toolTipText - Text displayed when the user hovers over the option pane.
message - The message displayed in the option pane.
optionType - The type of buttons to display (YES_NO_OPTION, and
OK_CANCEL_OPTION).
messageType - The type of message (ERROR_MESSAGE, or
INFORMATION_MESSAGE).
icon - The icon associated with the message in the option pane.
initialValue - The default selected value.
selectionValues - A list of values that are options to select from.
5. Color Chooser
Properties:
background - The background color of the color chooser dialog.
foreground - The color of the text in the color chooser.
font - The font style used for the text in the color chooser.
toolTipText - Text displayed when the user hovers over the color chooser.
selectedColor - The color currently selected in the color chooser.
customColors - The set of custom colors that the user has defined.
visible - Whether the color chooser is visible (true) or hidden (false).
dialogTitle - The title of the color chooser dialog window.
E. Swing Filters
1. Glue
Properties:
size - The flexible space that adapts to the remaining space available in the container. It can
adjust itself based on the container's layout.
2. Rigid Area
Properties:
width - The fixed width of the rigid area.
height - The fixed height of the rigid area.
size - The fixed dimensions (width and height) of the rigid area.
3. Horizontal Glue
Properties:
size - The flexible horizontal space that adjusts to the remaining horizontal space in the
container.
4. Vertical Glue
Properties:
size - The flexible vertical space that adjusts to the remaining vertical space in the container.
5. Horizontal Strut
Properties:
width - The fixed width of the horizontal strut. It remains constant.
6, Vertical Strut
Properties:
height - The fixed height of the vertical strut. It remains constant.