javax.swing.plaf.InsetsUIResource Java Examples

The following examples show how to use javax.swing.plaf.InsetsUIResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the scroll pane UI
 * @param d
 */
private void defineScrollPane(UIDefaults d) {
    // Define ScrollPane border painters.
    String c = PAINTER_PREFIX + "ScrollPanePainter";
    String p = "ScrollPane";
    d.put(p + ".opaque", Boolean.FALSE);
    d.put(p + ".contentMargins", new InsetsUIResource(3, 3, 3, 3));
    // d.put(p + ".useChildTextComponentFocus", Boolean.TRUE);
    d.put(p + ".backgroundPainter", new LazyPainter(c, ScrollPanePainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[Enabled+Focused].borderPainter", new LazyPainter(c, ScrollPanePainter.Which.BORDER_ENABLED_FOCUSED));
    d.put(p + "[Enabled].borderPainter", new LazyPainter(c, ScrollPanePainter.Which.BORDER_ENABLED));

    // Store ScrollPane Corner Component
    d.put(p + ".cornerPainter", new LazyPainter(c, ScrollPanePainter.Which.CORNER_ENABLED));
    
    //Initialize Viewport
    p = "Viewport";
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".opaque", Boolean.TRUE);
}
 
Example #2
Source File: AdrManagerFrame.java    From MercuryTrade with MIT License 6 votes vote down vote up
public AdrManagerFrame(AdrProfileDescriptor selectedProfile) {
    super();
    this.processingHideEvent = false;
    this.setTitle("MercuryTrade ADR");
    this.setFocusable(true);
    this.setFocusableWindowState(true);
    this.setAlwaysOnTop(false);
    this.selectedProfile = selectedProfile;
    this.exportDialog = new AdrExportDialog(this, new ArrayList<>());
    this.iconSelectDialog = new AdrIconSelectDialog();
    this.iconSelectDialog.setLocationRelativeTo(null);
    FrameDescriptor frameDescriptor = this.framesConfig.get(this.getClass().getSimpleName());
    this.setPreferredSize(frameDescriptor.getFrameSize());
    UIManager.put("MenuItem.background", AppThemeColor.ADR_BG);
    UIManager.put("MenuItem.selectionBackground", AppThemeColor.ADR_POPUP_BG);
    UIManager.put("Menu.contentMargins", new InsetsUIResource(2, 0, 2, 0));
    UIManager.put("MenuItem.opaque", true);
    UIManager.put("ComboBox.selectionBackground", AppThemeColor.HEADER);
    UIManager.put("ComboBox.selectionForeground", AppThemeColor.ADR_POPUP_BG);
    UIManager.put("ComboBox.disabledForeground", AppThemeColor.ADR_FOOTER_BG);
}
 
Example #3
Source File: KnopflerfishLookAndFeel.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void initComponentDefaults(UIDefaults table) {
  super.initComponentDefaults( table );

  // I'll have to copy some of the resource definitions here, since the
  // original code in BasicLookAndFeel (from which we inherit) uses
  // getClass() to find its resources. That will fail since my
  // classloader does not have these resources.
  //
  // So, the trick is to replace getClass() with MetalLookAndFeel.class

  Object[] defaults = {
    "OptionPane.errorIcon",       LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Error.gif"),
    "OptionPane.informationIcon", LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Inform.gif"),
    "OptionPane.warningIcon",     LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Warn.gif"),
    "OptionPane.questionIcon",    LookAndFeel.makeIcon(MetalLookAndFeel.class, "icons/Question.gif"),

    "InternalFrame.icon",         LookAndFeel.makeIcon(BasicLookAndFeel.class, "icons/JavaCup.gif"),


    // Button margin slightly smaller than metal to save space
    "Button.margin", new InsetsUIResource(1, 11, 1, 11),


  };
  table.putDefaults(defaults);
}
 
Example #4
Source File: BeautyEyeLookAndFeelWin.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
	 * 因Windos LNF会在Vista及更新的操作系统(如win7)上对Windows LNF作附加设置,
	 * 以保证与Vista及更新平台的外观的一致性(如让菜单菜项高度更大等),请参见
	 * WindowsLookAndFeel.initVistaComponentDefaults(..)。
	 * <p>
	 * BeautyEye中因需要保证审美一致性(在所有win平台上)而不需要这些额外的设置,
	 * 但因该方法是private私有方法,无法进行覆盖屏蔽,所以只能在此单列方法,以便针对Vista
	 * 及更新的平台进行补救性重新设置以便与BeautyEye LNF的审核进行适配.
	 * 
	 * @see WindowsLookAndFeel.initVistaComponentDefaults(..)
	 */
	protected void initForVista()
	{
		if(WinUtils.isOnVista())
		{
			UIManager.put("CheckBoxMenuItem.margin",new InsetsUIResource(0,0,0,0));
			UIManager.put("RadioButtonMenuItem.margin",new InsetsUIResource(0,0,0,0));
			UIManager.put("Menu.margin",new InsetsUIResource(0,0,0,0));//windows lnf xp中默认是2,2,2,2
			UIManager.put("MenuItem.margin",new InsetsUIResource(0,0,0,0));//windows lnf中  xp默认是2,2,2,2
			
			UIManager.put("Menu.border",new BorderUIResource(BorderFactory.createEmptyBorder(1,3,2,3)));//javax.swing.plaf.basic.BasicBorders.MarginBorder;
			UIManager.put("MenuItem.border",new BorderUIResource(BorderFactory.createEmptyBorder(1,0,2,0)));//javax.swing.plaf.basic.BasicBorders.MarginBorder;
			UIManager.put("CheckBoxMenuItem.border",new BorderUIResource(BorderFactory.createEmptyBorder(4,2,4,2)));//javax.swing.plaf.basic.BasicBorders.MarginBorder;
			UIManager.put("RadioButtonMenuItem.border",new BorderUIResource(BorderFactory.createEmptyBorder(4,0,4,0)));//javax.swing.plaf.basic.BasicBorders.MarginBorder;		
//			UIManager.put("PopupMenu.border",new BorderUIResource(BorderFactory.createEmptyBorder(20,10,20,10)));//	
		
			UIManager.put("CheckBoxMenuItem.checkIcon"
					,new org.jb2011.lnf.beautyeye.ch9_menu.BECheckBoxMenuItemUI.CheckBoxMenuItemIcon().setUsedForVista(true));//javax.swing.plaf.basic.BasicIconFactory.CheckBoxMenuItemIcon);
			UIManager.put("RadioButtonMenuItem.checkIcon"
					,new org.jb2011.lnf.beautyeye.ch9_menu.BERadioButtonMenuItemUI.RadioButtonMenuItemIcon().setUsedForVista(true));
		}
	}
 
Example #5
Source File: AWTConverters.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void register(ConverterRegistry registry) {
  registry.addConverter(Dimension.class, String.class, this);
  registry.addConverter(String.class, Dimension.class, this);
  registry.addConverter(DimensionUIResource.class, String.class, this);

  registry.addConverter(Insets.class, String.class, this);
  registry.addConverter(String.class, Insets.class, this);
  registry.addConverter(InsetsUIResource.class, String.class, this);

  registry.addConverter(Point.class, String.class, this);
  registry.addConverter(String.class, Point.class, this);
  
  registry.addConverter(Rectangle.class, String.class, this);
  registry.addConverter(String.class, Rectangle.class, this);
  
  registry.addConverter(Font.class, String.class, this);
  registry.addConverter(FontUIResource.class, String.class, this);
}
 
Example #6
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private static void createAndShowGui() {
  try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    Insets m = UIManager.getInsets("TextField.margin");
    UIManager.put("TextField.margin", new InsetsUIResource(m.top, m.left + 5, m.bottom, m.right));
  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
    ex.printStackTrace();
    Toolkit.getDefaultToolkit().beep();
  }
  JFrame frame = new JFrame("@title@");
  frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  frame.getContentPane().add(new MainPanel());
  frame.pack();
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
}
 
