From 120976e96e1afc5a02e5eaa2865dde7db8f23aab Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 28 Aug 2019 15:18:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=9F=BA=E7=A1=80=E7=9A=84UI?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/ui/component/UIActionLabel.java | 84 +++++++++++++++++++ .../api/design/ui/component/UIButton.java | 32 +++++++ .../api/design/ui/component/UILabel.java | 41 +++++++++ .../api/design/ui/component/UITextArea.java | 22 +++++ .../api/design/ui/component/UITextField.java | 32 +++++++ .../com/fanruan/api/layout/LayoutKit.java | 7 -- 6 files changed, 211 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIActionLabel.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIButton.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UILabel.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UITextArea.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UITextField.java delete mode 100644 src/main/java/com/fanruan/api/layout/LayoutKit.java diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIActionLabel.java b/src/main/java/com/fanruan/api/design/ui/component/UIActionLabel.java new file mode 100644 index 0000000..c1e8352 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIActionLabel.java @@ -0,0 +1,84 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.event.MouseInputAdapter; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 可以点击的标签(带超链接效果) + */ +public class UIActionLabel extends UILabel { + + private ActionListener actionListener; + + public UIActionLabel(String text) { + super(text); + + this.setForeground(Color.blue); + this.addMouseListener(mouseInputAdapter); + this.addMouseMotionListener(mouseInputAdapter); + } + + public void addActionListener(ActionListener actionListener) { + this.actionListener = actionListener; + } + + public void paintComponent(Graphics _gfx) { + super.paintComponent(_gfx); + + _gfx.setColor(Color.blue); + _gfx.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1); + } + + private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { + public void mouseClicked(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseReleased(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + //Action. + if (actionListener != null) { + ActionEvent actionEvent = new ActionEvent(source, 99, ""); + actionListener.actionPerformed(actionEvent); + } + } + } + + public void mouseEntered(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + } + + public void mouseExited(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + ((UILabel) source).setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + } + + public void mouseDragged(MouseEvent e) { + } + + public void mouseMoved(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + } + }; +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIButton.java b/src/main/java/com/fanruan/api/design/ui/component/UIButton.java new file mode 100644 index 0000000..00d035d --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIButton.java @@ -0,0 +1,32 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 按钮组件 + */ +public class UIButton extends com.fr.design.gui.ibutton.UIButton { + + public UIButton() { + super(); + } + + public UIButton(String text) { + super(text); + } + + public UIButton(Icon icon) { + super(icon); + } + + public UIButton(Action action) { + super(action); + } + + public UIButton(String text, Icon icon) { + super(text, icon); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UILabel.java b/src/main/java/com/fanruan/api/design/ui/component/UILabel.java new file mode 100644 index 0000000..7d80045 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UILabel.java @@ -0,0 +1,41 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 标签组件 + */ +public class UILabel extends com.fr.design.gui.ilable.UILabel { + + public UILabel() { + + } + + public UILabel(String text) { + super(text); + } + + public UILabel(Icon icon) { + super(icon); + } + + public UILabel(String text, boolean enable) { + super(text, enable); + } + + public UILabel(String text, int align) { + super(text, align); + } + + public UILabel(Icon icon, int align) { + super(icon, align); + } + + public UILabel(String text, Icon icon, int align) { + super(text, icon, align); + } + +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UITextArea.java b/src/main/java/com/fanruan/api/design/ui/component/UITextArea.java new file mode 100644 index 0000000..d21143c --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UITextArea.java @@ -0,0 +1,22 @@ +package com.fanruan.api.design.ui.component; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 文本域组件 + */ +public class UITextArea extends com.fr.design.gui.itextarea.UITextArea { + + public UITextArea() { + super(); + } + + public UITextArea(String text) { + super(text); + } + + public UITextArea(int rows, int columns) { + super(rows, columns); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UITextField.java b/src/main/java/com/fanruan/api/design/ui/component/UITextField.java new file mode 100644 index 0000000..3f1e72c --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UITextField.java @@ -0,0 +1,32 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.text.Document; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-28 + * 文本框组件 + */ +public class UITextField extends com.fr.design.gui.itextfield.UITextField { + + public UITextField() { + + } + + public UITextField(int columns) { + super(columns); + } + + public UITextField(String text) { + super(text); + } + + public UITextField(String text, int columns) { + super(text, columns); + } + + public UITextField(Document document, String text, int columns) { + super(document, text, columns); + } +} diff --git a/src/main/java/com/fanruan/api/layout/LayoutKit.java b/src/main/java/com/fanruan/api/layout/LayoutKit.java deleted file mode 100644 index b1e4ba5..0000000 --- a/src/main/java/com/fanruan/api/layout/LayoutKit.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.layout; -import com.fr.design.layout.TableLayout; - -public class LayoutKit { - public static final double PREFERRED = TableLayout.PREFERRED; - public static final double FILL = TableLayout.FILL; -}