public final class Util extends Object
This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.
Modifier and Type | Field and Description |
---|---|
static int |
JAVA_MAJOR_VERSION |
static int |
JAVA_MINOR_VERSION |
static BFOLogger |
LOGGER |
Modifier and Type | Method and Description |
---|---|
static boolean |
canUseComposites()
Return true if the AWT can use custom Composites.
|
static TransferHandler |
createTransferHandler(PDFViewer viewer)
Return the TransferHandler to use when copying/pasting text.
|
static void |
displayThrowable(Throwable throwable,
Component parent)
Display an Error message, including the stack trace
|
static String |
encodeColor(Color c)
Return the standard #RRGGBB representation of a Color
|
static JFileChooser |
fixFileChooser(JFileChooser chooser)
Attempt to repair a reported bug in the AWT classes where Icons returned
from this class a null, causing a NPE deep inside the JFileChooser UI
classes.
|
static void |
fixScrollPaneKeyBindings(JScrollPane scrollpane)
Remove the pageup/pagedown key bindings from ScrollPanes - they're clashing
with the pageup/pagedown we're mapping on the DocumentPanel
|
static JTextField |
getJFileChooserFileName(JFileChooser chooser)
Return the JTextField containing the current filename from the JFileChooser,
or null if this can't be determined for the current look-and-feel.
|
static JComponent |
getRootAncestor(JComponent c)
Get the top-level JComponent above the specified one - typically a JApplet, JWindow or JFrame
|
static int |
getScreenResolution(Component comp)
Get the screen resolution.
|
static String |
getUIString(String key)
Return a UIManager string field.
|
static String |
getUIString(String key,
String field1)
Return a UIManager string field with the specified fields replaced
|
static String |
getUIString(String key,
String field1,
String field2)
Return a UIManager string field with the specified fields replaced
|
static boolean |
hasFilePermission()
Return true if the viewer can access the local filesystem
|
static boolean |
isBrowserApplet(Component c)
Return true if the viewer is running as an Applet inside a web browser, false otherwise
|
static boolean |
isJavaFX(Component o)
Return true if the specified component is contained within a JavaFX component
|
static boolean |
isJNLP(Component c)
Return true if the specified component is running in a JNLP environment, false otherwise
|
static boolean |
isLAFAqua()
Return true if the LAF uses the Aqua toolkit (OS X)
|
static boolean |
isLAFGTK()
Return true if the LAF uses the GTK+ toolkit (UNIX)
|
static boolean |
isLAFMetal()
Return true if the LAF uses the Metal toolkit
|
static boolean |
isLAFNimbus()
Return true if the LAF uses the Nimbus toolkit
|
static boolean |
isLAFWindows()
Return true if the LAF uses the Window toolkit
|
static boolean |
isStandaloneApplet(Component c)
Return true if the viewer is running as an Applet that has been dragged outside of the
web browser, false otherwise.
|
static JDialog |
newJDialog(Component comp,
String title,
boolean modal)
Create a dialog for the specified component.
|
static boolean |
openURL(URL url,
Component c)
Display a URL in a web browser, if possible
|
static boolean |
patchJFileChooser(JFileChooser chooser,
JComponent patch,
boolean add)
Insert an "Option pane" into the JFileChooser.
|
static void |
setAutoFocusComponent(JComponent component)
Set the supplied component to gain focus when it's newly displayed, even inside
a sub-pane in a popup window.
|
static void |
setCanUseComposites(boolean comp) |
static URL |
toURL(DocumentPanel docpanel,
String path)
Attempt to convert a relative URL to an absolute one.
|
public static final BFOLogger LOGGER
public static final int JAVA_MAJOR_VERSION
public static final int JAVA_MINOR_VERSION
public static void displayThrowable(Throwable throwable, Component parent)
throwable
- the Throwable object this error relates toparent
- the parent component (not used)public static boolean isLAFAqua()
public static boolean isLAFGTK()
public static boolean isLAFNimbus()
public static boolean isLAFWindows()
public static boolean isLAFMetal()
public static boolean isBrowserApplet(Component c)
c
- the Componentpublic static boolean isStandaloneApplet(Component c)
c
- the Componentpublic static boolean isJavaFX(Component o)
o
- the Componentpublic static boolean isJNLP(Component c)
c
- the Componentpublic static boolean openURL(URL url, Component c)
url
- the URL to openc
- the Componentpublic static String getUIString(String key)
public static String getUIString(String key, String field1)
key
- the message key,field1
- the field to be substituted for {1}public static String getUIString(String key, String field1, String field2)
key
- the message key,field1
- the field to be substituted for {1}field2
- the field to be substituted for {2}public static void fixScrollPaneKeyBindings(JScrollPane scrollpane)
public static URL toURL(DocumentPanel docpanel, String path)
public static boolean hasFilePermission()
public static String encodeColor(Color c)
public static int getScreenResolution(Component comp)
public static JDialog newJDialog(Component comp, String title, boolean modal)
Create a dialog for the specified component. This will search up the Swing hierarchy until the first Frame, Dialog or Window is found and return a dialog on that object. This caters for situations where the viewer itself is running in a JDialog.
Note the JDialog(Window) constructor will do the same, but that's Java 6 only.
comp
- the Component creating the dialogtitle
- the title of the dialog, or null
for no titlemodal
- whether the dialog is to be modal or not.public static JFileChooser fixFileChooser(JFileChooser chooser)
public static TransferHandler createTransferHandler(PDFViewer viewer)
RichTextTransferHandler
, but this
can be overridden by setting the property "TransferHandler" on
the PDFViewer PropertyManager
.
to the full class-name of the TransferHandler.public static void setAutoFocusComponent(JComponent component)
component
- the componentpublic static boolean patchJFileChooser(JFileChooser chooser, JComponent patch, boolean add)
public static JTextField getJFileChooserFileName(JFileChooser chooser)
public static JComponent getRootAncestor(JComponent c)
public static void setCanUseComposites(boolean comp)
public static boolean canUseComposites()
Copyright © 2001-2017 Big Faceless Organization