java jpanel layout,新手求助啊关于JPanel跟gridlayout的

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

我用的是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)

······

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值