-
-
Notifications
You must be signed in to change notification settings - Fork 0
How use the component
Vincenzo Palazzo edited this page May 27, 2020
·
2 revisions
How described in introduction chapter my object on this component is to implements the same Android API in Swing, in version 0.1-rc1 this is not real but contains different methods and different names, It mean that some methods change change in the future.
The basic way to declare a SwingSnackBar is
SnackBar.make(frame, "Swing SnackBar", "OPEN").run();
While in Android
Snackbar.make(v, "Android SnackBar", Snackbar.LENGTH_LONG).show();
The difference is on the constructor, the Android take the time to show the component, however with Swing you should be pass the Button text, such as: "CLOSE", "OPEN". In addition with SwingSnackBar is possible pass also the button icon. For example, with this code:
Icon close = MaterialImageFactory.getInstance().getImage(
GoogleMaterialDesignIcons.CLOSE,
MaterialColors.RED_600
);
snackBar = SnackBar.make(frame, "Swing Snackbar?", close).run();
P.S: In this example is used material-ui-swing to generate the icon, but you can use personal Icons.
-
make(Windows, String, Icon)
: This method return a SwingSnackBar, it is created with a owner component (For example JFrame), Content text (String), personal Icon on the button.
public static SnackBar make(Window contextView, String withMessage, Icon icon)
-
make(Window, String, JLabel)
: This method return a SwingSnackBar, it is created with a owner component (For example JFrame), Content text (String), Button style (JLabel with personal color and font style).
public static SnackBar make(Window contextView, String withMessage, JLabel labelWithIconOrText)
-
make(Window, String, String)
: This method return a SwingSnackBar, it is created with a owner component (For example JFrame), Content text (String), Button text.
public static SnackBar make(Window contextView, String withMessage, String iconText)
-
public SnackBar setText(String text)
: Set content text inside the SnackBar. -
public SnackBar setIcon(Icon icon)
: Set button icon inside SnackBar. -
public SnackBar setSnackBarBackground(Color color)
: Change background color, don't use setBackground -
public SnackBar setSnackBarForeground(Color color)
: Change foreground color, don't use setForeground -
public SnackBar setBorder(Border border)
: Set border inside SnackBar content, Pay attention. -
public SnackBar setIconTextStyle(Font font)
: Set personal font to Button component. -
public SnackBar setIconTextColor(Color color)
; Set personal color to button component. -
public SnackBar setDuration(int duration)
: Set how much time the component should show on display.-
SnackBar.LENGTH_LONG
: 8000 milliseconds; -
SnackBar.LENGTH_SHORT
: 5000 milliseconds; -
SnackBar.LENGTH_INDEFINITE
: Value is -1;
-
-
public SnackBar setAction(AbstractSnackBarAction action)
: set button action on click.-
AbstractSnackBarAction
: Is a MouseListener where the only method to implement isonClick
, you can override also the methods:mouseClicked
,mouseReleased
,mouseEntered
,mouseExited
-
-
public SnackBar setPosition(SnackBarPosition position)
: Set component position.-
SnackBar.TOP
: To owner center in the top position. -
SnackBar.TOP_LEFT
: To owner left in the top position, if there isn't space, it will paint on TOP position. -
SnackBar.TOP_RIGHT
: To owner right in the top position, if there isn't space, it will paint on TOP position. -
SnackBar.BOTTOM
: To owner center in the bottom position. -
SnackBar.BOTTOM_LEFT
: To owner left in the bottom position, if there isn't space, it will paint on BOTTOM position. -
SnackBar.BOTTOM_RIGHT
: To owner right in the bottom position, if there isn't space, it will paint on BOTTOM position.
-