Example #7
Source File: AWTConverters.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
public void register(ConverterRegistry registry) {
  registry.addConverter(Dimension.class, String.class, this);
  registry.addConverter(String.class, Dimension.class, this);
  registry.addConverter(DimensionUIResource.class, String.class, this);

  registry.addConverter(Insets.class, String.class, this);
  registry.addConverter(String.class, Insets.class, this);
  registry.addConverter(InsetsUIResource.class, String.class, this);

  registry.addConverter(Point.class, String.class, this);
  registry.addConverter(String.class, Point.class, this);
  
  registry.addConverter(Rectangle.class, String.class, this);
  registry.addConverter(String.class, Rectangle.class, this);
  
  registry.addConverter(Font.class, String.class, this);
  registry.addConverter(FontUIResource.class, String.class, this);
}
 
Example #8
Source File: __UI__.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
	 * Ui impl.
	 */
	public static void uiImpl()
	{
//		UIManager.put("CheckBox.border",new BorderUIResource(new BERoundBorder().setArcWidth(0)));
		
		UIManager.put("CheckBox.margin",new InsetsUIResource(4,3,4,3));
		UIManager.put("RadioButton.margin",new InsetsUIResource(4,3,4,3));//2, 2, 2, 2));
		
		UIManager.put("RadioButton.background",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor));
		UIManager.put("CheckBox.background",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor));
		
		UIManager.put("CheckBox.foreground",new ColorUIResource(BeautyEyeLNFHelper.commonForegroundColor));
		UIManager.put("RadioButton.foreground",new ColorUIResource(BeautyEyeLNFHelper.commonForegroundColor));
		
		UIManager.put("RadioButton.icon", new RadioButtonIcon());
		UIManager.put("CheckBox.icon", new CheckBoxIcon());

		//衬距设定
		UIManager.put("RadioButton.margin", new InsetsUIResource(1,1,1,1));//默认是2,2,2,2
		UIManager.put("CheckBox.margin", new InsetsUIResource(1,1,1,1));//默认是2,2,2,2
	}
 
