-
-
Save Tadukoo/07276fc7f2b6e01bcd349663388abec6 to your computer and use it in GitHub Desktop.
Tadukoo Look & Feel After Journey Post #3
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
package com.gmail.realtadukoo.util.lookandfeel; | |
import java.awt.*; | |
public interface Shaped{ | |
Polygon getShape(int x, int y, int width, int height); | |
} |
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
package com.gmail.realtadukoo.util.lookandfeel; | |
import javax.swing.border.AbstractBorder; | |
import javax.swing.plaf.UIResource; | |
import java.awt.*; | |
public class TadukooBorder extends AbstractBorder implements UIResource{ | |
public static Insets borderInsets = new Insets(10, 10, 10, 10); | |
@Override | |
public Insets getBorderInsets(Component c){ | |
return borderInsets; | |
} | |
@Override | |
public Insets getBorderInsets(Component c, Insets insets){ | |
return borderInsets; | |
} | |
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h){ | |
if(!(c instanceof Shaped)){ | |
return; | |
} | |
Polygon shape = ((Shaped) c).getShape(x, y, w, h); | |
Graphics2D g2d = (Graphics2D) g; | |
g2d.setStroke(new BasicStroke(2)); | |
g.setColor(Color.RED); | |
g.drawPolygon(shape); | |
} | |
} |
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
package com.gmail.realtadukoo.util.lookandfeel; | |
import javax.swing.*; | |
import javax.swing.plaf.basic.BasicLookAndFeel; | |
import javax.swing.plaf.metal.MetalLookAndFeel; | |
import javax.swing.plaf.metal.OceanTheme; | |
public class TadukooLookAndFeel extends MetalLookAndFeel{ | |
@Override | |
public String getName(){ | |
return "Tadukoo"; | |
} | |
@Override | |
public String getID(){ | |
return "Tadukoo"; | |
} | |
@Override | |
public String getDescription(){ | |
return "The Tadukoo Look and Feel"; | |
} | |
@Override | |
public boolean isNativeLookAndFeel(){ | |
return false; | |
} | |
@Override | |
public boolean isSupportedLookAndFeel(){ | |
return true; | |
} | |
@Override | |
protected void initClassDefaults(UIDefaults table){ | |
super.initClassDefaults(table); | |
table.put("ButtonUI", "com.gmail.realtadukoo.util.lookandfeel.TadukooButtonUI"); | |
} | |
@Override | |
protected void initComponentDefaults(UIDefaults table){ | |
super.initComponentDefaults(table); | |
table.put("Button.border", new TadukooBorder()); | |
} | |
} |
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
package com.gmail.realtadukoo.util.lookandfeel; | |
import java.awt.*; | |
public interface TadukooShape extends Shaped{ | |
@Override | |
default Polygon getShape(int x, int y, int width, int height){ | |
Polygon polygon = new Polygon(); | |
polygon.addPoint(x + 1, y + 1); | |
polygon.addPoint(x + width - 10, y + 1); | |
polygon.addPoint(x + width - 1, y + 10); | |
polygon.addPoint(x + width - 1, y + height - 1); | |
polygon.addPoint(x + 10, y + height - 1); | |
polygon.addPoint(x + 1, y + height - 10); | |
return polygon; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment