Package com.reportmill.panels
Class UIUtils
java.lang.Object
com.reportmill.panels.UIUtils
A utility class for UI related needs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Initiates Drag and Drop for the given image with the list of mouse events.static void
dragString
(String aString, List events) Drags a String from any component, given a MouseEvent and the string.static String
format
(float value) Returns the given float value as a simple formatted string.static String
getString
(Transferable aTrans) Returns a string from given transferable.static void
Tries to open the given file name with the platform reader.static void
Tries to open the given URL with the platform reader.static String
showChooser
(boolean save, Component aComp, String aDesc, Object oneOrMoreExtensions) Runs a file chooser that remembers last open file and size.static String
showChooser
(boolean save, Component aComp, String aDesc, Object oneOrMoreExtensions, Class chooserClass) Runs a file chooser that remembers last open file and size.static void
showPopupMenu
(JPopupMenu aMenu, Component anOwner, int targetX, int targetY) Show a popup menu at the given coords, adjusting if necessary to ensure that full menu appears within screen bounds.static void
translateRectToDropDestination
(RMRect dragShapeBounds, RMPoint overShapePt) Set the origin of the rect to match the image being dragged around.
-
Constructor Details
-
UIUtils
public UIUtils()
-
-
Method Details
-
format
Returns the given float value as a simple formatted string. -
openFile
Tries to open the given file name with the platform reader. -
openURL
Tries to open the given URL with the platform reader. -
showChooser
public static String showChooser(boolean save, Component aComp, String aDesc, Object oneOrMoreExtensions) Runs a file chooser that remembers last open file and size. -
showChooser
public static String showChooser(boolean save, Component aComp, String aDesc, Object oneOrMoreExtensions, Class chooserClass) Runs a file chooser that remembers last open file and size.- Parameters:
save
- true if you intend to store into the resulting file, false otherwiseaComp
- a swing component that will go modalaDesc
- a description of the file(s) you are filtering foroneOrMoreExtensions
- a String or array of string with acceptable file extension(s)chooserClass
- an optional subclass of JFileChooser (you can pass null for JFileChooser)- Returns:
- the selected path if the user chose a valid file (null otherwise)
-
showPopupMenu
Show a popup menu at the given coords, adjusting if necessary to ensure that full menu appears within screen bounds. -
getString
Returns a string from given transferable. -
dragString
Drags a String from any component, given a MouseEvent and the string. -
dragImage
Initiates Drag and Drop for the given image with the list of mouse events. -
translateRectToDropDestination
Set the origin of the rect to match the image being dragged around.Right now this is used to handle the fact that the position of the drag image in relationship to the cursor is different depending on whether the image dragging is being done by the system or by us. It can also be used at some point if we want to make the image dragged from where it was clicked on initially, instead of in the middle (in the system drag case).
-