-
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 jtables, fixed a color selection bug for jtextfields
- Loading branch information
atarw
committed
May 24, 2018
1 parent
e26ea0a
commit ef16f56
Showing
14 changed files
with
472 additions
and
149 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package mdlaf; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.border.Border; | ||
import java.awt.Color; | ||
|
||
public class MaterialBorders { | ||
|
||
public static final Border LIGHT_LINE_BORDER = BorderFactory.createLineBorder (MaterialColors.LIGHT_GRAY, 1); | ||
|
||
public static final Border LIGHT_SHADOW_BORDER = new DropShadowBorder (Color.BLACK, 0, 4, 0.3f, 12, true, true, true, true); | ||
public static final Border DEFAULT_SHADOW_BORDER = new DropShadowBorder (Color.BLACK, 5, 5, 0.3f, 12, true, true, true, true); | ||
|
||
private MaterialBorders () {} | ||
} |
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
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,21 @@ | ||
package mdlaf.table; | ||
|
||
import javax.swing.DefaultCellEditor; | ||
import javax.swing.JTable; | ||
import javax.swing.JTextField; | ||
import java.awt.Component; | ||
|
||
public class MaterialTableCellEditor extends DefaultCellEditor { | ||
|
||
@Override | ||
public Component getTableCellEditorComponent (JTable table, Object value, boolean isSelected, int rowIndex, int vColIndex) { | ||
JTextField textField = (JTextField) super.getTableCellEditorComponent (table, value, isSelected, rowIndex, vColIndex); | ||
textField.setText ((String) value); | ||
|
||
return textField; | ||
} | ||
|
||
public MaterialTableCellEditor () { | ||
super (new JTextField ()); | ||
} | ||
} |
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.table; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JComponent; | ||
import javax.swing.JTable; | ||
import javax.swing.SwingConstants; | ||
import javax.swing.table.DefaultTableCellRenderer; | ||
import java.awt.Component; | ||
|
||
public class MaterialTableCellRenderer extends DefaultTableCellRenderer { | ||
|
||
@Override | ||
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { | ||
JComponent component = (JComponent) super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); | ||
|
||
// hides yellow selection highlight | ||
component.setBorder (BorderFactory.createEmptyBorder ()); | ||
|
||
this.setHorizontalAlignment (SwingConstants.CENTER); | ||
this.setVerticalAlignment (SwingConstants.CENTER); | ||
|
||
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,28 @@ | ||
package mdlaf.table; | ||
|
||
import mdlaf.MaterialBorders; | ||
import mdlaf.MaterialColors; | ||
import mdlaf.MaterialFonts; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JComponent; | ||
import javax.swing.JTable; | ||
import javax.swing.SwingConstants; | ||
import javax.swing.table.DefaultTableCellRenderer; | ||
import java.awt.Component; | ||
|
||
public class MaterialTableHeaderCellRenderer extends DefaultTableCellRenderer { | ||
|
||
@Override | ||
public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { | ||
JComponent component = (JComponent) super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); | ||
component.setBorder (BorderFactory.createCompoundBorder (MaterialBorders.LIGHT_LINE_BORDER, BorderFactory.createEmptyBorder (10, 10, 10, 10))); | ||
component.setFont (MaterialFonts.BOLD); | ||
component.setBackground (MaterialColors.LIGHT_GRAY); | ||
|
||
this.setHorizontalAlignment (SwingConstants.CENTER); | ||
this.setVerticalAlignment (SwingConstants.CENTER); | ||
|
||
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,28 @@ | ||
package mdlaf.table; | ||
|
||
import javax.swing.JComponent; | ||
import javax.swing.plaf.ComponentUI; | ||
import javax.swing.plaf.basic.BasicTableHeaderUI; | ||
import javax.swing.table.JTableHeader; | ||
import java.awt.Graphics; | ||
|
||
public class MaterialTableHeaderUI extends BasicTableHeaderUI { | ||
|
||
public static ComponentUI createUI (final JComponent c) { | ||
return new MaterialTableHeaderUI (); | ||
} | ||
|
||
@Override | ||
public void installUI (JComponent c) { | ||
super.installUI (c); | ||
|
||
JTableHeader header = (JTableHeader) c; | ||
|
||
header.setDefaultRenderer (new MaterialTableHeaderCellRenderer ()); | ||
} | ||
|
||
@Override | ||
public void paint (Graphics g, JComponent c) { | ||
super.paint (g, c); | ||
} | ||
} |
Oops, something went wrong.