日期:2014-05-20 浏览次数:21013 次
JTextField jt = new JTextField("你好!");
jl_center.add(jt);
jt.setOpaque(false);
jt.setBorder(
new Border(){
@Override
public boolean isBorderOpaque() {
// TODO Auto-generated method stub
return false;
}
@Override
public Insets getBorderInsets(Component c) {
// TODO Auto-generated method stub
return null;
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y,
int width, int height) {
// TODO Auto-generated method stub
}
}
);
@Override
public Insets getBorderInsets(Component c) {
// TODO Auto-generated method stub
return null;
}
package TestLogin_claP;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
public class TestJLabel_s_BorderLayout extends JFrame {
TestJLabel_s_BorderLayout() {
JLabel jl_top = new JLabel("1 ");
jl_top.setOpaque(true);
jl_top.setBackground(Color.black);
JLabel jl_left = new JLabel(" 2");
jl_left.setOpaque(true);
jl_left.setBackground(Color.blue);
JLabel jl_buttom = new JLabel("3 ");
jl_buttom.setOpaque(true);
jl_buttom.setBackground(Color.cyan);
JLabel jl_right = new JLabel("4 ");
jl_right.setOpaque(true);
jl_right.setBackground(Color.gray);
JLabel jl_center = new JLabel();