Example #9
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
private void defineOptionPane(UIDefaults d) {
    //Initialize OptionPane
    d.put("OptionPane.contentMargins", new InsetsUIResource(15, 15, 15, 15));
    d.put("OptionPane.opaque", Boolean.TRUE);
    d.put("OptionPane.background", getDerivedColor("control", 0, 0, 0, 0, true));
    d.put("OptionPane.buttonOrientation", new Integer(4));
    d.put("OptionPane.messageAnchor", new Integer(17));
    d.put("OptionPane.separatorPadding", new Integer(0));
    d.put("OptionPane.sameSizeButtons", Boolean.FALSE);
    d.put("OptionPane:\"OptionPane.separator\".contentMargins", new InsetsUIResource(1, 0, 0, 0));
    d.put("OptionPane:\"OptionPane.messageArea\".contentMargins", new InsetsUIResource(0, 0, 10, 0));
    d.put("OptionPane:\"OptionPane.messageArea\":\"OptionPane.label\".contentMargins", new InsetsUIResource(0, 10, 10, 10));

    d.put("OptionPane[Enabled].errorIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.OptionPanePainter", OptionPanePainter.Which.ERRORICON_ENABLED));
    d.put("OptionPane.errorIcon", new SeaGlassIcon("OptionPane", "errorIconPainter", 48, 48));
    d.put("OptionPane[Enabled].informationIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.OptionPanePainter", OptionPanePainter.Which.INFORMATIONICON_ENABLED));
    d.put("OptionPane.informationIcon", new SeaGlassIcon("OptionPane", "informationIconPainter", 48, 48));
    d.put("OptionPane[Enabled].questionIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.OptionPanePainter", OptionPanePainter.Which.QUESTIONICON_ENABLED));
    d.put("OptionPane.questionIcon", new SeaGlassIcon("OptionPane", "questionIconPainter", 48, 48));
    d.put("OptionPane[Enabled].warningIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.OptionPanePainter", OptionPanePainter.Which.WARNINGICON_ENABLED));
    d.put("OptionPane.warningIcon", new SeaGlassIcon("OptionPane", "warningIconPainter", 48, 48));
    
    // Color Chooser Dialog
    d.put("ColorChooser.swatchesDefaultRecentColor", getDerivedColor("control", 0, 0, 0, 0, true));
}
 
