//package com.cn;import javax.swing.*;
import java.awt.*;public class MyMun { /**
 * @param args
 */
JLabel backlabel = null;
JFrame chuangkou = null; public MyMun() {
chuangkou = new JFrame("企业管理系统");
// JPanel jpanel1=new JPanel();
// jpanel1.setBackground(Color.red);
backlabel = new JLabel();
backlabel.setVerticalAlignment(SwingConstants.TOP);
backlabel.setHorizontalAlignment(SwingConstants.CENTER);
uptupian();
JDesktopPane desktoppane = new JDesktopPane();
desktoppane.add(backlabel, new Integer(Integer.MIN_VALUE));
JPanel jpanel2 = new JPanel();
jpanel2.setBackground(Color.black);
//JPanel jpanel3 = new JPanel();
//jpanel3.setBackground(Color.blue); Container conn = chuangkou.getContentPane();
conn.add(desktoppane);
// conn.add(jpanel1,BorderLayout.SOUTH);
conn.add(jpanel2, BorderLayout.NORTH);
//conn.add(jpanel3, BorderLayout.CENTER);
JMenuBar caidanlan = new JMenuBar();
// caidanlan.setBorderPainted(falsh);
JMenu caidan = new JMenu("基础信息管理");
JMenu caidan1 = new JMenu("进货管理");
JMenu caidan2 = new JMenu("销售管理");
JMenu caidan3 = new JMenu("查询统计");
JMenu caidan4 = new JMenu("库存管理");
JMenu caidan5 = new JMenu("系统管理");
caidanlan.add(caidan);
caidanlan.add(caidan1);
caidanlan.add(caidan2);
caidanlan.add(caidan3);
caidanlan.add(caidan4);
caidanlan.add(caidan5);
chuangkou.setJMenuBar(caidanlan);
chuangkou.setSize(800, 600);
chuangkou.setVisible(true);
} public void uptupian() {
if (backlabel != null) {
int backw = MyMun.this.chuangkou.getWidth();
int backh = chuangkou.getHeight();
backlabel.setSize(backw, backh);
backlabel.setText("<html><body><image width='" + backw
+ "'height='" + (backh) + "'src="
+ MyMun.this.getClass().getResource("a.jpg")
+ "'></img></body></html>");
} }
static {
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e)
{e.printStackTrace();}
}
public static void main(String[] args) {
// TODO Auto-generated method stub new MyMun();
}}

解决方案 »

  1.   


    package com.cn; import javax.swing.*;
    import java.awt.*;public class MyMun { /**
     * @param args
     */
    JLabel backlabel = null; JFrame chuangkou = null; public MyMun() {
    chuangkou = new JFrame("企业管理系统");
    // JPanel jpanel1=new JPanel();
    // jpanel1.setBackground(Color.red); uptupian();
    //JDesktopPane desktoppane = new JDesktopPane();
    //desktoppane.add(backlabel, new Integer(Integer.MIN_VALUE));
    JPanel jpanel2 = new JPanel();
    jpanel2.setBackground(Color.black);
    // JPanel jpanel3 = new JPanel();
    // jpanel3.setBackground(Color.blue); Container conn = chuangkou.getContentPane();
    conn.add(backlabel);
    // conn.add(jpanel1,BorderLayout.SOUTH);
    conn.add(jpanel2, BorderLayout.NORTH);
    // conn.add(jpanel3, BorderLayout.CENTER);
    JMenuBar caidanlan = new JMenuBar();
    // caidanlan.setBorderPainted(falsh);
    JMenu caidan = new JMenu("基础信息管理");
    JMenu caidan1 = new JMenu("进货管理");
    JMenu caidan2 = new JMenu("销售管理");
    JMenu caidan3 = new JMenu("查询统计");
    JMenu caidan4 = new JMenu("库存管理");
    JMenu caidan5 = new JMenu("系统管理");
    caidanlan.add(caidan);
    caidanlan.add(caidan1);
    caidanlan.add(caidan2);
    caidanlan.add(caidan3);
    caidanlan.add(caidan4);
    caidanlan.add(caidan5);
    chuangkou.setJMenuBar(caidanlan);
    chuangkou.setSize(800, 600);
    chuangkou.setVisible(true);
    } public void uptupian() {
    int backw = MyMun.this.chuangkou.getWidth();
    int backh = chuangkou.getHeight();

    backlabel = new JLabel(" <html> <body> <image width='" + backw
    + "'height='" + (backh) + "'src="
    + MyMun.this.getClass().getResource("a.jpg")
    + "'> </img> </body> </html>");
    backlabel.setVerticalAlignment(SwingConstants.TOP);
    backlabel.setHorizontalAlignment(SwingConstants.CENTER);

    if (backlabel != null) {
    backlabel.setSize(backw, backh);
    } } static {
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    e.printStackTrace();
    }
    } public static void main(String[] args) {
    // TODO Auto-generated method stub  new MyMun();
    }}
      

  2.   

    是JDesktopPane的问题,你要好好的看看JDesktopPane的API哦!!!
      

  3.   

    最单间的方法就是在:JDesktopPane desktoppane = new JDesktopPane(); 后面加desktoppane.setLayout(new FlowLayout());
      

  4.   

    最后把desktoppane.add(backlabel, new Integer(Integer.MIN_VALUE)) 改为desktoppane.add(backlabel);