日期:2014-05-20 浏览次数:20791 次
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Example extends JFrame{ public static ImageIcon exampleImage=new ImageIcon(Example.class.getResource("thu.jpg")); JLabel exIL = new JLabel(); JPanel jPanel = new JPanel(); JLabel egL = new JLabel(); public void eIinit(){ exIL.setText(""); exIL.setIcon(exampleImage); egL.setText("example for set the spectrums"); jPanel.add(egL,BorderLayout.NORTH); jPanel.add(exIL,BorderLayout.SOUTH); getContentPane().setLayout(new FlowLayout()); getContentPane().add(jPanel); } public Example(){ // super(); eIinit(); } public static void main(String args[]){ Example f = new Example(); f.pack(); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
------解决方案--------------------
public void example() 加了一个void就变成普通的方法了