Example #10
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
private void defineFileChooser(UIDefaults d) {
    //Initialize FileChooser
    d.put("FileChooser.contentMargins", new InsetsUIResource(10, 10, 10, 10));
    d.put("FileChooser.opaque", Boolean.TRUE);
    d.put("FileChooser.usesSingleFilePane", Boolean.TRUE);
    d.put("FileChooser[Enabled].fileIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.FILEICON_ENABLED));
    d.put("FileChooser.fileIcon", new SeaGlassIcon("FileChooser", "fileIconPainter", 16, 16));
    d.put("FileChooser[Enabled].directoryIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.DIRECTORYICON_ENABLED));
    d.put("FileChooser.directoryIcon", new SeaGlassIcon("FileChooser", "directoryIconPainter", 16, 16));
    d.put("FileChooser[Enabled].upFolderIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.UPFOLDERICON_ENABLED));
    d.put("FileChooser.upFolderIcon", new SeaGlassIcon("FileChooser", "upFolderIconPainter", 16, 16));
    d.put("FileChooser[Enabled].newFolderIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.NEWFOLDERICON_ENABLED));
    d.put("FileChooser.newFolderIcon", new SeaGlassIcon("FileChooser", "newFolderIconPainter", 16, 16));
    d.put("FileChooser[Enabled].hardDriveIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.HARDDRIVEICON_ENABLED));
    d.put("FileChooser.hardDriveIcon", new SeaGlassIcon("FileChooser", "hardDriveIconPainter", 16, 16));
    d.put("FileChooser[Enabled].floppyDriveIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.FLOPPYDRIVEICON_ENABLED));
    d.put("FileChooser.floppyDriveIcon", new SeaGlassIcon("FileChooser", "floppyDriveIconPainter", 16, 16));
    d.put("FileChooser[Enabled].homeFolderIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.HOMEFOLDERICON_ENABLED));
    d.put("FileChooser.homeFolderIcon", new SeaGlassIcon("FileChooser", "homeFolderIconPainter", 16, 16));
    d.put("FileChooser[Enabled].detailsViewIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.DETAILSVIEWICON_ENABLED));
    d.put("FileChooser.detailsViewIcon", new SeaGlassIcon("FileChooser", "detailsViewIconPainter", 16, 16));
    d.put("FileChooser[Enabled].listViewIconPainter", new LazyPainter("com.seaglasslookandfeel.painter.FileChooserPainter", FileChooserPainter.Which.LISTVIEWICON_ENABLED));
    d.put("FileChooser.listViewIcon", new SeaGlassIcon("FileChooser", "listViewIconPainter", 16, 16));
}
 
Example #11
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the internal frame close button settings.
 *
 * @param d the UI defaults map.
 */
private void defineInternalFrameCloseButtons(UIDefaults d) {
    String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\"";
    String c = PAINTER_PREFIX + "TitlePaneCloseButtonPainter";

    // Set the multiplicity of states for the Close button.
    d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,WindowNotFocused");
    d.put(p + ".WindowNotFocused", new TitlePaneCloseButtonWindowNotFocusedState());
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));

    d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_DISABLED));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[MouseOver].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_MOUSEOVER));
    d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_PRESSED));
    d.put(p + "[Enabled+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_ENABLED_WINDOWNOTFOCUSED));
    d.put(p + "[MouseOver+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_MOUSEOVER));
    d.put(p + "[Pressed+WindowNotFocused].backgroundPainter", new LazyPainter(c, TitlePaneCloseButtonPainter.Which.BACKGROUND_PRESSED_WINDOWNOTFOCUSED));

    d.put(p + ".icon", new SeaGlassIcon(p, "iconPainter", 43, 18));
}
 
Example #12
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the internal frame menu button settings.
 *
 * @param d the UI defaults map.
 */
private void defineInternalFrameMenuButtons(UIDefaults d) {
    String p = "InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.menuButton\"";
    String c = PAINTER_PREFIX + "TitlePaneMenuButtonPainter";

    d.put(p + ".WindowNotFocused", new TitlePaneMenuButtonWindowNotFocusedState());
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));

    // Set the states for the Menu button.
    d.put(p + "[Enabled].iconPainter", new LazyPainter(c, TitlePaneMenuButtonPainter.Which.ICON_ENABLED));
    d.put(p + "[Disabled].iconPainter", new LazyPainter(c, TitlePaneMenuButtonPainter.Which.ICON_DISABLED));
    d.put(p + "[MouseOver].iconPainter", new LazyPainter(c, TitlePaneMenuButtonPainter.Which.ICON_MOUSEOVER));
    d.put(p + "[Pressed].iconPainter", new LazyPainter(c, TitlePaneMenuButtonPainter.Which.ICON_PRESSED));
    d.put(p + "[Enabled+WindowNotFocused].iconPainter",
          new LazyPainter(c,
                          TitlePaneMenuButtonPainter.Which.ICON_ENABLED_WINDOWNOTFOCUSED));
    d.put(p + "[MouseOver+WindowNotFocused].iconPainter",
          new LazyPainter(c,
                          TitlePaneMenuButtonPainter.Which.ICON_MOUSEOVER_WINDOWNOTFOCUSED));
    d.put(p + "[Pressed+WindowNotFocused].iconPainter",
          new LazyPainter(c,
                          TitlePaneMenuButtonPainter.Which.ICON_PRESSED_WINDOWNOTFOCUSED));

    d.put(p + ".icon", new SeaGlassIcon(p, "iconPainter", 19, 18));
}
 
