在网格中显示椭圆 [英] Displaying ovals in grid

查看:70
本文介绍了在网格中显示椭圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。我已经有这个问题很长时间了,这让我感到非常沮丧。 :x


我试图在JPanel上显示42个椭圆形(连接4),但它似乎在面板顶部显示一个巨大的白色框,并且提示os 7椭圆形和JPanel的其余部分为蓝色(背景颜色设置为蓝色)。

我的CircleGrid类:

展开 | 选择 | Wrap | 行号

解决方案


大家好。我已经有这个问题很长时间了,这让我感到非常沮丧。 :x


我试图在JPanel上显示42个椭圆形(连接4),但它似乎在面板顶部显示一个巨大的白色框,并且提示os 7椭圆形和JPanel的其余部分为蓝色(背景颜色设置为蓝色)。



无需感到沮丧;这是唯一的代码;-)从我看到的代码是

根本没有绘图代码所以我不知道问题可能是什么。


亲切的问候,


Jos



无需感到沮丧;这是唯一的代码;-)从我看到的代码是

根本没有绘图代码所以我不知道问题可能是什么。


亲切的问候,


Jos



哦道歉,我忘记了绘图代码。这是:

展开 | 选择 | Wrap | 行号


您的程序逻辑存在缺陷:您有一个存储42个小的CircleGrid JPanel

每个存储一个椭圆形的JPanels。当您的CircleGrid JPanel必须绘制

时,它会尝试自行绘制整个网格/板。你的GridLayout中的所有圈子都没有尝试绘制任何东西,所以JPanels自己

必须处理绘图(他们只是绘制他们的灰色背景)。


将所有实际绘图逻辑移动到它所属的位置:每个圆圈应绘制

本身。 GridLayout将注意每个人在正确的位置吸引自己

(这就是LayoutManagers的用途)。我还没有彻底检查你的代码但是

我的猜测是你的CircleGrid实际上绘制了椭圆形,但是GridLayout

也想绘制(没有任何反应,除了灰色背景图。


亲切的问候,


Jos


Hi guys. I have had this problem for so long now it''s making me feel so depressed. :x

I am trying to display 42 ovals (connect 4) on JPanel but it seems to display a huge white box at the top of the panel and the tips os 7 ovals and the rest of the JPanel is blue (the background colour is set to blue).
My CircleGrid class:

Expand|Select|Wrap|Line Numbers

解决方案

Hi guys. I have had this problem for so long now it''s making me feel so depressed. :x

I am trying to display 42 ovals (connect 4) on JPanel but it seems to display a huge white box at the top of the panel and the tips os 7 ovals and the rest of the JPanel is blue (the background colour is set to blue).

No need to feel depressed; it''s only code ;-) From what I see from that code is
no drawing code at all so I have no idea what the problem might be.

kind regards,

Jos


No need to feel depressed; it''s only code ;-) From what I see from that code is
no drawing code at all so I have no idea what the problem might be.

kind regards,

Jos

Oh apologies, I forgot the drawing code. Here it is:

Expand|Select|Wrap|Line Numbers


Your program logic is flawed: you have a CircleGrid JPanel that stores 42 small
JPanels that store one oval each. When your CircleGrid JPanel has to draw
something it attempts to draw the entire grid/board by itself. None of the circles
in your GridLayout even attempt to draw anything so the JPanels themselves
have to handle the drawing (they just draw their grey backgrounds).

Move all your actual drawing logic to where it belongs: each Circle should draw
itself. The GridLayout will take care that each one draws itself in the correct place
(that''s what LayoutManagers are for). I haven''t thoroughly checked your code but
my guess is that your CircleGrid actually draws the ovals but the GridLayout
also wants to draw (nothing happens there, except for grey background drawing).

kind regards,

Jos


这篇关于在网格中显示椭圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