具有下嵌效果的JTextField就是对其border进行重新设定,代码如下:
package test2;
import javax.swing.*;
import java.awt.*;
public class Testing2 {
JFrame jf = new JFrame();
JTextField jtf = new JTextField(20);
JLabel jl = new JLabel("具有下嵌效果的JTextField:");
public Testing2(){
jf.add(jl,BorderLayout.NORTH);
jf.add(jtf,BorderLayout.SOUTH);
jtf.setBorder(BorderFactory.createLoweredBevelBorder());
jf.pack();
jf.setVisible(true);
}
public static void main(String[] arg0){
Testing2 test = new Testing2();
}
}
效果: