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); }
public static void init(UIDefaults d) { d.put("ScrollBarUI", AgScrollBarUI.class.getName()); d.put("ScrollBar.minimumThumbSize", new DimensionUIResource(10, 10)); d.put("ScrollBar.maximumThumbSize", new DimensionUIResource(4096, 4096)); d.put("ScrollBar.border", BORDER); d.put("ScrollBar.track", ThemeColor.shadow(ThemeKey.TEXT_BG, 0.05)); d.put("ScrollBar.background", Theme.TEXT_BG); d.put("ScrollBar.foreground", Theme.TEXT_FG); //thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight"); //thumbLightShadowColor = UIManager.getColor("ScrollBar.thumbShadow"); //thumbDarkShadowColor = UIManager.getColor("ScrollBar.thumbDarkShadow"); //thumbColor = UIManager.getColor("ScrollBar.thumb"); //trackColor = UIManager.getColor("ScrollBar.track"); //trackHighlightColor = UIManager.getColor("ScrollBar.trackHighlight"); }
@Override public void register(Registry 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); }
public static final Object[] getUIDefaults() { return new Object[] { // // Notifications settings NOTIFICATIONS_MaxDisplayed, NOTIFICATIONS_MaxDisplayed_Default , NOTIFICATIONS_AutoFadeAwayTimeMillis, NOTIFICATIONS_AutoFadeAwayTimeMillis_Default , NOTIFICATIONS_BottomGap, NOTIFICATIONS_BottomGap_Default // // Item settings , ITEM_BackgroundColor, AdempierePLAF.createActiveValueProxy(AdempiereLookAndFeel.MANDATORY_BG_KEY, Color.WHITE) // same as mandatory background color , ITEM_Border, new BorderUIResource(BorderFactory.createLineBorder(Color.GRAY, 1)) , ITEM_SummaryText_Font, new FontUIResource("Serif", Font.BOLD, 12) , ITEM_DetailText_Font, new FontUIResource("Serif", Font.PLAIN, 12) , ITEM_TextColor, null , ITEM_MinimumSize, new DimensionUIResource(230, 45) , ITEM_MaximumSize, null // // Button settings (i.e. the close button) , ITEM_Button_Insets, new InsetsUIResource(1, 4, 1, 4) , ITEM_Button_Size, 20 , ITEM_Button_Border, new BorderUIResource(BorderFactory.createEmptyBorder()) }; }
private void initComponent(Image imageNumber) { setName(NbBundle.getMessage(Costanti.class, Costanti.VIEW_BEST_MAPPINGS_TOP_COMPONENT)); setToolTipText(NbBundle.getMessage(Costanti.class, Costanti.VIEW_BEST_MAPPINGS_TOP_COMPONENT_TOOLTIP)); Image imageDefault = ImageUtilities.loadImage(Costanti.ICONA_VIEW_BEST_MAPPINGS, true); this.setIcon(ImageUtilities.mergeImages(imageDefault, imageNumber, Scenario.X_OFFSET_IMAGE_NUMBER, Scenario.Y_OFFSET_IMAGE_NUMBER)); messageLabel = new JTextArea(); messageLabel.setRows(2); messageLabel.setEditable(false); messageLabel.setBackground(this.getBackground()); tabellaBestMappings = new JTable(); jScrollPane = new JScrollPane(); jScrollPane.setPreferredSize(new DimensionUIResource(150, this.getHeight())); this.setPreferredSize(new Dimension(150, this.getHeight())); this.setLayout(new BorderLayout()); this.add(messageLabel, BorderLayout.NORTH); this.add(jScrollPane, BorderLayout.CENTER); addSelectionListener(); }
public void testInstallDefaults() { JOptionPane pane = new JOptionPane(); UIManager.put("OptionPane.background", new ColorUIResource(Color.red)); UIManager.put("OptionPane.foreground", new ColorUIResource(Color.yellow)); UIManager.put("OptionPane.messageForeground", new ColorUIResource(Color.green)); Font font = new FontUIResource(pane.getFont().deriveFont(100f)); UIManager.put("OptionPane.font", font); Border border = new BorderUIResource(BorderFactory.createEmptyBorder(1, 1, 1, 1)); UIManager.put("OptionPane.border", border); Dimension minimumSize = new DimensionUIResource(123, 456); UIManager.put("OptionPane.minimumSize", minimumSize); pane.setUI(paneUI); pane.setOptions(new Object[] { "button" }); paneUI.installDefaults(); assertEquals(Color.red, pane.getBackground()); assertEquals(Color.yellow, pane.getForeground()); assertEquals(font, pane.getFont()); assertEquals(border, pane.getBorder()); assertEquals(minimumSize, paneUI.getMinimumOptionPaneSize()); }
@Override protected void installOther(UIDefaults table) { table.put(SCROLLBAR_WIDTH, 9); table.put(SCROLLBAR_BACKGROUND, getColorRes(Color.WHITE)); table.put(MINIMUMTHUMBSIZE, new DimensionUIResource(48, 48)); }
/** * Ui impl. */ public static void uiImpl() { UIManager.put("ProgressBar.background",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor)); UIManager.put("ProgressBar.selectionForeground",new ColorUIResource(BeautyEyeLNFHelper.commonBackgroundColor)); //* 此属性决定水平进度条的默认最小大小:15是相关于.9.png图片的最小填充 //* 高度或长度的(小于此高度则NinePatch算法无法解决而很难看) UIManager.put("ProgressBar.horizontalSize",new DimensionUIResource(146,15));//默认是146,12 //* 此属性决定垂直进度条的默认最小大小:15是相关于.9.png图片的最小填充 //* 高度或长度的(小于此高度则NinePatch算法无法解决而很难看) UIManager.put("ProgressBar.verticalSize",new DimensionUIResource(15,146));//默认是12,146 UIManager.put("ProgressBar.border",new BorderUIResource(BorderFactory.createEmptyBorder(0,0,0,0))); UIManager.put("ProgressBarUI",org.jb2011.lnf.beautyeye.ch12_progress.BEProgressBarUI.class.getName()); }
private void myInitComponents() { this.setLayout(new BorderLayout()); this.scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new DimensionUIResource(100, this.getHeight())); this.setPreferredSize(new Dimension(100, this.getHeight())); this.jTree = new JTree(null, false); new TreeDragSource(jTree, DnDConstants.ACTION_COPY_OR_MOVE); this.jTree.setDragEnabled(true); // new TreeDropTarget(tree); this.scrollPane.setViewportView(jTree); this.add(this.scrollPane, BorderLayout.CENTER); }
private void initComponent() { messageLabel = new JTextArea(); messageLabel.setRows(2); messageLabel.setEditable(false); messageLabel.setBackground(this.getBackground()); tabellaRankedTransformations = new JTable(); jScrollPane = new JScrollPane(); jScrollPane.setPreferredSize(new DimensionUIResource(150, this.getHeight())); this.setPreferredSize(new Dimension(150, this.getHeight())); this.setLayout(new BorderLayout()); this.add(messageLabel, BorderLayout.NORTH); this.add(jScrollPane, BorderLayout.CENTER); addSelectionListener(); }
public void testGetPreferredSize() { JOptionPane pane = new JOptionPane() { private static final long serialVersionUID = 1L; @Override public FontMetrics getFontMetrics(Font font) { return BasicOptionPaneUITest.this.getFontMetrics(font); } }; Border messageAreaBorder = new BorderUIResource(BorderFactory.createEmptyBorder(3, 3, 3, 3)); UIManager.put("OptionPane.messageAreaBorder", messageAreaBorder); messageAreaBorder = new BorderUIResource(BorderFactory.createEmptyBorder(4, 4, 4, 4)); UIManager.put("OptionPane.messageAreaBorder", messageAreaBorder); Border border = new BorderUIResource(BorderFactory.createEmptyBorder(1, 1, 1, 1)); UIManager.put("OptionPane.border", border); Dimension minimumSize = new DimensionUIResource(123, 456); UIManager.put("OptionPane.minimumSize", minimumSize); pane.setUI(paneUI); assertNull(paneUI.getPreferredSize(null)); Dimension preferredSize = paneUI.getPreferredSize(pane); assertNotNull(preferredSize); assertTrue(preferredSize.width > 0); assertTrue(preferredSize.height > 0); LayoutManager layout = new MyLayoutManager(new Dimension(200, 500)); pane.setLayout(layout); assertEquals(new Dimension(200, 500), paneUI.getPreferredSize(pane)); layout = new MyLayoutManager(new Dimension(200, 300)); pane.setLayout(layout); assertEquals(new Dimension(200, 456), paneUI.getPreferredSize(pane)); layout = new MyLayoutManager(new Dimension(100, 500)); pane.setLayout(layout); assertEquals(new Dimension(123, 500), paneUI.getPreferredSize(pane)); layout = new MyLayoutManager(new Dimension(10, 10)); pane.setLayout(layout); assertEquals(new Dimension(123, 456), paneUI.getPreferredSize(pane)); }
@Override protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.getForeground(); JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g) { Color borderColor = ModernUIUtil.getBorderColor(myComboBox); GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); g.setColor(UIUtil.getControlColor()); g.fillRect(0, 0, w, h); g.setColor(myComboBox.isEnabled() ? getForeground() : borderColor); GraphicsUtil.setupAAPainting(g); g.drawLine(JBUI.scale(3), JBUI.scale(7), JBUI.scale(7), JBUI.scale(11)); g.drawLine(JBUI.scale(7), JBUI.scale(11), JBUI.scale(11), JBUI.scale(7)); config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + JBUI.scale(4); if (size % 2 == 1) size += JBUI.scale(1); return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
protected DimensionUIResource getDimensionRes(int w, int h) { return new DimensionUIResource(w, h); }
protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.getForeground(); JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g2) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(UIUtil.getControlColor())); g.fillRect(0, 0, w, h); } g.setColor(comboBox.isEnabled() ? new JBColor(Gray._255, getForeground()) : new JBColor(Gray._255, getBorderColor())); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final int tW = JBUI.scale(8); final int tH = JBUI.scale(6); final int xU = (w - tW) / 2; final int yU = (h - tH) / 2; g.translate(JBUI.scale(2), JBUI.scale(1)); final Path2D.Double path = new Path2D.Double(); path.moveTo(xU, yU); path.lineTo(xU + tW, yU); path.lineTo(xU + tW/2, yU + tH); path.lineTo(xU, yU); //path.moveTo(xU + 1, yU + 2); //path.lineTo(3 * xU + 1, yU + 2); //path.lineTo(2 * xU + 1, 3 * yU); //path.lineTo(xU + 1, yU + 2); path.closePath(); g.fill(path); g.translate(-JBUI.scale(2), -JBUI.scale(1)); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(getBorderColor())); g.drawLine(0, -1, 0, h); } config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size%2==1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
/** * Set the icons to paint the title pane decorations. * * @param d the UI defaults map. */ private void defineInternalFrames(UIDefaults d) { // Copied from nimbus //Initialize InternalFrameTitlePane d.put("InternalFrameTitlePane.contentMargins", new InsetsUIResource(0, 0, 0, 0)); d.put("InternalFrameTitlePane.maxFrameIconSize", new DimensionUIResource(18, 18)); //Initialize InternalFrame d.put("InternalFrame.contentMargins", new InsetsUIResource(1, 6, 6, 6)); d.put("InternalFrame:InternalFrameTitlePane.contentMargins", new InsetsUIResource(3, 0, 3, 0)); d.put("InternalFrame:InternalFrameTitlePane.titleAlignment", "CENTER"); d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.menuButton\".contentMargins", new InsetsUIResource(0, 0, 0, 0)); d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.iconifyButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9)); d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.maximizeButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9)); d.put("InternalFrame:InternalFrameTitlePane:\"InternalFrameTitlePane.closeButton\".contentMargins", new InsetsUIResource(9, 9, 9, 9)); // Seaglass starts below if (PlatformUtils.isMac()) { d.put("frameBaseActive", new Color(0xa8a8a8)); } else { d.put("frameBaseActive", new Color(0x96adc4)); } d.put("frameBaseInactive", new Color(0xe0e0e0)); d.put("frameBorderBase", new Color(0x545454)); d.put("frameInnerHighlightInactive", new Color(0x55ffffff, true)); d.put("frameInnerHighlightActive", new Color(0x55ffffff, true)); d.put("seaGlassTitlePaneButtonEnabledBorder", new Color(0x99000000, true)); d.put("seaGlassTitlePaneButtonEnabledCorner", new Color(0x26000000, true)); d.put("seaGlassTitlePaneButtonEnabledInterior", new Color(0x99ffffff, true)); d.put("seaGlassTitlePaneButtonHoverBorder", new Color(0xe5101010, true)); d.put("seaGlassTitlePaneButtonHoverCorner", new Color(0x267a7a7a, true)); d.put("seaGlassTitlePaneButtonHoverInterior", new Color(0xffffff)); d.put("seaGlassTitlePaneButtonPressedBorder", new Color(0xe50e0e0e, true)); d.put("seaGlassTitlePaneButtonPressedCorner", new Color(0x876e6e6e, true)); d.put("seaGlassTitlePaneButtonPressedInterior", new Color(0xe6e6e6)); String p = "InternalFrame"; String c = PAINTER_PREFIX + "FrameAndRootPainter"; d.put(p + ".titleFont", new DerivedFont("defaultFont", 1.0f, true, null)); d.put(p + ".States", "Enabled,WindowFocused"); d.put(p + ":InternalFrameTitlePane.WindowFocused", new TitlePaneWindowFocusedState()); d.put(p + ".WindowFocused", new InternalFrameWindowFocusedState()); 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)); p = "InternalFrameTitlePane"; d.put(p + ".buttonSpacing", 0); p = "InternalFrame:InternalFrameTitlePane"; d.put(p + "[Enabled].textForeground", d.get("seaGlassDisabledText")); d.put(p + "[WindowFocused].textForeground", Color.BLACK); }
/** * Initialize the progress bar settings. * * @param d the UI defaults map. */ private void defineProgressBars(UIDefaults d) { // Copied from nimbus //Initialize ProgressBar d.put("ProgressBar.contentMargins", new InsetsUIResource(0, 0, 0, 0)); d.put("ProgressBar.States", "Enabled,Disabled,Indeterminate,Finished"); d.put("ProgressBar.tileWhenIndeterminate", Boolean.TRUE); d.put("ProgressBar.paintOutsideClip", Boolean.TRUE); d.put("ProgressBar.rotateText", Boolean.TRUE); d.put("ProgressBar.vertictalSize", new DimensionUIResource(19, 150)); d.put("ProgressBar.horizontalSize", new DimensionUIResource(150, 19)); addColor(d, "ProgressBar[Disabled].textForeground", "seaGlassDisabledText", 0.0f, 0.0f, 0.0f, 0); d.put("ProgressBar[Disabled+Indeterminate].progressPadding", new Integer(3)); // Seaglass starts below. d.put("progressBarTrackInterior", Color.WHITE); d.put("progressBarTrackBase", new Color(0x4076bf)); d.put("ProgressBar.Indeterminate", new ProgressBarIndeterminateState()); d.put("ProgressBar.Finished", new ProgressBarFinishedState()); String p = "ProgressBar"; String c = PAINTER_PREFIX + "ProgressBarPainter"; d.put(p + ".cycleTime", 500); d.put(p + ".progressPadding", new Integer(3)); d.put(p + ".trackThickness", new Integer(19)); d.put(p + ".tileWidth", new Integer(24)); d.put(p + ".backgroundFillColor", Color.WHITE); d.put(p + ".font", new DerivedFont("defaultFont", 0.769f, null, null)); d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ProgressBarPainter.Which.BACKGROUND_ENABLED)); d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ProgressBarPainter.Which.BACKGROUND_DISABLED)); d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_ENABLED)); d.put(p + "[Enabled+Finished].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_ENABLED_FINISHED)); d.put(p + "[Enabled+Indeterminate].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_ENABLED_INDETERMINATE)); d.put(p + "[Disabled].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_DISABLED)); d.put(p + "[Disabled+Finished].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_DISABLED_FINISHED)); d.put(p + "[Disabled+Indeterminate].foregroundPainter", new LazyPainter(c, ProgressBarPainter.Which.FOREGROUND_DISABLED_INDETERMINATE)); }
/** * Initialize the scroll bar UI settings. * * @param d the UI defaults map. */ private void defineScrollBars(UIDefaults d) { d.put("scrollBarThumbBorderBasePressed", new Color(0x4879bf)); d.put("scrollBarThumbInteriorBasePressed", new Color(0x82a8ca)); d.put("scrollBarButtonBase", Color.WHITE); d.put("scrollBarButtonBasePressed", new Color(0xa1bfdb)); d.put("scrollBarTrackBackgroundBase", Color.WHITE); d.put("scrollBarTrackGradientBase", d.get("seaGlassTransparent")); d.put("ScrollBar.incrementButtonGap", new Integer(-7)); d.put("ScrollBar.decrementButtonGap", new Integer(-7)); d.put("ScrollBar.capSize", new Integer(11)); d.put("ScrollBar.contentMargins", new InsetsUIResource(0, 0, 0, 0)); d.put("ScrollBar.thumbHeight", new Integer(15)); d.put("ScrollBar.minimumThumbSize", new DimensionUIResource(29, 29)); d.put("ScrollBar.maximumThumbSize", new DimensionUIResource(1000, 1000)); // Buttons String c = PAINTER_PREFIX + "ScrollBarButtonPainter"; String p = "ScrollBar:\"ScrollBar.button\""; d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0)); d.put(p + ".size", new Integer(22)); d.put(p + ".States", "Enabled,Pressed,MouseOver,IncreaseButton,Disabled,ButtonsTogether"); d.put(p + ".IncreaseButton", new ScrollBarButtonIsIncreaseButtonState()); d.put(p + ".ButtonsTogether", new ScrollBarButtonsTogetherState()); d.put(p + ".foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED)); d.put(p + "[Enabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED)); d.put(p + "[Disabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_DISABLED)); d.put(p + "[MouseOver].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED)); d.put(p + "[Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_PRESSED)); d.put(p + "[MouseOver+Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_PRESSED)); d.put(p + "[IncreaseButton+Enabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_ENABLED)); d.put(p + "[MouseOver+IncreaseButton].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_ENABLED)); d.put(p + "[IncreaseButton+Disabled].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_DISABLED)); d.put(p + "[IncreaseButton+Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_PRESSED)); d.put(p + "[MouseOver+IncreaseButton+Pressed].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_PRESSED)); d.put(p + "[Enabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_ENABLED_TOGETHER)); d.put(p + "[Disabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_DISABLED_TOGETHER)); d.put(p + "[Pressed+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_PRESSED_TOGETHER)); d.put(p + "[IncreaseButton+Enabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_ENABLED_TOGETHER)); d.put(p + "[IncreaseButton+Disabled+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_DISABLED_TOGETHER)); d.put(p + "[IncreaseButton+Pressed+ButtonsTogether].foregroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_INCREASE_PRESSED_TOGETHER)); // Thumb // Seems to be a bug somewhere where MouseOver is always delivered even // when we don't want it, but if it's not specified nothing at all is // painted. c = PAINTER_PREFIX + "ScrollBarThumbPainter"; p = "ScrollBar:ScrollBarThumb"; d.put(p + ".States", "Enabled,Pressed,MouseOver,Disabled"); d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_DISABLED)); d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_ENABLED)); d.put(p + "[MouseOver].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_ENABLED)); d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_PRESSED)); d.put(p + "[MouseOver+Pressed].backgroundPainter", new LazyPainter(c, ScrollBarThumbPainter.Which.BACKGROUND_PRESSED)); // Track c = PAINTER_PREFIX + "ScrollBarTrackPainter"; p = "ScrollBar:ScrollBarTrack"; d.put(p + ".States", "Enabled,Disabled"); d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ScrollBarTrackPainter.Which.BACKGROUND_DISABLED)); d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ScrollBarTrackPainter.Which.BACKGROUND_ENABLED)); // Cap c = PAINTER_PREFIX + "ScrollBarButtonPainter"; p = "ScrollBar:ScrollBarCap"; d.put(p + ".States", "Enabled,Disabled"); d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_CAP)); d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, ScrollBarButtonPainter.Which.FOREGROUND_CAP)); }
/** * Initialize the table UI settings. * * @param d the UI defaults map. */ private void defineTables(UIDefaults d) { d.put("tableHeaderBorderEnabled", new Color(0xcad3e0)); d.put("tableHeaderSortIndicator", new Color(0xc02a5481, true)); // Rossi: table headers now blue and glassy. // I know you discussed this already but I like all interactive components to have the glassy look. d.put("tableHeaderInteriorBaseEnabled", new Color(0x80a6d2)); String p = "TableHeader"; String c = PAINTER_PREFIX + "TableHeaderPainter"; // d.put(p + ".font", new DerivedFont("defaultFont", 0.846f, null, null)); d.put(p + "[Enabled].ascendingSortIconPainter", new LazyPainter(c, TableHeaderPainter.Which.ASCENDINGSORTICON_ENABLED)); d.put(p + "[Enabled].descendingSortIconPainter", new LazyPainter(c, TableHeaderPainter.Which.DESCENDINGSORTICON_ENABLED)); p = "Table"; d.put(p + ".background", new ColorUIResource(Color.WHITE)); d.put(p + ".alternateRowColor", new ColorUIResource(0xebf5fc)); d.put(p + ".showGrid", Boolean.FALSE); d.put(p + ".contentMargins", new InsetsUIResource(0, 0, 0, 0)); d.put(p + ".opaque", Boolean.TRUE); d.put(p + ".intercellSpacing", new DimensionUIResource(0, 0)); d.put(p + ".rendererUseTableColors", Boolean.TRUE); d.put(p + ".rendererUseUIBorder", Boolean.TRUE); d.put(p + ".cellNoFocusBorder", new BorderUIResource(BorderFactory.createEmptyBorder(2, 5, 2, 5))); // TODO Why doesn't ColorUIResource work on these next two? d.put(p + "[Enabled+Selected].textForeground", Color.WHITE); d.put(p + "[Enabled+Selected].textBackground", new Color(0x6181a5)); d.put(p + "[Disabled+Selected].textBackground", new Color(0x6181a5)); d.put(p + ".ascendingSortIcon", new SeaGlassIcon("TableHeader", "ascendingSortIconPainter", 8, 7)); d.put(p + ".descendingSortIcon", new SeaGlassIcon("TableHeader", "descendingSortIconPainter", 8, 7)); d.put(p + ".scrollPaneCornerComponent", TableScrollPaneCorner.class); c = PAINTER_PREFIX + "TableHeaderRendererPainter"; p = "TableHeader:\"TableHeader.renderer\""; d.put(p + ".contentMargins", new InsetsUIResource(2, 4, 2, 4)); d.put(p + ".States", "Enabled,Pressed,Disabled,Focused,Sorted"); d.put(p + ".Sorted", new TableHeaderRendererSortedState()); d.put(p + "[Disabled].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_DISABLED)); d.put(p + "[Enabled].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED)); d.put(p + "[Enabled+Focused].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED_FOCUSED)); d.put(p + "[Pressed].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_PRESSED)); d.put(p + "[Enabled+Sorted].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED_SORTED)); d.put(p + "[Enabled+Focused+Sorted].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_ENABLED_FOCUSED_SORTED)); d.put(p + "[Disabled+Sorted].backgroundPainter", new LazyPainter(c, TableHeaderRendererPainter.Which.BACKGROUND_DISABLED_SORTED)); }
protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.getForeground(); JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g2) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); g.setColor(UIUtil.getControlColor()); g.fillRect(0, 0, w, h); g.setColor(myComboBox.isEnabled() ? getForeground() : getForeground().darker()); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final int xU = w / 4; final int yU = h / 4; final Path2D.Double path = new Path2D.Double(); g.translate(2, 0); path.moveTo(xU + 1, yU + 2); path.lineTo(3 * xU + 1, yU + 2); path.lineTo(2 * xU + 1, 3 * yU); path.lineTo(xU + 1, yU + 2); path.closePath(); g.fill(path); g.translate(-2, 0); g.setColor(getBorderColor()); g.drawLine(0, -1, 0, h); config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size%2==1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.getForeground(); JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g2) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(UIUtil.getControlColor())); g.fillRect(0, 0, w, h); } g.setColor(comboBox.isEnabled() ? new DoubleColor(Gray._255, getForeground()) : new DoubleColor(Gray._255, getForeground().darker())); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final int xU = w / 4; final int yU = h / 4; final Path2D.Double path = new Path2D.Double(); g.translate(2, 0); path.moveTo(xU + 1, yU + 2); path.lineTo(3 * xU + 1, yU + 2); path.lineTo(2 * xU + 1, 3 * yU); path.lineTo(xU + 1, yU + 2); path.closePath(); g.fill(path); g.translate(-2, 0); if (!isTableCellEditor(myComboBox)) { g.setColor(getArrowButtonFillColor(getBorderColor())); g.drawLine(0, -1, 0, h); } config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size%2==1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }
@Override protected JButton createArrowButton() { final Color bg = myComboBox.getBackground(); final Color fg = myComboBox.getForeground(); JButton button = new DPIAwareArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) { @Override public void paint(Graphics g2) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final int w = getWidth(); final int h = getHeight(); g.setColor(UIUtil.getControlColor()); g.fillRect(0, 0, w, h); g.setColor(myComboBox.isEnabled() ? getForeground() : getForeground().darker()); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final int xU = w / 4; final int yU = h / 4; final Path2D.Double path = new Path2D.Double(); g.translate(JBUI.scale(2), 0); path.moveTo(xU + JBUI.scale(1), yU + JBUI.scale(2)); path.lineTo(3 * xU + JBUI.scale(1), yU + JBUI.scale(2)); path.lineTo(2 * xU + JBUI.scale(1), 3 * yU); path.lineTo(xU + JBUI.scale(1), yU + JBUI.scale(2)); path.closePath(); g.fill(path); g.translate(-JBUI.scale(2), 0); g.setColor(getBorderColor()); g.drawLine(0, -JBUI.scale(1), 0, h); config.restore(); } @Override public Dimension getPreferredSize() { int size = getFont().getSize() + 4; if (size % 2 == 1) size++; return new DimensionUIResource(size, size); } }; button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); return button; }