Class CustomPreferButton

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public class CustomPreferButton extends JButton
Custom JButton that allows users to add or remove items from their favorites. It updates its text and background color based on the favorite status of the item.
Author:
Riccardo Finocchiaro, Davide Galilei
See Also:
  • Constructor Details

  • Method Details

    • update

      public void update(boolean isFavorite)
      Updates the JButton text and background CustomColor based on the favorite status of the item. If the item is a favorite, it shows "Remove from Favorites" and sets the background to red. If not, it shows "Add to Favorites" and sets the background CustomColor to green.
      Parameters:
      isFavorite - true if the item is a favorite, false otherwise
      See Also:
    • setFavBehaviour

      public void setFavBehaviour(FavoriteBehaviour behaviour)
      Sets the behavior to execute when the JButton is clicked.
      Parameters:
      behaviour - the implementation of FavoriteBehaviour that defines the behavior for favorite actions.
      See Also:
    • setDataType

      public void setDataType(DataType mode)
      Sets the data type for the item associated with this JButton.
      Parameters:
      mode - set the DataType of the item, which can be one of the types defined in the DataType enum. This is used to determine the type of data the item represents, such as a route, user, or other entities.
      See Also:
    • setItemId

      public void setItemId(String itemId)
      Sets the ID and name of the item associated with this JButton. This is used to uniquely identify the item that the JButton is currently representing.
      Parameters:
      itemId - the unique identifier for the item
      See Also:
    • setItemName

      public void setItemName(String itemName)
      Sets the name of the item associated with this JButton. This is used to display the name of the item in the button text.
      Parameters:
      itemName - the name of the item
      See Also: