一个简单的toolbar死活出不来。package TestApp;
import java.awt.*;
import javax.swing.table.*;
import javax.swing.JPopupMenu;
import javax.swing.JMenuItem;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import org.jdom.*;
import org.jdom.output.*;
import org.jdom.input.*;/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author Zhangb
 * @version 1.0
 */public class MainFrm extends JFrame {
public JPanel contentPane;
public MainFrm() {
try {
  contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(null);
    this.setLocale(java.util.Locale.getDefault());
    this.setResizable(false);
    this.setTitle("見積ツール");
    contentPane.setBackground(new Color(255, 255, 145)); JToolBar jToolBar = new JToolBar();
JButton jButton1 = new JButton();
ImageIcon image1;       image1 = new ImageIcon("icon\\sample01.bmp");
    jButton1.setIcon(image1);
    jButton1.setToolTipText("Open File");      jToolBar.add(jButton1);    contentPane.add(jToolBar, BorderLayout.NORTH);
   contentPane.setVisible(true);  
}
catch(Exception ex) {
  ex.printStackTrace();
}
}

}

解决方案 »

  1.   

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.*;public class MainFrm extends JFrame {
    public JPanel contentPane;
    public MainFrm() {
    try {
    contentPane = (JPanel) this.getContentPane();
    //contentPane.setLayout(null);
        contentPane.setLayout(new FlowLayout());
        this.setLocale(java.util.Locale.getDefault());
        //this.setResizable(false);
        this.setTitle("中国人写中文");
        this.setSize(400,300);
        contentPane.setBackground(new Color(255, 255, 145)); JToolBar jToolBar = new JToolBar();
    JButton jButton1 = new JButton();
    ImageIcon image1;       image1 = new ImageIcon("icon\\sample01.bmp");
        jButton1.setIcon(image1);
        jButton1.setToolTipText("Open File");      jToolBar.add(jButton1);    contentPane.add(jToolBar, BorderLayout.NORTH);
       contentPane.setVisible(true);  
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
    }

    public static void main(String[] args)
    {
    MainFrm mf=new MainFrm();
    mf.show();
    }

    }