该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我用的是eclipse
JPanel p1=new JPanel(new GridLayout(1,3,10,10));
这一句在代码显示错误:构造函数 JPanel(GridLayout)未定义
JPanel p2=new JPanel();
p1.setLayout(new GridLayout(2,2,10,10));
我改成这样之后,他不显示错误,但是运行异常一大堆
部分如下
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.getEntry(HashMap.java:443)
at java.util.HashMap.get(HashMap.java:405)
at sun.awt.AppContext.get(AppContext.java:604)
at com.sun.java.swing.SwingUtilities3.getDelegateRepaintManager(SwingUtilities3.java:120)
at javax.swing.RepaintManager.getDelegate(RepaintManager.java:1625)
at javax.swing.RepaintManager.addDirtyRegion(RepaintManager.java:445)
at javax.swing.JComponent.repaint(JComponent.java:4795)
at java.awt.Component.repaint(Component.java:3286)
at javax.swing.JComponent.setBackground(JComponent.java:2733)
at javax.swing.LookAndFeel.installColors(LookAndFeel.java:175)
at javax.swing.LookAndFeel.installColorsAndFont(LookAndFeel.java:211)
at javax.swing.plaf.basic.BasicPanelUI.installDefaults(BasicPanelUI.java:66)
at javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:56)
at javax.swing.JComponent.setUI(JComponent.java:664)
at javax.swing.JPanel.setUI(JPanel.java:153)
at javax.swing.JPanel.updateUI(JPanel.java:126)
at javax.swing.JPanel.(JPanel.java:86)
at javax.swing.JPanel.(JPanel.java:109)
at javax.swing.JPanel.(JPanel.java:117)
at javax.swing.JRootPane.createGlassPane(JRootPane.java:545)
at javax.swing.JRootPane.(JRootPane.java:365)
at javax.swing.JFrame.createRootPane(JFrame.java:277)
at javax.swing.JFrame.frameInit(JFrame.java:258)
at javax.swing.JFrame.(JFrame.java:181)
at t00101.JPanel.(JPanel.java:9)
at t00101.JPanel.(JPanel.java:13)
at t00101.JPanel.(JPanel.java:13)
at t00101.JPanel.(JPanel.java:13)
······