Browse Source

一些基础的UI组件

pull/1/head
richie 5 years ago
parent
commit
120976e96e
  1. 84
      src/main/java/com/fanruan/api/design/ui/component/UIActionLabel.java
  2. 32
      src/main/java/com/fanruan/api/design/ui/component/UIButton.java
  3. 41
      src/main/java/com/fanruan/api/design/ui/component/UILabel.java
  4. 22
      src/main/java/com/fanruan/api/design/ui/component/UITextArea.java
  5. 32
      src/main/java/com/fanruan/api/design/ui/component/UITextField.java
  6. 7
      src/main/java/com/fanruan/api/layout/LayoutKit.java

84
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));
}
}
};
}

32
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);
}
}

41
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);
}
}

22
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);
}
}

32
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);
}
}

7
src/main/java/com/fanruan/api/layout/LayoutKit.java

@ -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;
}
Loading…
Cancel
Save