Java JButtons在borderlayout中显示不正确,并且在向按钮添加actionListener时出现问题
对于相同的代码,我这里有两个问题,首先,出于某种原因,JButtons没有显示在当前配置的GUI上,但是代码正在运行(调试器确实显示在该代码行)。我似乎不明白问题出在哪里 我遇到的第二个问题是JButton.addActionListener(this)不喜欢工作,我需要actionListener在另一个类中触发事件,因此我无法执行匿名actionListener 代码如下:Java JButtons在borderlayout中显示不正确,并且在向按钮添加actionListener时出现问题,java,swing,events,jbutton,actionlistener,Java,Swing,Events,Jbutton,Actionlistener,对于相同的代码,我这里有两个问题,首先,出于某种原因,JButtons没有显示在当前配置的GUI上,但是代码正在运行(调试器确实显示在该代码行)。我似乎不明白问题出在哪里 我遇到的第二个问题是JButton.addActionListener(this)不喜欢工作,我需要actionListener在另一个类中触发事件,因此我无法执行匿名actionListener 代码如下: import java.awt.*; import java.awt.event.*; import javax.sw
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PPP extends JFrame{
static digit atp_hundred = new digit(); //Amount to pay
static digit atp_ten = new digit();
static digit atp_unit = new digit();
static digit atp_tenth = new digit();
static digit atp_hundreth = new digit();
static digit ltr_ten = new digit(); //Litres
static digit ltr_unit = new digit();
static digit ltr_tenth = new digit();
static digit ppl_hundred = new digit(); //Pence per litre
static digit ppl_ten = new digit();
static digit ppl_unit = new digit();
static digit ppl_tenth = new digit();
static PPP frame = new PPP();
public static void init() {
frame.setSize(1280,800);
frame.setLayout(new BorderLayout());
JPanel mainPanel = new mainPanel();
mainPanel.setLayout(new GridLayout(2,2));
frame.getContentPane().add(mainPanel);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
System.exit(0);
}
});
frame.setVisible(true);
}
public static void main(String arg[]){
init();
while (true) {
for (int i = 0; i < 10; i++) {
atp_hundred.value = i;
atp_hundred.update();
frame.getContentPane().repaint();
try {
Thread.sleep(1000);
} catch (Exception e) {
}
frame.getContentPane().repaint();
try {
Thread.sleep(10);
} catch (Exception e) {
}
}
}
}
public void refresh() {
repaint();
}
public PPP(){
super();
}
/*public void update(Graphics g) {
paint(g);
}*/
public static void atpCreate(Graphics g, int x, int y) {
atp_hundred.create(x, y);
drawPolygons(g, atp_hundred);
atp_ten.create(x+50,y);
drawPolygons(g, atp_ten);
atp_unit.create(x+100, y);
drawPolygons(g, atp_unit);
g.drawOval(x+145, y+60, 10,10);
atp_tenth.create(x+160, y);
drawPolygons(g, atp_tenth);
}
public static void ltrCreate(Graphics g, int x, int y) {
ltr_ten.create(x+50, y);
drawPolygons(g, ltr_ten);
ltr_unit.create(x+100, y);
drawPolygons(g, ltr_unit);
g.drawOval(x+145, y+60, 10, 10);
ltr_tenth.create(x+160, y);
drawPolygons(g, ltr_tenth);
}
public static void pplCreate(Graphics g, int x, int y) {
ppl_hundred.create(x, y);
drawPolygons(g, ppl_hundred);
ppl_ten.create(x+50,y);
drawPolygons(g, ppl_ten);
ppl_unit.create(x+100, y);
drawPolygons(g, ppl_unit);
g.drawOval(x+145, y+60, 10,10);
ppl_tenth.create(x+160, y);
drawPolygons(g, ppl_tenth);
}
public static void drawPolygons(Graphics g, digit d) {
if (d.top) {
g.setColor(Color.green);
g.fillPolygon(d.ptop);
} else {
g.setColor(Color.black);
g.drawPolygon(d.ptop);
}
if (d.topleft) {
g.setColor(Color.green);
g.fillPolygon(d.ptopleft);
} else {
g.setColor(Color.black);
g.drawPolygon(d.ptopleft);
}
if (d.topright) {
g.setColor(Color.green);
g.fillPolygon(d.ptopright);
} else {
g.setColor(Color.black);
g.drawPolygon(d.ptopright);
}
if (d.mid) {
g.setColor(Color.green);
g.fillPolygon(d.pmid);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pmid);
}
if (d.botleft) {
g.setColor(Color.green);
g.fillPolygon(d.pbotleft);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pbotleft);
}
if (d.botright) {
g.setColor(Color.green);
g.fillPolygon(d.pbotright);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pbotright);
}
if (d.bot) {
g.setColor(Color.green);
g.fillPolygon(d.pbot);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pbot);
}
g.setColor(Color.black);
}
}
class mainPanel extends JPanel {
public mainPanel() {
setPreferredSize(new Dimension(1280,800));
JPanel customerPanel = new customerPanel();
customerPanel.setLayout(new BorderLayout());
add(customerPanel);
//add(new customerButtons());
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(new Font("Copperplate Gothic Light", Font.PLAIN, 30));
String title = "Pete's Petrol Pump Simulation vAlpha0.1";
g.setColor(Color.white);
//g.clearRect(0,0,640,500);
g.setColor(Color.black);
g.drawString(title, (int)(640 - (g.getFontMetrics().getStringBounds(title, g).getWidth() / 2)), 75);
}
}
class customerPanel extends JPanel {
public customerPanel() {
//setPreferredSize(new Dimension(640,500));
//setPreferredSize(new Dimension(500,800));
customerButtons buttons = new customerButtons();
add(buttons, BorderLayout.SOUTH);
}
@Override
public void paintComponent(Graphics g){
//super.paintComponent(g);
/*g.setFont(new Font("Copperplate Gothic Light", Font.PLAIN, 30));
String title = "Pete's Petrol Pump Simulation vAlpha0.1";
g.setColor(Color.white);
g.clearRect(0,0,640,500);
g.setColor(Color.black);
g.drawString(title, (int)(640 - (g.getFontMetrics().getStringBounds(title, g).getWidth() / 2)), 75);*/
g.drawRoundRect(20,100,600,250,5,5);
g.setFont(new Font("Gill Sans MT", Font.PLAIN, 20));
g.drawString("Amount to Pay: ", 40, 160);
PPP.atpCreate(g, 200, 110);
g.drawString("Litres Dispensed: ", 40, 240);
PPP.ltrCreate(g, 200, 190);
g.drawString("Pence per Litre: ", 40, 320);
PPP.pplCreate(g, 200, 270);
//System.out.println((g.getFontMetrics().getStringBounds("Amount to Pay", g).getWidth()));
}
}
class customerButtons extends JPanel {
public customerButtons() {
JButton remove = new JButton("Remove nozzle");
remove.setActionCommand("remove");
//System.out.println("Hello");
remove.addActionListener(this);
remove.setToolTipText("Replace the fucking nozzle");
JButton squeeze = new JButton("Squeeze nozzle");
squeeze.setActionCommand("squeeze");
squeeze.addActionListener(this);
squeeze.setToolTipText("Squeeze the fucking nozzle");
JButton stop = new JButton("Stop Squeeze");
stop.setActionCommand("stop");
stop.addActionListener(this);
stop.setToolTipText("Stop squeezing the fucking nozzle");
JButton replace = new JButton("Replace nozzle");
replace.setActionCommand("replace");
replace.addActionListener(this);
replace.setToolTipText("Replace the fucking nozzle");
add(remove);
add(squeeze);
add(stop);
add(replace);
}
}
class digit {
int value = 0;
boolean top = false;
boolean topleft = false;
boolean topright = false;
boolean mid = false;
boolean botleft = false;
boolean botright = false;
boolean bot = false;
public void update() {
switch(value) {
case 0: top = true;
topleft = true;
topright = true;
mid = false;
botleft = true;
botright = true;
bot = true;
break;
case 1: top = false;
topleft = false;
topright = true;
mid = false;
botleft = false;
botright = true;
bot = false;
break;
case 2: top = true;
topleft = false;
topright = true;
mid = true;
botleft = true;
botright = false;
bot = true;
break;
case 3: top = true;
topleft = false;
topright = true;
mid = true;
botleft = false;
botright = true;
bot = true;
break;
case 4: top = false;
topleft = true;
topright = true;
mid = true;
botleft = false;
botright = true;
bot = false;
break;
case 5: top = true;
topleft = true;
topright = false;
mid = true;
botleft = false;
botright = true;
bot = true;
break;
case 6: top = true;
topleft = true;
topright = false;
mid = true;
botleft = true;
botright = true;
bot = true;
break;
case 7: top = true;
topleft = false;
topright = true;
mid = false;
botleft = false;
botright = true;
bot = false;
break;
case 8: top = true;
topleft = true;
topright = true;
mid = true;
botleft = true;
botright = true;
bot = true;
break;
case 9: top = true;
topleft = true;
topright = true;
mid = true;
botleft = false;
botright = true;
bot = true;
break;
}
}
Polygon ptop = new Polygon();
Polygon ptopleft = new Polygon();
Polygon ptopright = new Polygon();
Polygon pmid = new Polygon();
Polygon pbotleft = new Polygon();
Polygon pbotright = new Polygon();
Polygon pbot = new Polygon();
public void create(int x, int y) {
ptop.addPoint(x+10, y);
ptop.addPoint(x+30, y);
ptop.addPoint(x+35, y+5);
ptop.addPoint(x+30, y+10);
ptop.addPoint(x+10, y+10);
ptop.addPoint(x+5, y+5);
ptopleft.addPoint(x+5, y+5);
ptopleft.addPoint(x+10, y+10);
ptopleft.addPoint(x+10, y+30);
ptopleft.addPoint(x+5, y+35);
ptopleft.addPoint(x, y+30);
ptopleft.addPoint(x, y+10);
ptopright.addPoint(x+35, y+5);
ptopright.addPoint(x+40, y+10);
ptopright.addPoint(x+40, y+30);
ptopright.addPoint(x+35, y+35);
ptopright.addPoint(x+30, y+30);
ptopright.addPoint(x+30, y+10);
pmid.addPoint(x+10, y+30);
pmid.addPoint(x+30, y+30);
pmid.addPoint(x+35, y+35);
pmid.addPoint(x+30, y+40);
pmid.addPoint(x+10, y+40);
pmid.addPoint(x+5, y+35);
pbotleft.addPoint(x+5, y+35);
pbotleft.addPoint(x+10, y+40);
pbotleft.addPoint(x+10, y+60);
pbotleft.addPoint(x+5, y+65);
pbotleft.addPoint(x, y+60);
pbotleft.addPoint(x, y+40);
pbotright.addPoint(x+35, y+35);
pbotright.addPoint(x+40, y+40);
pbotright.addPoint(x+40, y+60);
pbotright.addPoint(x+35, y+65);
pbotright.addPoint(x+30, y+60);
pbotright.addPoint(x+30, y+40);
pbot.addPoint(x+10, y+60);
pbot.addPoint(x+30, y+60);
pbot.addPoint(x+35, y+65);
pbot.addPoint(x+30, y+70);
pbot.addPoint(x+10, y+70);
pbot.addPoint(x+5, y+65);
}
}
import java.awt.*;
导入java.awt.event.*;
导入javax.swing.*;
公共类PPP扩展了JFrame{
静态数字atp_一百=新数字();//支付金额
静态数字atp_十=新数字();
静态数字atp_单位=新数字();
静态数字atp_第十位=新数字();
静态数字atp_百分位=新数字();
静态数字ltr_ten=新数字();//升
静态数字ltr_单位=新数字();
静态数字ltr_第十位=新数字();
静态数字ppl_一百=新数字();//每升便士
静态数字ppl_十=新数字();
静态数字ppl_单位=新数字();
静态数字ppl_第十位=新数字();
静态PPP帧=新PPP();
公共静态void init(){
帧设置大小(1280800);
frame.setLayout(新的BorderLayout());
JPanel mainPanel=新的mainPanel();
主面板设置布局(新网格布局(2,2));
frame.getContentPane().add(主面板);
frame.addWindowListener(新java.awt.event.WindowAdapter(){
公共无效窗口关闭(java.awt.event.WindowEvent){
系统出口(0);
}
});
frame.setVisible(true);
}
公共静态void main(字符串arg[]){
init();
while(true){
对于(int i=0;i<10;i++){
atp_100.value=i;
atp_100.update();
frame.getContentPane().repaint();
试一试{
睡眠(1000);
}捕获(例外e){
}
frame.getContentPane().repaint();
试一试{
睡眠(10);
}捕获(例外e){
}
}
}
}
公共无效刷新(){
重新油漆();
}
公共购买力平价(){
超级();
}
/*公共空间更新(图g){
油漆(g);
}*/
公共静态无效atpCreate(图形g、整数x、整数y){
创建(x,y);
绘图多边形(g,atp_100);
创建(x+50,y);
绘制多边形(g,atp__十);
atp_单位创建(x+100,y);
牵引装置(g、atp_装置);
g、 牵引椭圆(x+145,y+60,10,10);
创建(x+160,y);
绘制多边形(g,atp_);
}
公共静态void ltrCreate(图形g、整数x、整数y){
创建(x+50,y);
绘图多边形(g、ltr__en);
ltr_单位创建(x+100,y);
绘图多边形(g,ltr_单位);
g、 牵引椭圆(x+145,y+60,10,10);
ltr_.创建(x+160,y);
绘制多边形(g,第10层);
}
公共静态无效pplCreate(图形g、整数x、整数y){
创建(x,y);
(g,ppl_100);
ppl_十。创建(x+50,y);
绘制多边形(g,ppl_十);
ppl_单位。创建(x+100,y);
绘图多边形(g,ppl_单位);
g、 牵引椭圆(x+145,y+60,10,10);
ppl_第十个。创建(x+160,y);
(g,ppl_);
}
公共静态空心多边形(图形g,数字d){
如果(d.顶部){
g、 setColor(Color.green);
g、 填充多边形(d.ptop);
}否则{
g、 设置颜色(颜色为黑色);
g、 牵引多边形(d.ptop);
}
如果(d.左上角){
g、 setColor(Color.green);
g、 填充多边形(d.ptopleft);
}否则{
g、 设置颜色(颜色为黑色);
g、 绘制多边形(d.ptopleft);
}
如果(右上角){
g、 setColor(Color.green);
g、 填充多边形(d.ptopright);
}否则{
g、 设置颜色(颜色为黑色);
g、 绘制多边形(d.ptopright);
}
如果(d.mid){
g、 setColor(Color.green);
g、 填充多边形(d.pmid);
}否则{
g、 设置颜色(颜色为黑色);
g、 绘制多边形(d.pmid);
}
if(d.botleft){
g、 setColor(Color.green);
g、 填充多边形(d.pbotleft);
}否则{
g、 设置颜色(颜色为黑色);
g、 drawPolygon(d.pbotleft);
}
if(d.botright){
g、 setColor(Color.green);
g、 填充多边形(d.pbotright);
}否则{
g、 设置颜色(颜色为黑色);
g、 绘制多边形(d.pbotright);
}
如果(d.bot){
g、 setColor(Color.green);
g、 填充多边形(d.pbot);
}否则{
g、 设置颜色(颜色为黑色);
g、 牵引多边形(d.pbot);
}
g、 设置颜色(颜色为黑色);
}
}
类主面板扩展了JPanel{
公共主面板(){
设置首选尺寸(新尺寸(1280800));
JPanel customerPanel=新的customerPanel();
setLayout(新的BorderLayout());
添加(customerPanel);
//添加(新的customerButtons());
}
@凌驾
公共组件(图形g){
超级组件(g);
g、 setFont(新字体(“铜版哥特式灯光”,字体为30号普通字体);
字符串title=“皮特的汽油泵模拟vAlpha0.1”;
g、 setColor(Color.white);
//g、 clearRect(0,0640500);
g、 设置颜色(颜色为黑色);
g、 drawString(title,(int)(640-(g.getFontMetrics().getStringBounds(title,g.getWidth()/2)),75);
}
}
类customerPanel扩展了JPanel{
公共客户面板(){
//setPreferredSize(新尺寸(640500));
//设置首选大小(ne)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PPP extends JFrame{
static digit atp_hundred = new digit(); //Amount to pay
static digit atp_ten = new digit();
static digit atp_unit = new digit();
static digit atp_tenth = new digit();
static digit atp_hundreth = new digit();
static digit ltr_ten = new digit(); //Litres
static digit ltr_unit = new digit();
static digit ltr_tenth = new digit();
static digit ppl_hundred = new digit(); //Pence per litre
static digit ppl_ten = new digit();
static digit ppl_unit = new digit();
static digit ppl_tenth = new digit();
static PPP frame = new PPP();
public static void init() {
frame.setSize(1280,800);
frame.setLayout(new BorderLayout());
JPanel mainPanel = new mainPanel();
mainPanel.setLayout(new GridLayout(2,2));
frame.getContentPane().add(mainPanel);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
System.exit(0);
}
});
frame.setVisible(true);
}
public static void main(String arg[]){
init();
while (true) {
for (int i = 0; i < 10; i++) {
atp_hundred.value = i;
atp_hundred.update();
frame.getContentPane().repaint();
try {
Thread.sleep(1000);
} catch (Exception e) {
}
frame.getContentPane().repaint();
try {
Thread.sleep(10);
} catch (Exception e) {
}
}
}
}
public void refresh() {
repaint();
}
public PPP(){
super();
}
/*public void update(Graphics g) {
paint(g);
}*/
public static void atpCreate(Graphics g, int x, int y) {
atp_hundred.create(x, y);
drawPolygons(g, atp_hundred);
atp_ten.create(x+50,y);
drawPolygons(g, atp_ten);
atp_unit.create(x+100, y);
drawPolygons(g, atp_unit);
g.drawOval(x+145, y+60, 10,10);
atp_tenth.create(x+160, y);
drawPolygons(g, atp_tenth);
}
public static void ltrCreate(Graphics g, int x, int y) {
ltr_ten.create(x+50, y);
drawPolygons(g, ltr_ten);
ltr_unit.create(x+100, y);
drawPolygons(g, ltr_unit);
g.drawOval(x+145, y+60, 10, 10);
ltr_tenth.create(x+160, y);
drawPolygons(g, ltr_tenth);
}
public static void pplCreate(Graphics g, int x, int y) {
ppl_hundred.create(x, y);
drawPolygons(g, ppl_hundred);
ppl_ten.create(x+50,y);
drawPolygons(g, ppl_ten);
ppl_unit.create(x+100, y);
drawPolygons(g, ppl_unit);
g.drawOval(x+145, y+60, 10,10);
ppl_tenth.create(x+160, y);
drawPolygons(g, ppl_tenth);
}
public static void drawPolygons(Graphics g, digit d) {
if (d.top) {
g.setColor(Color.green);
g.fillPolygon(d.ptop);
} else {
g.setColor(Color.black);
g.drawPolygon(d.ptop);
}
if (d.topleft) {
g.setColor(Color.green);
g.fillPolygon(d.ptopleft);
} else {
g.setColor(Color.black);
g.drawPolygon(d.ptopleft);
}
if (d.topright) {
g.setColor(Color.green);
g.fillPolygon(d.ptopright);
} else {
g.setColor(Color.black);
g.drawPolygon(d.ptopright);
}
if (d.mid) {
g.setColor(Color.green);
g.fillPolygon(d.pmid);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pmid);
}
if (d.botleft) {
g.setColor(Color.green);
g.fillPolygon(d.pbotleft);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pbotleft);
}
if (d.botright) {
g.setColor(Color.green);
g.fillPolygon(d.pbotright);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pbotright);
}
if (d.bot) {
g.setColor(Color.green);
g.fillPolygon(d.pbot);
} else {
g.setColor(Color.black);
g.drawPolygon(d.pbot);
}
g.setColor(Color.black);
}
}
class mainPanel extends JPanel {
public mainPanel() {
setPreferredSize(new Dimension(1280,800));
JPanel customerPanel = new customerPanel();
add(customerPanel);
//add(new customerButtons());
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setFont(new Font("Copperplate Gothic Light", Font.PLAIN, 30));
String title = "Pete's Petrol Pump Simulation vAlpha0.1";
g.setColor(Color.white);
//g.clearRect(0,0,640,500);
g.setColor(Color.black);
g.drawString(title, (int)(640 - (g.getFontMetrics().getStringBounds(title, g).getWidth() / 2)), 75);
}
}
class customerPanel extends JPanel {
public customerPanel() {
//setPreferredSize(new Dimension(640,500));
//setPreferredSize(new Dimension(500,800));
setLayout(new BorderLayout());
customerButtons buttons = new customerButtons();
add(buttons, BorderLayout.SOUTH);
}
@Override
public void paintComponent(Graphics g){
//super.paintComponent(g);
/*g.setFont(new Font("Copperplate Gothic Light", Font.PLAIN, 30));
String title = "Pete's Petrol Pump Simulation vAlpha0.1";
g.setColor(Color.white);
g.clearRect(0,0,640,500);
g.setColor(Color.black);
g.drawString(title, (int)(640 - (g.getFontMetrics().getStringBounds(title, g).getWidth() / 2)), 75);*/
g.drawRoundRect(20,100,600,250,5,5);
g.setFont(new Font("Gill Sans MT", Font.PLAIN, 20));
g.drawString("Amount to Pay: ", 40, 160);
PPP.atpCreate(g, 200, 110);
g.drawString("Litres Dispensed: ", 40, 240);
PPP.ltrCreate(g, 200, 190);
g.drawString("Pence per Litre: ", 40, 320);
PPP.pplCreate(g, 200, 270);
//System.out.println((g.getFontMetrics().getStringBounds("Amount to Pay", g).getWidth()));
}
}
class customerButtons extends JPanel implements ActionListener {
public customerButtons() {
JButton remove = new JButton("Remove nozzle");
remove.setActionCommand("remove");
//System.out.println("Hello");
remove.addActionListener(this);
remove.setToolTipText("Replace the fucking nozzle");
JButton squeeze = new JButton("Squeeze nozzle");
squeeze.setActionCommand("squeeze");
squeeze.addActionListener(this);
squeeze.setToolTipText("Squeeze the fucking nozzle");
JButton stop = new JButton("Stop Squeeze");
stop.setActionCommand("stop");
stop.addActionListener(this);
stop.setToolTipText("Stop squeezing the fucking nozzle");
JButton replace = new JButton("Replace nozzle");
replace.setActionCommand("replace");
replace.addActionListener(this);
replace.setToolTipText("Replace the fucking nozzle");
add(remove);
add(squeeze);
add(stop);
add(replace);
}
public void actionPerformed(ActionEvent e) {
// do your stuff here
}
}
class digit {
int value = 0;
boolean top = false;
boolean topleft = false;
boolean topright = false;
boolean mid = false;
boolean botleft = false;
boolean botright = false;
boolean bot = false;
public void update() {
switch(value) {
case 0: top = true;
topleft = true;
topright = true;
mid = false;
botleft = true;
botright = true;
bot = true;
break;
case 1: top = false;
topleft = false;
topright = true;
mid = false;
botleft = false;
botright = true;
bot = false;
break;
case 2: top = true;
topleft = false;
topright = true;
mid = true;
botleft = true;
botright = false;
bot = true;
break;
case 3: top = true;
topleft = false;
topright = true;
mid = true;
botleft = false;
botright = true;
bot = true;
break;
case 4: top = false;
topleft = true;
topright = true;
mid = true;
botleft = false;
botright = true;
bot = false;
break;
case 5: top = true;
topleft = true;
topright = false;
mid = true;
botleft = false;
botright = true;
bot = true;
break;
case 6: top = true;
topleft = true;
topright = false;
mid = true;
botleft = true;
botright = true;
bot = true;
break;
case 7: top = true;
topleft = false;
topright = true;
mid = false;
botleft = false;
botright = true;
bot = false;
break;
case 8: top = true;
topleft = true;
topright = true;
mid = true;
botleft = true;
botright = true;
bot = true;
break;
case 9: top = true;
topleft = true;
topright = true;
mid = true;
botleft = false;
botright = true;
bot = true;
break;
}
}
Polygon ptop = new Polygon();
Polygon ptopleft = new Polygon();
Polygon ptopright = new Polygon();
Polygon pmid = new Polygon();
Polygon pbotleft = new Polygon();
Polygon pbotright = new Polygon();
Polygon pbot = new Polygon();
public void create(int x, int y) {
ptop.addPoint(x+10, y);
ptop.addPoint(x+30, y);
ptop.addPoint(x+35, y+5);
ptop.addPoint(x+30, y+10);
ptop.addPoint(x+10, y+10);
ptop.addPoint(x+5, y+5);
ptopleft.addPoint(x+5, y+5);
ptopleft.addPoint(x+10, y+10);
ptopleft.addPoint(x+10, y+30);
ptopleft.addPoint(x+5, y+35);
ptopleft.addPoint(x, y+30);
ptopleft.addPoint(x, y+10);
ptopright.addPoint(x+35, y+5);
ptopright.addPoint(x+40, y+10);
ptopright.addPoint(x+40, y+30);
ptopright.addPoint(x+35, y+35);
ptopright.addPoint(x+30, y+30);
ptopright.addPoint(x+30, y+10);
pmid.addPoint(x+10, y+30);
pmid.addPoint(x+30, y+30);
pmid.addPoint(x+35, y+35);
pmid.addPoint(x+30, y+40);
pmid.addPoint(x+10, y+40);
pmid.addPoint(x+5, y+35);
pbotleft.addPoint(x+5, y+35);
pbotleft.addPoint(x+10, y+40);
pbotleft.addPoint(x+10, y+60);
pbotleft.addPoint(x+5, y+65);
pbotleft.addPoint(x, y+60);
pbotleft.addPoint(x, y+40);
pbotright.addPoint(x+35, y+35);
pbotright.addPoint(x+40, y+40);
pbotright.addPoint(x+40, y+60);
pbotright.addPoint(x+35, y+65);
pbotright.addPoint(x+30, y+60);
pbotright.addPoint(x+30, y+40);
pbot.addPoint(x+10, y+60);
pbot.addPoint(x+30, y+60);
pbot.addPoint(x+35, y+65);
pbot.addPoint(x+30, y+70);
pbot.addPoint(x+10, y+70);
pbot.addPoint(x+5, y+65);
}
}