-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish demo and releasing version 0.0.1
- Loading branch information
1 parent
53abbf1
commit 63893c0
Showing
7 changed files
with
169 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
JTextFieldPlaceholder | ||
# JTextFieldPlaceholder | ||
|
||
Custom component developer for JMars 5 application | ||
|
||
## TODO | ||
This component has bad design, in the future should introduce the following effect | ||
|
||
- [ ] Used a personal UI component as BasicTextFieldPlaceholderUI | ||
- [ ] Introduce a ruled to check the error inside the text field and paint the line with an error color | ||
- [ ] Introduce a toggle button with an icon, inside the icon | ||
|
||
## Actual effect | ||
|
||
<div align="center"> | ||
<img src="https://i.ibb.co/vYpnd3B/Selection-055.png" /> | ||
</div> | ||
|
||
## Dependency | ||
|
||
This component has a dependence from [Material-ui-swing](https://github.com/vincenzopalazzo/material-ui-swing) | ||
|
||
## Author | ||
|
||
This component is developer by [@vincenzopalazzo](https://github.com/vincenzopalazzo) | ||
|
||
<p align="center" style="center">In addition, this component is developed in collaborations with Arizona State University. </p> | ||
|
||
<div align="center"> | ||
<img src="https://sundevilgymnastics.com/wp-content/uploads/2016/10/ASU-Womens-Gymnastics-Website.png" /> | ||
</div> |
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.
51 changes: 51 additions & 0 deletions
51
src/main/java/io/vincenzopalazzo/placeholder/CustomTextField.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,51 @@ | ||
package io.vincenzopalazzo.placeholder; | ||
|
||
import javax.swing.*; | ||
import javax.swing.plaf.basic.BasicTextFieldUI; | ||
import java.awt.event.FocusEvent; | ||
import java.awt.event.FocusListener; | ||
|
||
class CustomTextField extends JTextField { | ||
|
||
private JTextFieldPlaceholder textFieldPlaceholder; | ||
|
||
public CustomTextField(JTextFieldPlaceholder placeholder) { | ||
setUI(new CustomTextFieldUI()); | ||
this.textFieldPlaceholder = placeholder; | ||
} | ||
|
||
@Override | ||
public void updateUI() { | ||
setUI(new CustomTextFieldUI()); | ||
} | ||
|
||
public class CustomTextFieldUI extends BasicTextFieldUI{ | ||
|
||
protected FocusListener focusListener = new LineFocusListener(); | ||
|
||
@Override | ||
protected void installListeners() { | ||
super.installListeners(); | ||
this.getComponent().addFocusListener(focusListener); | ||
} | ||
|
||
@Override | ||
protected void uninstallListeners() { | ||
super.uninstallListeners(); | ||
this.getComponent().removeFocusListener(focusListener); | ||
} | ||
|
||
public class LineFocusListener implements FocusListener{ | ||
|
||
@Override | ||
public void focusGained(FocusEvent e) { | ||
textFieldPlaceholder.doFocus(); | ||
} | ||
|
||
@Override | ||
public void focusLost(FocusEvent e) { | ||
textFieldPlaceholder.focusLose(); | ||
} | ||
} | ||
} | ||
} |
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