Example #13
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 6 votes vote down vote up
/**
     * Initialize the popup settings.
     *
     * @param d the UI defaults map.
     */
    private void definePopups(UIDefaults d) {
        d.put("seaGlassPopupBorder", new ColorUIResource(0xbbbbbb));

        d.put("popupMenuInteriorEnabled", Color.WHITE);
        // Rossi: Changed color of popup / submenus to get better contrast to bright backgrounds.
//        d.put("popupMenuBorderEnabled", new Color(0xdddddd));
        d.put("popupMenuBorderEnabled", new Color(0x5b7ea4));

        String c = PAINTER_PREFIX + "PopupMenuPainter";
        String p = "PopupMenu";

        d.put(p + ".contentMargins", new InsetsUIResource(6, 1, 6, 1));
        d.put(p + ".opaque", Boolean.TRUE);
        d.put(p + ".consumeEventOnClose", Boolean.TRUE);
        d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, PopupMenuPainter.Which.BACKGROUND_DISABLED));
        d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, PopupMenuPainter.Which.BACKGROUND_ENABLED));

        // Initialize PopupMenuSeparator
        c = PAINTER_PREFIX + "SeparatorPainter";
        p = "PopupMenuSeparator";
        d.put(p + ".contentMargins", new InsetsUIResource(1, 0, 2, 0));
        d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, SeparatorPainter.Which.BACKGROUND_ENABLED));
    }
 
Example #14
Source File: UIScale.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
public static Insets scale( Insets insets ) {
	initialize();
	return (insets == null || scaleFactor == 1f)
		? insets
		: (insets instanceof UIResource
			? new InsetsUIResource( scale( insets.top ), scale( insets.left ), scale( insets.bottom ), scale( insets.right ) )
			: new Insets          ( scale( insets.top ), scale( insets.left ), scale( insets.bottom ), scale( insets.right ) ));
}
 
Example #15
Source File: ModernDarkLaf.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected Object parseValue(String key, @Nonnull String value) {
  if (key.endsWith("Insets")) {
    final List<String> numbers = StringUtil.split(value, ",");
    return new InsetsUIResource(Integer.parseInt(numbers.get(0)), Integer.parseInt(numbers.get(1)), Integer.parseInt(numbers.get(2)), Integer.parseInt(numbers.get(3)));
  }
  else if (key.endsWith(".border")) {
    try {
      return Class.forName(value).newInstance();
    }
    catch (Exception e) {
      log(e);
    }
  }
  else {
    final Color color = parseColor(value);
    final Integer invVal = getInteger(value);
    final Boolean boolVal = "true".equals(value) ? Boolean.TRUE : "false".equals(value) ? Boolean.FALSE : null;
    Icon icon = value.startsWith("AllIcons.") ? IconLoader.getIcon(value) : null;
    if (icon == null && value.endsWith(".png")) {
      icon = IconLoader.findIcon(value, getClass(), true);
    }
    if (color != null) {
      return new ColorUIResource(color);
    }
    else if (invVal != null) {
      return invVal;
    }
    else if (icon != null) {
      return new IconUIResource(icon);
    }
    else if (boolVal != null) {
      return boolVal;
    }
  }
  return value;
}
 
