任何程序(包括自己写的,以前运行正常的,书本的示例程序)凡是来自Swing包的UI控件,统统无法显示!所有这样的程序(比如一个JFrame上放一个JButton或JLabel),都只能显示一个里面是灰色的框!
其他,比如AWT做的UI的程序就一切正常!
靠!如果把Swing控件和Awt控件放在一个面板里,就是Swing的无法显示!(一片灰色)真是晕啊。
我装的jdk 1.4.2 (j2sdk-1_4_2-windows-i586.exe 42.7M 含Jre)
环境变量设置么凡是我知道的和网上查的到的方法都尝试过了!
新下的jdk 1.5.0也试过了!更要命的是今天重装了系统竟然问题依旧!!!!
同样的代码我移到笔记本上就运行正常!无语!!!!哪位大虾帮帮我啊!!!!!!!!!

解决方案 »

  1.   

    唉,只能同情你了。:(
    不管你装过那些版本,任何时候,只能是仅仅某一个特定JVM启动并运行程序,应该没问题的啊。
      

  2.   

    如果可以的话,发程序给我,我帮你看看,我的Email地址:[email protected]
      

  3.   

    原来安装的jdk删除了没,所有跟它有关的都删了重装。我原来也这样,重装了就好了,在看看是否有病毒啊,这可不是开玩笑的^=^
      

  4.   

    我也出现了这样的情况只能支持AWT的东东不能支持swing的东东不过我的问题是出现在Pocket PC上的,可能是虚拟机的问题,低层不支持。
      

  5.   

    比如这个吧corejava上的一个例子。
    楼上说的是真的吗?可是连我以前自己写的程序也这样啊!
    /**
       @version 1.01 2001-07-22
       @author Cay Horstmann
    */import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;/**
       This program demonstrates the tabbed pane component organizer.
    */
    public class TabbedPaneTest
    {  
       public static void main(String[] args)
       {  
          JFrame frame = new TabbedPaneFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.show();
       }
    }/**
       This frame shows a tabbed pane and radio buttons to 
       switch between wrapped and scrolling tab layout.
    */
    class TabbedPaneFrame extends JFrame
    {  
       public TabbedPaneFrame()
       {  
          setTitle("TabbedPaneTest");
          setSize(WIDTH, HEIGHT);      final JTabbedPane tabbedPane = new JTabbedPane();
          // we set the components to null and delay their
          // loading until the tab is shown for the first time      ImageIcon icon = new ImageIcon("yellow-ball.gif");      tabbedPane.addTab("Mercury", icon, null);
          tabbedPane.addTab("Venus", icon, null);
          tabbedPane.addTab("Earth", icon, null);
          tabbedPane.addTab("Mars", icon, null);
          tabbedPane.addTab("Jupiter", icon, null);
          tabbedPane.addTab("Saturn", icon, null);
          tabbedPane.addTab("Uranus", icon, null);
          tabbedPane.addTab("Neptune", icon, null);
          tabbedPane.addTab("Pluto", icon, null);      getContentPane().add(tabbedPane, "Center");      tabbedPane.addChangeListener(new
             ChangeListener()
             {
                public void stateChanged(ChangeEvent event)
                {                 // check if this tab still has a null component               if (tabbedPane.getSelectedComponent() == null)
                   {  
                      // set the component to the image icon                  int n = tabbedPane.getSelectedIndex();
                      String title = tabbedPane.getTitleAt(n);
                      ImageIcon planetIcon 
                         = new ImageIcon(title + ".gif");
                      tabbedPane.setComponentAt(n, 
                         new JLabel(planetIcon));                  // indicate that this tab has been 
                      // visited--just for fun                  tabbedPane.setIconAt(n, 
                         new ImageIcon("red-ball.gif"));
                   }
                }
             });      JPanel buttonPanel = new JPanel();
          ButtonGroup buttonGroup = new ButtonGroup();
          JRadioButton wrapButton = new JRadioButton("Wrap tabs");
          wrapButton.addActionListener(new
             ActionListener()
             {
                public void actionPerformed(ActionEvent event)
                {
                   tabbedPane.setTabLayoutPolicy(
                      JTabbedPane.WRAP_TAB_LAYOUT);
                }
             });
          buttonPanel.add(wrapButton);
          buttonGroup.add(wrapButton);
          wrapButton.setSelected(true);
          JRadioButton scrollButton 
             = new JRadioButton("Scroll tabs");
          scrollButton.addActionListener(new
             ActionListener()
             {
                public void actionPerformed(ActionEvent event)
                {
                   tabbedPane.setTabLayoutPolicy(
                      JTabbedPane.SCROLL_TAB_LAYOUT);
                }
             });
          buttonPanel.add(scrollButton);
          buttonGroup.add(scrollButton);
          getContentPane().add(buttonPanel, BorderLayout.SOUTH);
       }   private static final int WIDTH = 400;
       private static final int HEIGHT = 300;
    }
      

  6.   

    还有,或许谁提供一小段在你们的机器上可以运行的Swing程序给我我试试
      

  7.   

    晕啊
    刚才在一台新的笔记本上
    装的同样的JDK
    用同样的环境设置
    用同样的  IDE
    运行同样的代码!
    就正常!靠!
      

  8.   

    楼主在 dos窗口下 运行 java -version 看看jvm的版本看看是不是你装的jdk 1.4.2 或者 jdk 1.5
      

  9.   

    没人赞成把AWT和Swing混起来用吧?有个性
      

  10.   

    要说最简单地Swing程序,我想莫过于:
    import javax.swing.JOptionPane;public class HelloSwing {
    public static void main(String args[]) {
    JOptionPane.showMessageDialog(null, "How Swing!");
    }
    };楼主试试运行否?俺的机器上没任何问题。
      

  11.   

    ...
    import javax.swing.JOptionPane;public class HelloSwing {
    public static void main(String args[]) {
    JOptionPane.showMessageDialog(null, "How Swing!");
    }
    };
    不可以弹出的Dialog一片灰