-
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.
added support for jtoolbar, jcombobox
- Loading branch information
atarw
committed
Jul 27, 2018
1 parent
755612b
commit 5943931
Showing
11 changed files
with
415 additions
and
220 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.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
24 changes: 24 additions & 0 deletions
24
src/mdlaf/components/combobox/MaterialComboBoxRenderer.java
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,24 @@ | ||
package mdlaf.components.combobox; | ||
|
||
import mdlaf.resources.MaterialColors; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JComponent; | ||
import javax.swing.JList; | ||
import javax.swing.plaf.basic.BasicComboBoxRenderer; | ||
import java.awt.Color; | ||
import java.awt.Component; | ||
|
||
public class MaterialComboBoxRenderer extends BasicComboBoxRenderer { | ||
|
||
@Override | ||
public Component getListCellRendererComponent (JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { | ||
JComponent component = (JComponent) super.getListCellRendererComponent (list, value, index, isSelected, cellHasFocus); | ||
|
||
component.setForeground (Color.BLACK); | ||
component.setBackground (isSelected || cellHasFocus ? MaterialColors.GRAY_200 : Color.WHITE); | ||
component.setBorder (BorderFactory.createEmptyBorder (5, 5, 5, 5)); | ||
|
||
return component; | ||
} | ||
} |
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,53 @@ | ||
package mdlaf.components.combobox; | ||
|
||
import mdlaf.resources.MaterialBorders; | ||
import mdlaf.resources.MaterialColors; | ||
import mdlaf.resources.MaterialDrawingUtils; | ||
import mdlaf.resources.MaterialFonts; | ||
import mdlaf.resources.MaterialImages; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.ImageIcon; | ||
import javax.swing.JButton; | ||
import javax.swing.JComboBox; | ||
import javax.swing.JComponent; | ||
import javax.swing.plaf.ComponentUI; | ||
import javax.swing.plaf.basic.BasicComboBoxUI; | ||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
|
||
public class MaterialComboBoxUI extends BasicComboBoxUI { | ||
|
||
public static ComponentUI createUI (JComponent c) { | ||
return new MaterialComboBoxUI (); | ||
} | ||
|
||
@Override | ||
public void installUI (JComponent c) { | ||
super.installUI (c); | ||
|
||
JComboBox<?> comboBox = (JComboBox<?>) c; | ||
comboBox.setFont (MaterialFonts.REGULAR); | ||
comboBox.setBackground (Color.WHITE); | ||
comboBox.setForeground (Color.BLACK); | ||
comboBox.setBorder (BorderFactory.createCompoundBorder (MaterialBorders.LIGHT_LINE_BORDER, BorderFactory.createEmptyBorder (0, 5, 0, 0))); | ||
comboBox.setLightWeightPopupEnabled (true); | ||
comboBox.setRenderer (new MaterialComboBoxRenderer ()); | ||
} | ||
|
||
@Override | ||
protected JButton createArrowButton () { | ||
JButton button = new JButton (new ImageIcon (MaterialImages.DOWN_ARROW)); | ||
|
||
button.setOpaque (true); | ||
button.setBackground (MaterialColors.GRAY_300); | ||
button.setBorder (BorderFactory.createEmptyBorder ()); | ||
|
||
return button; | ||
} | ||
|
||
@Override | ||
public void paint (Graphics g, JComponent c) { | ||
super.paint (MaterialDrawingUtils.getAliasedGraphics (g), c); | ||
} | ||
} |
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,33 @@ | ||
package mdlaf.components.popupmenu; | ||
|
||
import mdlaf.resources.MaterialBorders; | ||
import mdlaf.resources.MaterialDrawingUtils; | ||
|
||
import javax.swing.JComponent; | ||
import javax.swing.JPopupMenu; | ||
import javax.swing.plaf.ComponentUI; | ||
import javax.swing.plaf.basic.BasicPopupMenuUI; | ||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
|
||
public class MaterialPopupMenuUI extends BasicPopupMenuUI { | ||
|
||
public static ComponentUI createUI (JComponent c) { | ||
return new MaterialPopupMenuUI (); | ||
} | ||
|
||
@Override | ||
public void installUI (JComponent c) { | ||
super.installUI (c); | ||
|
||
JPopupMenu popupMenu = (JPopupMenu) c; | ||
popupMenu.setBorder (MaterialBorders.LIGHT_LINE_BORDER); | ||
popupMenu.setBackground (Color.WHITE); | ||
popupMenu.setForeground (Color.BLACK); | ||
} | ||
|
||
@Override | ||
public void paint (Graphics g, JComponent c) { | ||
super.paint (MaterialDrawingUtils.getAliasedGraphics (g), c); | ||
} | ||
} |
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,60 @@ | ||
package mdlaf.components.slider; | ||
|
||
import mdlaf.resources.MaterialBorders; | ||
import mdlaf.resources.MaterialDrawingUtils; | ||
import mdlaf.resources.MaterialFonts; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JComponent; | ||
import javax.swing.JSlider; | ||
import javax.swing.plaf.ComponentUI; | ||
import javax.swing.plaf.basic.BasicSliderUI; | ||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
|
||
public class MaterialSliderUI extends BasicSliderUI { | ||
|
||
public MaterialSliderUI (JSlider slider) { | ||
super (slider); | ||
} | ||
|
||
public static ComponentUI createUI (JComponent c) { | ||
return new MaterialSliderUI ((JSlider) c); | ||
} | ||
|
||
@Override | ||
public void installUI (JComponent c) { | ||
super.installUI (c); | ||
|
||
JSlider slider = (JSlider) c; | ||
slider.setFont (MaterialFonts.REGULAR); | ||
slider.setBackground (Color.WHITE); | ||
slider.setForeground (Color.BLACK); | ||
slider.setBorder (BorderFactory.createCompoundBorder (MaterialBorders.LIGHT_LINE_BORDER, BorderFactory.createEmptyBorder (5, 5, 5, 5))); | ||
} | ||
|
||
/*@Override | ||
public void paintThumb (Graphics g) { | ||
g = MaterialDrawingUtils.getAliasedGraphics (g); | ||
g.setColor (Color.RED); | ||
g.fillOval (this.thumbRect.x, this.thumbRect.y, this.getThumbSize ().height, this.getThumbSize ().height); | ||
} | ||
@Override | ||
public void paintTrack (Graphics g) { | ||
g = MaterialDrawingUtils.getAliasedGraphics (g); | ||
g.setColor (this.slider.getForeground ()); | ||
g.drawLine (this.trackRect.x, this.trackRect.y + this.trackRect.height / 2, this.trackRect.x + this.trackRect.width, this.trackRect.y + this.trackRect.height / 2); | ||
}*/ | ||
|
||
@Override | ||
public void paintFocus (Graphics g) { | ||
|
||
} | ||
|
||
@Override | ||
public void paint (Graphics g, JComponent c) { | ||
super.paint (MaterialDrawingUtils.getAliasedGraphics (g), c); | ||
} | ||
} |
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,41 @@ | ||
package mdlaf.components.toolbar; | ||
|
||
import mdlaf.resources.MaterialBorders; | ||
import mdlaf.resources.MaterialColors; | ||
import mdlaf.resources.MaterialDrawingUtils; | ||
import mdlaf.resources.MaterialFonts; | ||
|
||
import javax.swing.JComponent; | ||
import javax.swing.JToolBar; | ||
import javax.swing.plaf.ComponentUI; | ||
import javax.swing.plaf.basic.BasicToolBarUI; | ||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
|
||
public class MaterialToolBarUI extends BasicToolBarUI { | ||
|
||
public static ComponentUI createUI (JComponent c) { | ||
return new MaterialToolBarUI (); | ||
} | ||
|
||
@Override | ||
public void installUI (JComponent c) { | ||
super.installUI (c); | ||
JToolBar toolBar = (JToolBar) c; | ||
|
||
toolBar.setFont (MaterialFonts.REGULAR); | ||
toolBar.setBackground (Color.WHITE); | ||
toolBar.setForeground (Color.BLACK); | ||
toolBar.setBorder (MaterialBorders.LIGHT_SHADOW_BORDER); | ||
|
||
this.dockingBorderColor = null; | ||
this.floatingBorderColor = null; | ||
this.dockingColor = MaterialColors.LIGHT_GREEN_A100; | ||
this.floatingColor = MaterialColors.GRAY_200; | ||
} | ||
|
||
@Override | ||
public void paint (Graphics g, JComponent c) { | ||
super.paint (MaterialDrawingUtils.getAliasedGraphics (g), c); | ||
} | ||
} |