From 63893c01e0b2c2ad5c900bd866267d2d6df17897 Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 7 May 2020 18:52:14 -0700 Subject: [PATCH] Finish demo and releasing version 0.0.1 --- README.md | 31 +++++++- build.gradle.kts | 1 + devlib/SwingSnackBar-0.0.1.jar | Bin 0 -> 17345 bytes .../placeholder/CustomTextField.java | 51 +++++++++++++ .../placeholder/JTextFieldPlaceholder.java | 67 +++++++++++++----- .../placeholder/RoundedCornerBorder.java | 4 +- .../placeholder/DemoFrame.java | 39 +++++++++- 7 files changed, 169 insertions(+), 24 deletions(-) create mode 100644 devlib/SwingSnackBar-0.0.1.jar create mode 100644 src/main/java/io/vincenzopalazzo/placeholder/CustomTextField.java diff --git a/README.md b/README.md index 2d79b6c..020e2d6 100644 --- a/README.md +++ b/README.md @@ -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 + +
+ +
+ +## 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) + +

In addition, this component is developed in collaborations with Arizona State University.

+ +
+ +
\ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ba4d637..4589f0e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,4 +26,5 @@ dependencies { // Use JUnit test framework implementation(files("$projectDir/devlib/material-ui-swing-1.1.1-rc2.jar")) + implementation(files("$projectDir/devlib/SwingSnackBar-0.0.1.jar")) } diff --git a/devlib/SwingSnackBar-0.0.1.jar b/devlib/SwingSnackBar-0.0.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..58103e4289e64d0628753c4cbe590494316e79c3 GIT binary patch literal 17345 z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W4(@56Z3g$#z7~$vw>al@?Gk5KG0Wxc9wGQ-kr@2wch)J;T?A?S zo<&n#nB*}W8Maq{tHvceRaWM!&`@McKChm@Q~qO~BBj~vYD)@iXxahl>^X;BGM1UD zCS41aGw1P#X-xI;ghcXUNs>yuy2ax6A*5XxBDHeXp(KPR3I!dKweTaTp$nrqe>G+W z$?}F{R$YHZdAecg?ZjY8WIal{-uI5iVDNbP-Y<%Do_I*S=6tIkai)9vpZKBH3P?09 z6DZ_EW^aUbNb*M#>cgzl5W(Kby|vDE)Po7q*^ejE&k~2nr^^ltN=OZSR4I8-ZE1Hl zDt)xTgjt{XT_Z^4yixY80HL;f`yn2;O}yO%2H;e20_jux zBEEmRha<#Zw<3R|FPl?9B>sZrzN}W=+D)l?GyUmu=mL-P`CTM|ZYWPjtXG1+3u-Ao z@}3dgltT*Wdq({QlkS_sH*Gg@2`7 zFS3u{|1u@|8D+! zDEOZMxn9G6Xa47g|1&WBcevkUe*XnW`_Y^KXw9E+f7~~I2m9T9^Iu@qNdE(j@So0{ zzr+19|8r=6$qs*{Un8aV@hJO`w*AB5?stse9q#@_$@Pl)uNeQ;{qA@0-<==+1+M!M zKmGR&{C8J~-|>Fg|JmVR=c<3CUmaE^_#3=GPFa5k`TdmjPncY<$o~%V=e+)Q=K4GK z@A~Dxu%jverh$K={{Pj?-z)kB{O3sgb?QYw+$R5HWdETg{f_aw{`9ZLdi+<6zg44t z2mYO){|mT*`EMHcf1~hEy8b)dzxVYQMf)TDn)Od?e*^bV!uC7L?}Y77oLn!?|AF$q u=-cl#{LV7|Rl_0s-?a1py8UP7ube|h9OOeA1OPzz_;h{nmLslT|NTFO4mmFX literal 0 HcmV?d00001 diff --git a/src/main/java/io/vincenzopalazzo/placeholder/CustomTextField.java b/src/main/java/io/vincenzopalazzo/placeholder/CustomTextField.java new file mode 100644 index 0000000..5b56433 --- /dev/null +++ b/src/main/java/io/vincenzopalazzo/placeholder/CustomTextField.java @@ -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(); + } + } + } +} diff --git a/src/main/java/io/vincenzopalazzo/placeholder/JTextFieldPlaceholder.java b/src/main/java/io/vincenzopalazzo/placeholder/JTextFieldPlaceholder.java index ae792f7..478fd2a 100644 --- a/src/main/java/io/vincenzopalazzo/placeholder/JTextFieldPlaceholder.java +++ b/src/main/java/io/vincenzopalazzo/placeholder/JTextFieldPlaceholder.java @@ -1,17 +1,16 @@ package io.vincenzopalazzo.placeholder; -import mdlaf.shadows.RoundedCornerBorder; +import mdlaf.utils.MaterialColors; import javax.swing.*; -import javax.swing.border.Border; import java.awt.*; public class JTextFieldPlaceholder extends JPanel { protected JLabel iconContainer; protected JLabel placeholder; - private JSeparator separator; - protected JTextField textField; + protected CustomTextField textField; + protected Color colorLine; public JTextFieldPlaceholder() { super(new FlowLayout()); @@ -24,27 +23,21 @@ protected void initView(){ this.add(iconContainer); placeholder = new JLabel(); - separator = new JSeparator(JSeparator.VERTICAL); placeholder.setBorder(BorderFactory.createEmptyBorder(0,0,0,2)); this.add(placeholder); - this.add(separator); - textField = new JTextField(); + textField = new CustomTextField(this); textField.setMinimumSize(new Dimension(50, 20)); - textField.setPreferredSize(new Dimension(50, 20)); - textField.setSize(new Dimension(50, 20)); + textField.setPreferredSize(new Dimension(95, 20)); + textField.setSize(new Dimension(95, 20)); super.add(textField); textField.setBorder(BorderFactory.createEmptyBorder()); - iconContainer.setBorder(BorderFactory.createEmptyBorder()); - placeholder.setBorder(BorderFactory.createEmptyBorder()); setBorder(new RoundedCornerBorder(getBackground(), 6)); } protected void initStyle(){ setBackground(textField.getBackground()); - placeholder.setBackground(getBackground()); - iconContainer.setBackground(getBackground()); } @Override @@ -53,21 +46,57 @@ protected void paintComponent(Graphics g) { this.paintLine(g); } - protected void paintLine(Graphics graphics){ - graphics.setColor(Color.CYAN); - graphics.fillRect(iconContainer.getX(), this.getHeight() - this.getY(), this.getWidth() - iconContainer.getWidth(), 1); - } - public JTextFieldPlaceholder setIcon(Icon icon){ if(icon == null) throw new IllegalArgumentException("icon null"); iconContainer.setIcon(icon); return this; } - public JTextFieldPlaceholder setText(String text){ + public JTextFieldPlaceholder setPlaceholderText(String text){ if(text == null || text.isEmpty()) throw new IllegalArgumentException("Invalid text"); placeholder.setText(text); return this; } + public JTextFieldPlaceholder setText(String text){ + if(text == null || text.isEmpty()) throw new IllegalArgumentException("Invalid text"); + this.textField.setText(text); + return this; + } + + public String getText(){ + return textField.getText(); + } + + public String getPlaceholderText(){ + return placeholder.getText(); + } + + public Icon getIcon(){ + return this.iconContainer.getIcon(); + } + + protected void paintLine(Graphics graphics){ + if(colorLine == null){ + if(textField.isFocusOwner()){ + this.colorLine = UIManager.getColor("TextField[Line].activeColor");; + }else{ + this.colorLine = UIManager.getColor("TextField[Line].inactiveColor"); + } + } + graphics.setColor(this.colorLine); + graphics.fillRect(iconContainer.getX(), this.getHeight() - this.getY(), this.getWidth() - iconContainer.getWidth(), 1); + } + + void doFocus(){ + this.colorLine = UIManager.getColor("TextField[Line].activeColor"); + this.repaint(); + } + + void focusLose(){ + this.colorLine = UIManager.getColor("TextField[Line].inactiveColor"); + this.repaint(); + } + + } diff --git a/src/main/java/io/vincenzopalazzo/placeholder/RoundedCornerBorder.java b/src/main/java/io/vincenzopalazzo/placeholder/RoundedCornerBorder.java index f230626..d25bbaf 100644 --- a/src/main/java/io/vincenzopalazzo/placeholder/RoundedCornerBorder.java +++ b/src/main/java/io/vincenzopalazzo/placeholder/RoundedCornerBorder.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package mdlaf.shadows; +package io.vincenzopalazzo.placeholder; import mdlaf.utils.MaterialColors; @@ -36,7 +36,7 @@ /** * @author https://github.com/vincenzopalazzo */ -public class RoundedCornerBorder extends AbstractBorder { +class RoundedCornerBorder extends AbstractBorder { protected int arch = 12; //default value protected Color colorLine; diff --git a/src/test/java/io/vincenzopalazzo/placeholder/DemoFrame.java b/src/test/java/io/vincenzopalazzo/placeholder/DemoFrame.java index 4ba955e..3d86e4a 100644 --- a/src/test/java/io/vincenzopalazzo/placeholder/DemoFrame.java +++ b/src/test/java/io/vincenzopalazzo/placeholder/DemoFrame.java @@ -1,13 +1,18 @@ package io.vincenzopalazzo.placeholder; +import io.swingsnackbar.SnackBar; +import io.swingsnackbar.action.AbstractSnackBarAction; import jiconfont.icons.google_material_design_icons.GoogleMaterialDesignIcons; import mdlaf.MaterialLookAndFeel; import mdlaf.themes.JMarsDarkTheme; import mdlaf.utils.MaterialColors; +import mdlaf.utils.MaterialFontFactory; import mdlaf.utils.MaterialImageFactory; import javax.swing.*; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; public class DemoFrame extends JFrame { @@ -19,6 +24,7 @@ public class DemoFrame extends JFrame { } } + private JFrame frame = this; private JPanel container; private JTextFieldPlaceholder textFieldPlaceholder; @@ -35,14 +41,43 @@ public void initView() { public void initComponent() { container = new JPanel(); + //Init component textFieldPlaceholder = new JTextFieldPlaceholder(); + + //configure component textFieldPlaceholder.setIcon(MaterialImageFactory.getInstance().getImage( GoogleMaterialDesignIcons.BOOKMARK, MaterialColors.COSMO_DARK_GRAY )) - .setText("Lan/Lon") - .setVisible(true); + .setPlaceholderText("Lan/Lon") + .setVisible(true); + container.add(textFieldPlaceholder); + JButton button = new JButton(MaterialImageFactory.getInstance().getImage( + GoogleMaterialDesignIcons.SEND, + MaterialColors.WHITE + )); + + button.addActionListener(new AbstractAction() { + private SnackBar snackBar; + @Override + public void actionPerformed(ActionEvent e) { + snackBar = SnackBar.make(frame, "Lan/Lon: " + textFieldPlaceholder.getText(), "CLOSE") + .setGap(80) + .setIconTextStyle(MaterialFontFactory.getInstance().getFont(MaterialFontFactory.BOLD)) + .setIconTextColor(MaterialColors.COSMO_RED) + .setDuration(SnackBar.LENGTH_LONG) + .setAction(new AbstractSnackBarAction() { + @Override + public void mousePressed(MouseEvent e) { + snackBar.dismiss(); + } + }) + .run(); + } + }); + + container.add(button); } public static void main(String[] args) {