Module jEdit

Class GenericGUIUtilities

java.lang.Object
org.gjt.sp.util.GenericGUIUtilities

public class GenericGUIUtilities extends Object
Various GUI utility functions not depending on jEdit, for use in StandaloneTextArea.
Version:
$Id: GenericGUIUtilities.java 25107 2020-03-31 22:37:06Z kpouer $
Author:
Slava Pestov, Eric Le Lay
  • Constructor Details

    • GenericGUIUtilities

      public GenericGUIUtilities()
  • Method Details

    • prettifyMenuLabel

      public static String prettifyMenuLabel(String label)
      `Prettifies' a menu item label by removing the `$' sign. This can be used to process the contents of an action.label property.
      Parameters:
      label - the label
      Returns:
      a pretty label
      Since:
      jEdit 5.3.1
    • setAutoMnemonic

      public static void setAutoMnemonic(AbstractButton button)
      Sets the mnemonic for the given button using jEdit convention, taking the letter after the dollar.
      Parameters:
      button - The button to set the mnemonic for.
      Since:
      jEdit 5.3.1
    • adjustForScreenBounds

      public static void adjustForScreenBounds(Rectangle desired)
      Gives a rectangle the specified bounds, ensuring it is within the screen bounds.
      Since:
      jEdit 5.3.1
    • requestFocus

      public static void requestFocus(Window win, Component comp)
      Focuses on the specified component as soon as the window becomes active.
      Parameters:
      win - The window
      comp - The component
      Since:
      jEdit 5.3.1
    • isPopupTrigger

      public static boolean isPopupTrigger(MouseEvent evt)
      Returns if the specified event is the popup trigger event. This implements precisely defined behavior, as opposed to MouseEvent.isPopupTrigger().
      Parameters:
      evt - The event
      Since:
      jEdit 5.3.1
    • isLeftButton

      public static boolean isLeftButton(MouseEvent evt)
      Parameters:
      evt - A mouse event
      Since:
      jEdit 5.6
    • isMiddleButton

      @Deprecated public static boolean isMiddleButton(int modifiers)
      Parameters:
      modifiers - The modifiers flag from a mouse event
      Since:
      jEdit 5.3.1
    • isMiddleButton

      public static boolean isMiddleButton(MouseEvent evt)
      Parameters:
      evt - A mouse event
      Since:
      jEdit 5.6
    • isRightButton

      @Deprecated public static boolean isRightButton(int modifiers)
      Deprecated.
      Parameters:
      modifiers - The modifiers flag from a mouse event
      Since:
      jEdit 5.3.1
    • isRightButton

      public static boolean isRightButton(MouseEvent evt)
      Parameters:
      evt - A mouse event
      Since:
      jEdit 5.6
    • getScreenBounds

      public static Rectangle getScreenBounds()
      Returns the screen bounds, taking into account multi-screen environments.
      Since:
      jEdit 5.3.1
    • showPopupMenu

      public static void showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
      Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
      Parameters:
      popup - The popup menu
      comp - The component to show it for
      x - The x co-ordinate
      y - The y co-ordinate
      Since:
      jEdit 4.0pre1, jEdit 5.3.1
      See Also:
    • showPopupMenu

      public static void showPopupMenu(JPopupMenu popup, Component comp, int x, int y, boolean point)
      Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
      Parameters:
      popup - The popup menu
      comp - The component to show it for
      x - The x co-ordinate
      y - The y co-ordinate
      point - If true, then the popup originates from a single point; otherwise it will originate from the component itself. This affects positioning in the case where the popup does not fit onscreen.
      Since:
      jEdit 5.3.1
    • isAncestorOf

      public static boolean isAncestorOf(Component comp1, Component comp2)
      Returns if the first component is an ancestor of the second by traversing up the component hierarchy.
      Parameters:
      comp1 - The ancestor
      comp2 - The component to check
      Since:
      jEdit 5.3.1
    • getParentDialog

      public static JDialog getParentDialog(Component c)
      Traverses the given component's parent tree looking for an instance of JDialog, and return it. If not found, return null.
      Parameters:
      c - The component
      Since:
      jEdit 5.3.1
    • setEnabledRecursively

      public static void setEnabledRecursively(Container c, boolean enabled)
      Call setEnabled() recursively on the container and its descendants.
      Parameters:
      c - The container
      enabled - The enabled state to set
      Since:
      jEdit 5.3.1
    • setButtonContentMargin

      public static void setButtonContentMargin(AbstractButton button, Insets margin)
      Sets the content margin of a button (for Nimbus L&F).
      Parameters:
      button - the button to modify
      margin - the new margin
      Since:
      jEdit 5.3.1
    • makeSameSize

      public static void makeSameSize(Component... components)
      Makes components the same size by finding the largest width and height of the given components then setting all components to that width and height. This is especially useful for making JButtons the same size.
      Parameters:
      components - The components to make the same size.
      Since:
      jEdit 5.3.1
    • defaultTableCellSize

      public static Dimension defaultTableCellSize()
      JTable cell size, based on global defaults.
      Since:
      jEdit 5.3.1
    • defaultColumnWidth

      public static int defaultColumnWidth()
      Column width for JTable, based on global defaults.
      Since:
      jEdit 5.3.1
    • defaultRowHeight

      public static int defaultRowHeight()
      Row height for JTable, based on global defaults.
      Since:
      jEdit 5.3.1