Example #16
Source File: BubbleBorder.java    From darklaf with MIT License 5 votes vote down vote up
/**
 * Create new TextBubbleBorder.
 *
 * @param color       Colour of bubble.
 * @param thickness   Line thickness of border.
 * @param radius      corner radius of border.
 * @param pointerSize size of pointer. You can set this size to 0 to achieve no pointer, but it is not desirable.
 *                    The appropriate method for this is to set using {@link BubbleBorder#setPointerSide(Alignment)}
 *                    to. {@link Alignment#CENTER}
 */
public BubbleBorder(final Color color, final int thickness,
                    final int radius, final int pointerSize) {
    this.color = color;
    this.thickness = thickness;
    this.radius = radius;
    this.pointerSize = pointerSize;
    this.pointerWidth = pointerSize;
    insets = new InsetsUIResource(0, 0, 0, 0);
    setThickness(thickness);
}
 
Example #17
Source File: DarkComboBoxBorder.java    From darklaf with MIT License 5 votes vote down vote up
@Override
public Insets getBorderInsets(final Component c) {
    if (ComboBoxConstants.isTreeOrTableCellEditor(c)) {
        return CellUtil.adjustEditorInsets(new InsetsUIResource(cellPadding.top, cellPadding.left,
                                                                cellPadding.bottom, cellPadding.right),
                                           c);
    }
    if (c.getComponentOrientation().isLeftToRight()) {
        return new InsetsUIResource(boxPadding.top, boxPadding.left, boxPadding.bottom, borderSize);
    } else {
        return new InsetsUIResource(boxPadding.top, borderSize, boxPadding.bottom, boxPadding.right);
    }
}
 
Example #18
Source File: LuckProgressBarUIBundle.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
protected void installOther(UIDefaults table)
{
    UIManager.put(HORIZONTALSIZE, getDimensionRes(160, 10));

    UIManager.put(VERTICALSIZE, getDimensionRes(10, 160));

    UIManager.put(CELLBAR_INSETS, new InsetsUIResource(1, 2, 1, 2));
}
 
Example #19
Source File: UIDefaultsLoader.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
private static Insets parseInsets( String value ) {
	List<String> numbers = split( value, ',' );
	try {
		return new InsetsUIResource(
			Integer.parseInt( numbers.get( 0 ) ),
			Integer.parseInt( numbers.get( 1 ) ),
			Integer.parseInt( numbers.get( 2 ) ),
			Integer.parseInt( numbers.get( 3 ) ) );
	} catch( NumberFormatException ex ) {
		throw new IllegalArgumentException( "invalid insets '" + value + "'" );
	}
}
 
Example #20
Source File: LuckRootPaneUIBundle.java    From littleluck with Apache License 2.0 5 votes vote down vote up
@Override
protected void installOther(UIDefaults table)
{
    table.put(TITLEPANEL_HEIGHT, 26);
    table.put(APPLICATION_TITLE_TEXTGAP, 5);
    table.put(APPLICATION_TITLE_INSETS, new InsetsUIResource(4, 6, 0, 0));
}
 
Example #21
Source File: DarculaLaf.java    From Darcula with Apache License 2.0 5 votes vote down vote up
private static Object parseValue(String key, String value) {
  if ("null".equals(value)) {
    return null;
  }
  if (key.endsWith("Insets")) {
    final List<String> numbers = StringUtil.split(value, ",");
    return new InsetsUIResource(Integer.parseInt(numbers.get(0)),
        Integer.parseInt(numbers.get(1)),
        Integer.parseInt(numbers.get(2)),
        Integer.parseInt(numbers.get(3)));
  } else if (key.endsWith(".border")) {
    try {
      return Class.forName(value).newInstance();
    } catch (Exception e) {log(e);}
  } else {
    final Color color = ColorUtil.fromHex(value, null);
    final Integer invVal = getInteger(value);
    final Boolean boolVal = "true".equals(value) ? Boolean.TRUE : "false".equals(value) ? Boolean.FALSE : null;
    Icon icon = key.toLowerCase().endsWith("icon") ? null : null; //TODO: copy image loading
    if (color != null) {
      return  new ColorUIResource(color);
    } else if (invVal != null) {
      return invVal;
    } else if (icon != null) {
      return new IconUIResource(icon);
    } else if (boolVal != null) {
      return boolVal;
    }
  }
  return value;
}
 
