mytextfield.java

来自「MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程」· Java 代码 · 共 47 行

JAVA
47
字号
import java.awt.Color;import javax.swing.JTextField;import javax.swing.JLabel;//This class extends TextField to put background and foreground//colors to the TextField and make it editable according to the options.public class MyTextField extends JTextField {  public MyTextField (boolean b) {super (); setup (b);}  public MyTextField (String text, boolean b) {super (text); setup (b);}  public MyTextField (int columns, boolean b) {super (columns); setup (b);}  public MyTextField (String text, int columns, boolean b) {    super (text, columns);    setup (b);  }  void setup (boolean b) {    this.setBackground (Color.white);    this.setForeground (Color.black);    this.setEditable (b);  }}class MyJLabel extends JLabel {  public MyJLabel (String s) {super (s);}    public MyJLabel (String s, int columns) {    super ();    StringBuffer t = new StringBuffer (s);    int len = t.length ();        if (len < columns)      for (int i = 0; i < (columns - len); i++) t.append (' ');    else if (len > columns)       t.setLength (columns);        setText (t.toString ());  }    public MyJLabel (int columns) {    super ();    StringBuffer t = new StringBuffer ();        for (int i = 0; i < columns; i++) t.append (' ');    setText (t.toString ());  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?