-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
atarw
committed
Jun 20, 2018
1 parent
73097a0
commit 0fb07d1
Showing
5 changed files
with
123 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package mdlaf.components.tabbedpane; | ||
|
||
import mdlaf.resources.MaterialColors; | ||
import mdlaf.resources.MaterialDrawingUtils; | ||
import mdlaf.resources.MaterialFonts; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JComponent; | ||
import javax.swing.JTabbedPane; | ||
import javax.swing.plaf.ComponentUI; | ||
import javax.swing.plaf.basic.BasicTabbedPaneUI; | ||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
import java.awt.Rectangle; | ||
|
||
public class MaterialTabbedPaneUI extends BasicTabbedPaneUI { | ||
|
||
public static ComponentUI createUI (JComponent c) { | ||
return new MaterialTabbedPaneUI (); | ||
} | ||
|
||
@Override | ||
public void installUI (JComponent c) { | ||
super.installUI (c); | ||
|
||
JTabbedPane tabbedPane = (JTabbedPane) c; | ||
tabbedPane.setOpaque (false); | ||
tabbedPane.setFont (MaterialFonts.REGULAR); | ||
tabbedPane.setBackground (Color.WHITE); | ||
tabbedPane.setForeground (Color.BLACK); | ||
tabbedPane.setBorder (BorderFactory.createEmptyBorder ()); | ||
|
||
darkShadow = null; | ||
shadow = null; | ||
lightHighlight = MaterialColors.LIGHT_GRAY; | ||
} | ||
|
||
@Override | ||
public void paint (Graphics g, JComponent c) { | ||
super.paint (MaterialDrawingUtils.getAliasedGraphics (g), c); | ||
} | ||
|
||
@Override | ||
protected void paintTabBackground (Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { | ||
g.setColor (isSelected ? lightHighlight : tabPane.getBackground ()); | ||
g.fillRect (x, y, w, h); | ||
} | ||
|
||
@Override | ||
protected void paintTabBorder (Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { | ||
g.setColor (Color.LIGHT_GRAY); | ||
g.drawRect (x, y, w, h); | ||
} | ||
|
||
@Override | ||
protected void paintFocusIndicator (Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) { | ||
// do nothing | ||
} | ||
|
||
@Override | ||
protected void paintTab (Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) { | ||
// for some reason tabs aren't painted properly by paint() | ||
super.paintTab (MaterialDrawingUtils.getAliasedGraphics (g), tabPlacement, rects, tabIndex, iconRect, textRect); | ||
} | ||
} |