Example #22
Source File: NimbusTheme.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {
    super.init();

    UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults();
    lafDefaults.put("Nimbus.keepAlternateRowColor", true); // deny SwingX to remove alternate row color
    lafDefaults.put("ComboBox:\"ComboBox.textField\".contentMargins", new InsetsUIResource(0, 6, 0, 6));
    lafDefaults.put("ComboBox:\"ComboBox.textField\"[Enabled].backgroundPainter", MandatoryComboBoxTextFieldPainter.backgroundEnabledPainter());
    lafDefaults.put("ComboBox:\"ComboBox.textField\"[Disabled].backgroundPainter", MandatoryComboBoxTextFieldPainter.backgroundDisabledPainter());
    lafDefaults.put("ComboBox:\"ComboBox.textField\"[Selected].backgroundPainter", MandatoryComboBoxTextFieldPainter.backgroundSelectedPainter());
}
 
Example #23
Source File: __UI__.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Ui impl.
 */
public static void uiImpl()
{
	UIManager.put("Spinner.background",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor));
	UIManager.put("Spinner.foreground",new ColorUIResource(BeautyEyeLNFHelper.commonForegroundColor));
	UIManager.put("SpinnerUI", org.jb2011.lnf.beautyeye.ch18_spinner.BESpinnerUI.class.getName());
	
	//Spinner组件的边框
	UIManager.put("Spinner.border", new BorderUIResource(new EmptyBorder(5, 5, 10, 5)));//windows lnf中默认是3, 3, 3, 3
	//Spinner组件的2个箭头按钮的内衬距
	UIManager.put("Spinner.arrowButtonInsets", new InsetsUIResource(1,0,2,2));//windows lnf中默认是1,1,1,1
	//Spinner组件的2个箭头按钮的默认大小
	UIManager.put("Spinner.arrowButtonSize",new Dimension(17,9));//windows lnf中默认是17,9
}
 
Example #24
Source File: BEButtonUI.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public Insets getBorderInsets(Component c, Insets insets)       {
    insets = super.getBorderInsets(c, insets);
        
    Insets margin = null;
    if (c instanceof AbstractButton) {
        Insets m = ((AbstractButton)c).getMargin();
        // if this is a toolbar button then ignore getMargin()
        // and subtract the padding added by the constructor
        if(c.getParent() instanceof JToolBar 
           && ! (c instanceof JRadioButton)
           && ! (c instanceof JCheckBox)
           && m instanceof InsetsUIResource) {
            insets.top -= 2;
            insets.left -= 2;
            insets.bottom -= 2;
            insets.right -= 2;
        } else {
            margin = m;
        }
    } else if (c instanceof JToolBar) {
        margin = ((JToolBar)c).getMargin();
    } else if (c instanceof JTextComponent) {
        margin = ((JTextComponent)c).getMargin();
    }
    if (margin != null) {
        insets.top    = margin.top + 2;
        insets.left   = margin.left + 2;
        insets.bottom = margin.bottom + 2;
        insets.right  = margin.right + 2;
    }
    return insets;
}
 
Example #25
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Define some settings for tool tips.
 * @param d
 */
private void defineToolTips(UIDefaults d) {
    String p = "ToolTip";
    d.put("seaGlassToolTipBorder", new Color(0x5b7ea4));
    d.put(p + ".contentMargins", new InsetsUIResource(4, 4, 4, 4));
    d.put(p + ".opaque", Boolean.FALSE);
    d.put(p + ".background", new ColorUIResource(0xd5, 0xe8, 0xf7));
    d.put(p + ".backgroundPainter", new ToolTipPainter(ToolTipPainter.Which.BORDER_ENABLED));
}
 
Example #26
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the split pane UI settings.
 *
 * @param d the UI defaults map.
 */
