如何在背景图上加按钮(java)
importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassMainFrameexten...
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MainFrame extends JFrame{
private JLabel jl_picture;
private Panel p_right;
private Panel p_Left;
private Button btn_personmanage;
private Button btn_toolmanage;
private Button btn_lend;
private Button btn_back;
private Button btn_select;
private Button btn_change;
private ImageIcon ii;
String showname;
public MainFrame(){
super();
this.setTitle("主信息表");
p_right=new Panel();
p_right.setLayout(new GridLayout(14,1));
jl_picture=new JLabel();
ii=new ImageIcon("D:\\Pro\\Images\\4.jpg");
jl_picture=new JLabel("");
jl_picture.setSize(800,600);
jl_picture.setIcon((Icon)ii);
this.getContentPane().add(jl_picture);
btn_personmanage=new Button("固定资产信息管理");
btn_toolmanage=new Button("人员信息管理");
btn_lend=new Button("资产的领用");
btn_back=new Button("资产的归还");
btn_select=new Button("资产信息浏览和查询");
btn_change=new Button("修改密码");
p_right.add(new Label());
p_right.add(new Label());
p_right.add(btn_change);
p_right.add(new Label());
p_right.add(btn_personmanage);
p_right.add(new Label());
p_right.add(btn_toolmanage);
p_right.add(new Label());
p_right.add(btn_lend);
p_right.add(new Label());
p_right.add(btn_back);
p_right.add(new Label());
p_right.add(btn_select);
p_right.add(new Label());
add(jl_picture,"Center");
add(p_right,"East");
setSize(800,600);
setVisible(true);
}
public static void main(String[] args){
MainFrame mf=new MainFrame();
}
}
以上代码,运行后按钮在背景图右边,我想按钮在背景图上面,怎么修改??谢谢回答 展开
import javax.swing.*;
import java.awt.event.*;
public class MainFrame extends JFrame{
private JLabel jl_picture;
private Panel p_right;
private Panel p_Left;
private Button btn_personmanage;
private Button btn_toolmanage;
private Button btn_lend;
private Button btn_back;
private Button btn_select;
private Button btn_change;
private ImageIcon ii;
String showname;
public MainFrame(){
super();
this.setTitle("主信息表");
p_right=new Panel();
p_right.setLayout(new GridLayout(14,1));
jl_picture=new JLabel();
ii=new ImageIcon("D:\\Pro\\Images\\4.jpg");
jl_picture=new JLabel("");
jl_picture.setSize(800,600);
jl_picture.setIcon((Icon)ii);
this.getContentPane().add(jl_picture);
btn_personmanage=new Button("固定资产信息管理");
btn_toolmanage=new Button("人员信息管理");
btn_lend=new Button("资产的领用");
btn_back=new Button("资产的归还");
btn_select=new Button("资产信息浏览和查询");
btn_change=new Button("修改密码");
p_right.add(new Label());
p_right.add(new Label());
p_right.add(btn_change);
p_right.add(new Label());
p_right.add(btn_personmanage);
p_right.add(new Label());
p_right.add(btn_toolmanage);
p_right.add(new Label());
p_right.add(btn_lend);
p_right.add(new Label());
p_right.add(btn_back);
p_right.add(new Label());
p_right.add(btn_select);
p_right.add(new Label());
add(jl_picture,"Center");
add(p_right,"East");
setSize(800,600);
setVisible(true);
}
public static void main(String[] args){
MainFrame mf=new MainFrame();
}
}
以上代码,运行后按钮在背景图右边,我想按钮在背景图上面,怎么修改??谢谢回答 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询