-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add hints and tooltip for url and open jar fields
- Loading branch information
1 parent
40acf32
commit a7bfa54
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
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,29 @@ | ||
package gui.custom; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class HintTextField extends JTextField { | ||
|
||
public HintTextField(String hint) { | ||
_hint = hint; | ||
} | ||
|
||
@Override | ||
public void paint(Graphics g) { | ||
super.paint(g); | ||
if (getText().length() == 0) { | ||
int h = getHeight(); | ||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | ||
Insets ins = getInsets(); | ||
FontMetrics fm = g.getFontMetrics(); | ||
int c0 = getBackground().getRGB(); | ||
int c1 = getForeground().getRGB(); | ||
int m = 0xfefefefe; | ||
int c2 = ((c0 & m) >>> 1) + ((c1 & m) >>> 1); | ||
g.setColor(new Color(c2, true)); | ||
g.drawString(_hint, ins.left, h / 2 + fm.getAscent() / 2 - 2); | ||
} | ||
} | ||
private final String _hint; | ||
} |
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