private void defineSplitPanes(UIDefaults d) {
    d.put("splitPaneDividerBackgroundOuter", new Color(0xd9d9d9));

    String p = "SplitPane";

    d.put(p + ".contentMargins", new InsetsUIResource(1, 1, 1, 1));
    d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical");
    d.put(p + ".Vertical", new SplitPaneVerticalState());
    d.put(p + ".size", new Integer(11));
    d.put(p + ".dividerSize", new Integer(11));
    d.put(p + ".centerOneTouchButtons", Boolean.TRUE);
    d.put(p + ".oneTouchButtonOffset", new Integer(20));
    d.put(p + ".oneTouchButtonVOffset", new Integer(3));
    d.put(p + ".oneTouchExpandable", Boolean.FALSE);
    d.put(p + ".continuousLayout", Boolean.TRUE);

    String c = PAINTER_PREFIX + "SplitPaneDividerPainter";

    p = "SplitPane:SplitPaneDivider";
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".States", "Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Vertical");
    d.put(p + ".Vertical", new SplitPaneDividerVerticalState());
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[Focused].backgroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.BACKGROUND_FOCUSED));
    d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_ENABLED));
    d.put(p + "[Focused].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_FOCUSED));
    d.put(p + "[Enabled+Vertical].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_ENABLED_VERTICAL));
    d.put(p + "[Focused+Vertical].foregroundPainter", new LazyPainter(c, SplitPaneDividerPainter.Which.FOREGROUND_FOCUSED_VERTICAL));
}
 
Example #27
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the desktop pane UI settings.
 *
 * @param d the UI defaults map.
 */
private void defineDesktopPanes(UIDefaults d) {
    d.put("seaGlassDesktopPane", new ColorUIResource(0x556ba6));
    String c = PAINTER_PREFIX + "DesktopPanePainter";

    String p = "DesktopPane";

    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, DesktopPanePainter.Which.BACKGROUND_ENABLED));

    // Initialize DesktopIcon
    p = "DesktopIcon";
    c = PAINTER_PREFIX + "DesktopIconPainter";
    d.put(p + ".contentMargins", new InsetsUIResource(0, 6, 5, 4));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, DesktopIconPainter.Which.BACKGROUND_ENABLED));
}
 
Example #28
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the list settings.
 *
 * @param d the UI defaults map.
 */
private void defineLists(UIDefaults d) {
    String p = "List";

    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".opaque", Boolean.TRUE);

    d.put(p + ".background", d.get("seaGlassLightBackground"));
    d.put(p + ".dropLineColor", d.get("seaGlassFocus"));
    d.put(p + ".rendererUseListColors", Boolean.TRUE);
    d.put(p + ".rendererUseUIBorder", Boolean.TRUE);
    d.put(p + ".cellNoFocusBorder", new BorderUIResource(BorderFactory.createEmptyBorder(2, 5, 2, 5)));
    d.put(p + ".focusCellHighlightBorder",
          new BorderUIResource(new PainterBorder("Tree:TreeCell[Enabled+Focused].backgroundPainter",
                                                 new Insets(2, 5, 2, 5))));

    // TODO Why doesn't ColorUIResource work here?
    d.put(p + "[Selected].textForeground", Color.WHITE);
    d.put(p + "[Selected].textBackground", d.get("seaGlassSelection"));
    d.put(p + "[Disabled+Selected].textBackground", Color.WHITE);
    d.put(p + "[Disabled].textForeground", d.get("seaGlassDisabledText"));

    p = "List:\"List.cellRenderer\"";
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".opaque", Boolean.TRUE);
    d.put(p + "[Disabled].textForeground", d.get("seaGlassDisabledText"));
    d.put(p + "[Disabled].background", d.get("seaGlassSelectionBackground"));
}
 
Example #29
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the panel settings.
 *
 * @param d the UI defaults map.
 */
private void definePanels(UIDefaults d) {
    String p = "Panel";
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".background", new ColorUIResource((Color) d.get("control")));
    d.put(p + ".opaque", Boolean.TRUE);
}
 
Example #30
Source File: SeaGlassLookAndFeel.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the root pane settings.
 *
 * @param d the UI defaults map.
 */
private void defineRootPanes(UIDefaults d) {
    String c = PAINTER_PREFIX + "FrameAndRootPainter";
    String p = "RootPane";

    d.put(p + ".States", "Enabled,WindowFocused,NoFrame");
    d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0));
    d.put(p + ".opaque", Boolean.FALSE);
    d.put(p + ".NoFrame", new RootPaneNoFrameState());
    d.put(p + ".WindowFocused", new RootPaneWindowFocusedState());

    d.put(p + "[Enabled+NoFrame].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED_NOFRAME));
    d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED));
    d.put(p + "[Enabled+WindowFocused].backgroundPainter", new LazyPainter(c, FrameAndRootPainter.Which.BACKGROUND_ENABLED_WINDOWFOCUSED));
}