[java] What do these appletviewer error type things mean?
I made an applet, and it compiles fine. But when I run appletviewer, I get these errors:
java.lang.ArrayIndexOutOfBoundsException: 550
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:887)
at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:806)
at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:1373)
at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1336)
at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:706)
at java.awt.Container.layout(Container.java:1017)
at java.awt.Container.doLayout(Container.java:1007)
at java.awt.Container.validateTree(Container.java:1089)
at java.awt.Container.validateTree(Container.java:1096)
at java.awt.Container.validate(Container.java:1064)
at sun.applet.AppletPanel.run(AppletPanel.java:360)
at java.lang.Thread.run(Thread.java:536)
here is my source code so far (yes, it''s sparse, but it should still work)
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
*
* @author David Grimsley
* @title Battle Monsters
* @version 0.1
*
*/
public class BattleMonsters extends Applet implements ActionListener
{
Label lAttack1 = new Label("Attack 1");
Label lAttack2 = new Label("Attack 2");
Label lAttack3 = new Label("Attack 3");
Label lDefense1 = new Label("Defense 1");
Label lDefense2 = new Label("Defense 2");
Label lDefense3 = new Label("Defense 3");
TextField fA1 = new TextField(5);
TextField fA2 = new TextField(5);
TextField fA3 = new TextField(5);
TextField fD1 = new TextField(5);
TextField fD2 = new TextField(5);
TextField fD3 = new TextField(5);
Button bMonst1 = new Button("ATK w/ Monster 1");
Button bMonst2 = new Button("ATK w/ Monster 2");
Button bMonst3 = new Button("ATK w/ Monster 3");
Button bCom1 = new Button("Attack this monster");
Button bCom2 = new Button("Attack this monster");
Button bCom3 = new Button("Attack this monster");
public void init()
{
GridBagLayout layout1 = new GridBagLayout();
GridBagConstraints c1 = new GridBagConstraints();
setLayout(layout1);
add(lAttack1);
layout1.setConstraints(lAttack1, c1);
c1.gridx = 100;
c1.gridy = 500;
add(lAttack2);
layout1.setConstraints(lAttack2, c1);
c1.gridx = 130;
c1.gridy = 500;
add(lAttack3);
layout1.setConstraints(lAttack3, c1);
c1.gridx = 160;
c1.gridy = 500;
add(lDefense1);
layout1.setConstraints(lDefense1, c1);
c1.gridx = 100;
c1.gridx = 550;
add(lDefense2);
layout1.setConstraints(lDefense2, c1);
c1.gridx = 130;
c1.gridy = 550;
add(lDefense3);
layout1.setConstraints(lDefense3, c1);
c1.gridx = 160;
c1.gridy = 550;
add(bMonst1);
layout1.setConstraints(bMonst1, c1);
c1.gridx = 100;
c1.gridy = 600;
add(bMonst2);
layout1.setConstraints(bMonst2, c1);
c1.gridx = 130;
c1.gridy = 600;
add(bMonst3);
layout1.setConstraints(bMonst3, c1);
c1.gridx = 160;
c1.gridy = 600;
bMonst1.addActionListener(this);
bMonst2.addActionListener(this);
} // end init()
public void actionPerformed(ActionEvent e)
{
} // end actionPerformed()
} // end class
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*
*
* @author David Grimsley
* @title Battle Monsters
* @version 0.1
*
*/
public class BattleMonsters extends Applet implements ActionListener
{
Label lAttack1 = new Label("Attack 1");
Label lAttack2 = new Label("Attack 2");
Label lAttack3 = new Label("Attack 3");
Label lDefense1 = new Label("Defense 1");
Label lDefense2 = new Label("Defense 2");
Label lDefense3 = new Label("Defense 3");
TextField fA1 = new TextField(5);
TextField fA2 = new TextField(5);
TextField fA3 = new TextField(5);
TextField fD1 = new TextField(5);
TextField fD2 = new TextField(5);
TextField fD3 = new TextField(5);
Button bMonst1 = new Button("ATK w/ Monster 1");
Button bMonst2 = new Button("ATK w/ Monster 2");
Button bMonst3 = new Button("ATK w/ Monster 3");
Button bCom1 = new Button("Attack this monster");
Button bCom2 = new Button("Attack this monster");
Button bCom3 = new Button("Attack this monster");
public void init()
{
GridBagLayout layout1 = new GridBagLayout();
GridBagConstraints c1 = new GridBagConstraints();
setLayout(layout1);
add(lAttack1);
layout1.setConstraints(lAttack1, c1);
c1.gridx = 100;
c1.gridy = 500;
add(lAttack2);
layout1.setConstraints(lAttack2, c1);
c1.gridx = 130;
c1.gridy = 500;
add(lAttack3);
layout1.setConstraints(lAttack3, c1);
c1.gridx = 160;
c1.gridy = 500;
add(lDefense1);
layout1.setConstraints(lDefense1, c1);
c1.gridx = 100;
c1.gridx = 550;
add(lDefense2);
layout1.setConstraints(lDefense2, c1);
c1.gridx = 130;
c1.gridy = 550;
add(lDefense3);
layout1.setConstraints(lDefense3, c1);
c1.gridx = 160;
c1.gridy = 550;
add(bMonst1);
layout1.setConstraints(bMonst1, c1);
c1.gridx = 100;
c1.gridy = 600;
add(bMonst2);
layout1.setConstraints(bMonst2, c1);
c1.gridx = 130;
c1.gridy = 600;
add(bMonst3);
layout1.setConstraints(bMonst3, c1);
c1.gridx = 160;
c1.gridy = 600;
bMonst1.addActionListener(this);
bMonst2.addActionListener(this);
} // end init()
public void actionPerformed(ActionEvent e)
{
} // end actionPerformed()
} // end class
ok, nevermind
i had the constraints for the gridbag layout too high. I guess that can only go to a certain number. anyone know for certain? anyone know what that number is?
i had the constraints for the gridbag layout too high. I guess that can only go to a certain number. anyone know for certain? anyone know what that number is?
Let's see, you have a 160 x 600 grid. I don't think grid bag layout is meant to be used that way. What is it that you're trying to achieve? For most of my GUI programming, even the most complex, my grids never exceed 20 x 20.
Perhaps you should read up on how to use GridbagLayout, or use something else.
EDIT: It just struck me that you're probably misunderstanding what gridx and gridy are. These aren't pixels, but rather cells. Look up the documentation for more information.
[edited by - NuffSaid on March 26, 2003 6:14:00 PM]
Perhaps you should read up on how to use GridbagLayout, or use something else.
EDIT: It just struck me that you're probably misunderstanding what gridx and gridy are. These aren't pixels, but rather cells. Look up the documentation for more information.
[edited by - NuffSaid on March 26, 2003 6:14:00 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement