Mid Term Act1
Mid Term Act1
B. Swing Controls
1. Label
Properties:
text - Is the string of text shown by the label.
icon - Is an image displayed next to or instead of the text.
horizontalAlignment - Aligns the text left, center, or right.
verticalAlignment - Aligns the text top, center, or bottom.
horizontalTextPosition - Sets the position of the text relative to the icon horizontally.
verticalTextPosition - Sets the position of the text relative to the icon vertically.
foreground - Changes the color of the text.
background - Sets the background color.
opaque - Allows the background to be painted.
toolTipText - Shows help text when you hover the mouse over the label.
name - Is Label’s code name.
visible - Controls whether the label is shown or hidden.
enabled -Enable or Disable the label.
2. Check Box
Properties:
text - Is the label shown beside the checkbox.
selected - Determines if the checkbox is initially checked or not.
icon - Is an image used instead of the standard checkbox box.
font - Sets the font of the label.
foreground - Changes the label text color.
background - Sets the background color behind the checkbox and label.
border - Adds an edge around the checkbox.
toolTipText - Shows help text when you hover over the checkbox
name - Is Check Box’s code name
visible - Controls whether the checkbox is visible or hidden
enabled - Turns the user interaction on and off.
3. Combo Box
Properties:
model - Is the list of items in the dropdown.
selectedItem - Is the item currently selected.
editable - Allows the user to type their own value if true.
font - Sets the font for the text and items.
foreground - Changes the color of the selected text.
background - Sets the background color of the dropdown..
toolTipText - Shows a hint when you hover over the dropdown.
name - Is Combo Box’x code name.
visible - Controls whether the combo box is shown or hidden.
enabled - Enables or disables user interaction with the combo box.
4. Text Area
Properties:
text - Is the text shown in the area.
columns - Sets the width in character columns.
rows - Sets the height in number of rows.
lineWrap - Enables automatic wrapping of long lines.
wrapStyleWord - Wraps text 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 - Changes the color of the text.
background - Sets the background color.
border - Adds an edge around the text area.
toolTipText - Shows help text when you hover over the area.
name - Is Text Area’s code name.
visible - Controls whether the text area is shown or hidden.
enabled - Turns the user interaction on and off.5. Progress Bar
Properties:
value - Is the current progress shown.
minimum - Sets the starting value of the progress.
maximum - Sets the ending value of the progress.
orientation - Sets whether the bar is horizontal or vertical.
stringPainted - Shows the progress percentage as text.
foreground - Sets the color of the progress fill.
background - Sets the background color behind the bar.
font - Changes the font of the progress text.
toolTipText - Shows help text when you hover over the progress bar.
name - Is Progress Bar’s code name.
visible - Controls whether the progress bar is shown or hidden.
enabled -Useless, since the progress bar is just for display.
6.Spinner
Properties:
model - Is the data used in the spinner like numbers, dates, or a list.
value - Is the current value shown in the spinner.
editor - Customizes how the text is shown or edited.
font - Sets the font style of the text.
foreground - Changes the text color.
background - Sets the background color.
toolTipText - Shows a description when you hover over the spinner.
border - Adds an edge around the spinner.
name - Is Spinner code name.
visible - Controls whether the spinner is shown or hidden.
enabled - Turns the user interaction on and off.
7. Editor Pane
Properties:
contentType - Sets the type of content, like plain text, etc.
text - Is the content shown inside the editor.
editable - Controls whether the user can change the text.
font - Sets the font of the text.
foreground - Changes the text color.
background - Sets the background color.
toolTipText - Shows a description when you hover over the editor.
name - Is Editor Pane’s code name.
visible - Controls whether the editor is shown or hidden.
enabled - Turns typing on or off.
8. Button
Properties:
text - Is the text shown on the button.
icon - Is the image displayed on the button.
pressedIcon - Is the image shown when the button is clicked.
rolloverIcon - Is the image shown when you hover the mouse over the button.
selected - Sets whether the button looks selected or not
enabled - Turns the button on or off.
mnemonic - Sets a keyboard shortcut key.
actionCommand - Is a string used to identify what the button does when clicked.
font - Changes the font of the button text.
foreground - Changes the color of the text.
background - Sets the button’s background color.
border - Adds a border around the button.
toolTipText - Shows a hint when you hover over the button.
name - Is Button’s code name.
visible - Shows or hides the button.
opaque - Controls whether the background color is visible or not.
9. Radio Button
Properties:
text - Label displayed beside the button.
selected - sets whether the button is selected.
buttonGroup - links buttons together so only one can be selected at a time
icon - Image displayed with the button.
font - Text style.
foreground - Text color.
background - Background color.
border - Adds border around the button.
toolTipText - shows help text when you hover over the button.
name - Code name.
visible - Shown or hidden.
enabled - Can or cannot be selected.
10. List
Properties:
model - Is the list of items shown.
selectedIndex - Is the position of the selected item.
selectionMode - Sets whether you can select one or multiple items.
visibleRowCount - Controls how many rows are shown without scrolling.
font - Text style.
foreground - Changes the color of the text
background - Sets the background color.
border - Adds a border around the list.
toolTipText - Shows help text when you hover over the list.
name - Code name.
visible - Shown or hidden.
enabled - Lets you turn interaction with the list on or off.
11. Scroll Bar
Properties:
value - Is the current scroll position.
minimum - Is the starting position of the scroll bar.
maximum - Is the ending position of the scroll bar.
orientation - Sets whether the scroll bar is horizontal or vertical.
visibleAmount - Is how much content is visible at one time.
unitIncrement - Is how far the scroll moves when clicking the arrow buttons.
blockIncrement - Is how far the scroll moves when clicking the track area.
toolTipText - Shows text when you hover over the scroll bar.
12. Formatted Field
Properties:
value - The formatted value.
formatterFactory - Defines the format like date, number.
editable - Allows user input.
font - Text style.
foreground - Text color.
background - Background Color.
toolTipText - Shows text when you hover over the scroll bar.
border - Visual Edge.
name - Code Name.
visible - Show or hide.
enabled - Enable or disable interaction.
13. Separator
Properties:
orientation - Vertical or horizontal line.
foreground - Line color.
background - Color behind line.
toolTipText - Description when hovering.
name - Code Name.
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 - Helpful Description when hovering.
border - Outline border.
name - Code Name.
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 - Helpful Description when hovering.
name - Code Name.
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 -Allows user to change the text.
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 - Code Name.
visible - Show or hide the Text Field.
enabled - Enable or disable interaction.
caretPosition - Position of the text cursor.
18. Slider
Properties:
value - Is the current position of the slider.
minimum - Is the lowest value the slider can have.
maximum - is the highest value the slider can reach.
orientation - Sets if the slider is horizontal or vertical.
majorTickSpacing - Sets the distance between big tick marks.
minorTickSpacing - Sets the distance between small tick marks.
paintTicks - Shows or hides the tick marks on the slider.
paintLabels - Shows or hides number labels on the slider.
toolTipText - Shows a hint when you hover over the slider.
19. Password Field
Properties:
echoChar - Character shown instead of actual password characters.
text - Gets or sets the password value.
columns - Width in character columns.
editable - Allows user input.
font - Font of the characters.
foreground - Color of password dots or characters.
background - Field background color.
border - Frame around Password Field.
toolTipText - Shows help text on mouse hover.
name - Code Name.
visible - Shows or hidden.
enabled - Allows or disallows typing.
20. Text Pane
Properties:
text - The content displayed in the text pane.
contentType - The type of content.
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 - Shows help text on mouse hover.
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.
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 - Shows help text on mouse hover.
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 - Shows help text on mouse hover.
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 item.
enabled - Enable or disable Menu Item.
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 - Shows help text on mouse hover.
3. Menu Item/Radio Button
Properties:
text - The label of the radio button item.
selected - Indicates whether the radio button is selected or not.
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 - Shows help text on mouse hover.
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 - Displays helpful text 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 - Displays helpful text 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 or deselected.
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 - Display helpful text 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 or not.
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 or not
visible - Whether the dialog is visible or hidden
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 - Display helpful text 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 or not.
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 or not.
visible - Whether the frame is visible or hidden.
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 or no or ok and 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 or hidden.
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.