关于背景图片的问题。求求!
解答问题的大哥大姐们,我先谢谢了,但同时希望某些也能认真对待问题么?我不想问题没解决就被迫结贴。
程序代码:import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Font;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@SuppressWarnings("serial")
public class price extends JFrame implements ActionListener,DocumentListener
{
Panel p1,p2,p3;
Box b1,b2,b3,b4;
Label nom,name,p,count,money;
JTextField f1,f2,f3,f4,f5;
Button bt1,bt2,bt3,bt4,bt5;
String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String connectionStr = "jdbc:odbc:shang";
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
PreparedStatement pstmt = null;
int search = 0;
private JPanel kl;
private ImageIcon i;
public price()
{
super();
i = new ImageIcon("welcome.jpg"); //背景图片
JLabel la = new JLabel(i);
la.setBounds(0,0,i.getIconWidth(),i.getIconHeight()); //把图片填满整个
kl = (JPanel)this.getContentPane();
kl.setOpaque(false); //使窗口透明化
this.getLayeredPane().setLayout(null); //把背景图片添加到分层窗口的最低层作为背景
this.getLayeredPane().add(la,new Integer(Integer.MIN_VALUE));
this.setSize(i.getIconWidth(),i.getIconHeight());
kl.setLayout(new BorderLayout());
Label lo = new Label("仓库信息查询");
kl.add(lo,BorderLayout.NORTH);
b1 = Box.createVerticalBox();
b2 = Box.createVerticalBox();
nom = new Label("编号");
name = new Label("名称");
p = new Label("单价");
count = new Label("数量");
money = new Label("总价");
f1 = new JTextField(15);
f2 = new JTextField(15);
f3 = new JTextField(15);
f4 = new JTextField(15);
f5 = new JTextField(15);
f1.setFont(new Font("宋体", Font.PLAIN, 14));
f2.setFont(new Font("宋体", Font.PLAIN, 14));
f3.setFont(new Font("宋体", Font.PLAIN, 14));
f4.setFont(new Font("宋体", Font.PLAIN, 14));
f5.setFont(new Font("宋体", Font.PLAIN, 14));
f3.getDocument().addDocumentListener(this);
f4.getDocument().addDocumentListener(this);
b1.add(nom);
b1.add(Box.createVerticalStrut(20));
b1.add(name);
b1.add(Box.createVerticalStrut(20));
b1.add(p);
b1.add(Box.createVerticalStrut(20));
b1.add(count);
b1.add(Box.createVerticalStrut(20));
b1.add(money);
b2.add(f1);
b2.add(Box.createVerticalStrut(20));
b2.add(f2);
b2.add(Box.createVerticalStrut(20));
b2.add(f3);
b2.add(Box.createVerticalStrut(20));
b2.add(f4);
b2.add(Box.createVerticalStrut(20));
b2.add(f5);
b3 = Box.createHorizontalBox();
b3.add(b1);
b3.add(Box.createHorizontalStrut(10));
b3.add(b2);
p1 = new Panel();
p3 = new Panel();
p1.add(b3);
// p1.setBackground(Color.LIGHT_GRAY);
// p3.setBackground(Color.LIGHT_GRAY);
bt1 = new Button("添加");
bt2 = new Button("删除");
bt3 = new Button("查询");
bt4 = new Button("重置");
// bt1.addActionListener(this);
// bt2.addActionListener(this);
// bt3.addActionListener(this);
// bt4.addActionListener(this);
p3.add(bt1);
p3.add(bt2);
p3.add(bt3);
p3.add(bt4);
kl.add(p1,BorderLayout.CENTER);
kl.add(p3,BorderLayout.SOUTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.setLocationRelativeTo(null);
}
//以下是无关紧要的access数据表的内容,我就没有复制上来
public static void main(String shang[])
{
new price();
}
public void changedUpdate(DocumentEvent e)
{
doChange();
}
public void insertUpdate(DocumentEvent e)
{
doChange();
}
public void removeUpdate(DocumentEvent e)
{
doChange();
}
public void doChange()
{
try
{
int n1 = Integer.parseInt(f3.getText());
int n2 = Integer.parseInt(f4.getText());
f5.setText(String.valueOf(n1*n2));
} catch (Exception ee)
{}
}
}









