Exemplo n.º 1
0
  private Insets getButtonInsets(SynthContext context, Insets insets) {
    // The following calculations are derived from gtkbutton.c
    // (GTK+ version 2.8.20), gtk_button_size_allocate() method.
    int CHILD_SPACING = 1;
    int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
    int xThickness = getXThickness();
    int yThickness = getYThickness();
    int w = focusSize + focusPad + xThickness + CHILD_SPACING;
    int h = focusSize + focusPad + yThickness + CHILD_SPACING;
    insets.left = insets.right = w;
    insets.top = insets.bottom = h;

    Component component = context.getComponent();
    if ((component instanceof JButton)
        && !(component.getParent() instanceof JToolBar)
        && ((JButton) component).isDefaultCapable()) {
      // Include the default border insets, but only for JButtons
      // that are default capable.  Note that
      // JButton.getDefaultCapable() returns true by default, but
      // GtkToolButtons are never default capable, so we skip this
      // step if the button is contained in a toolbar.
      Insets defaultInsets =
          getClassSpecificInsetsValue(context, "default-border", BUTTON_DEFAULT_BORDER_INSETS);
      insets.left += defaultInsets.left;
      insets.right += defaultInsets.right;
      insets.top += defaultInsets.top;
      insets.bottom += defaultInsets.bottom;
    }

    return insets;
  }
Exemplo n.º 2
0
  /*
   * Fix for BugTraq ID 4041703.
   * Set the focus to a reasonable default for an Applet.
   */
  private void setDefaultFocus() {
    Component toFocus = null;
    Container parent = getParent();

    if (parent != null) {
      if (parent instanceof Window) {
        toFocus = getMostRecentFocusOwnerForWindow((Window) parent);
        if (toFocus == parent || toFocus == null) {
          toFocus = parent.getFocusTraversalPolicy().getInitialComponent((Window) parent);
        }
      } else if (parent.isFocusCycleRoot()) {
        toFocus = parent.getFocusTraversalPolicy().getDefaultComponent(parent);
      }
    }

    if (toFocus != null) {
      if (parent instanceof EmbeddedFrame) {
        ((EmbeddedFrame) parent).synthesizeWindowActivation(true);
      }
      // EmbeddedFrame might have focus before the applet was added.
      // Thus after its activation the most recent focus owner will be
      // restored. We need the applet's initial focusabled component to
      // be focused here.
      toFocus.requestFocusInWindow();
    }
  }
Exemplo n.º 3
0
 /**
  * Returns the value to initialize the opacity property of the Component to. A Style should NOT
  * assume the opacity will remain this value, the developer may reset it or override it.
  *
  * @param context SynthContext identifying requestor
  * @return opaque Whether or not the JComponent is opaque.
  */
 @Override
 public boolean isOpaque(SynthContext context) {
   Region region = context.getRegion();
   if (region == Region.COMBO_BOX
       || region == Region.DESKTOP_PANE
       || region == Region.DESKTOP_ICON
       || region == Region.EDITOR_PANE
       || region == Region.FORMATTED_TEXT_FIELD
       || region == Region.INTERNAL_FRAME
       || region == Region.LIST
       || region == Region.MENU_BAR
       || region == Region.PANEL
       || region == Region.PASSWORD_FIELD
       || region == Region.POPUP_MENU
       || region == Region.PROGRESS_BAR
       || region == Region.ROOT_PANE
       || region == Region.SCROLL_PANE
       || region == Region.SPINNER
       || region == Region.SPLIT_PANE_DIVIDER
       || region == Region.TABLE
       || region == Region.TEXT_AREA
       || region == Region.TEXT_FIELD
       || region == Region.TEXT_PANE
       || region == Region.TOOL_BAR_DRAG_WINDOW
       || region == Region.TOOL_TIP
       || region == Region.TREE
       || region == Region.VIEWPORT) {
     return true;
   }
   Component c = context.getComponent();
   String name = c.getName();
   if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
     return true;
   }
   return false;
 }