Google Answers Logo
View Question
 
Q: Problem with Code ( No Answer,   0 Comments )
Question  
Subject: Problem with Code
Category: Computers
Asked by: charbrad-ga
List Price: $5.00
Posted: 29 Nov 2003 19:04 PST
Expires: 02 Dec 2003 18:45 PST
Question ID: 281789
Hi I have a problem with my code.  First let me explain what I am trying to do:

Create 26 buttons each with a letter of the alphabet, then create
swing applet to hold panels in a five by one grid.  Each the 1st four
panels have six buttons and the fifth has 2.

Problem.......my grid is 26 panels instead of the five.  Here is my code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Alphabet extends JApplet implements ActionListener
{
JButton button5 = null;
JLabel alphaLabel = null;

public void init()
{
Container con = getContentPane();
con.setLayout(new GridLayout());
JPanel panel = new JPanel(new GridLayout(1,5));
JButton button1 = new JButton("A  B  C  D  E  F");
JButton button2 = new JButton("G  H  I  J  K  L");
JButton button3 = new JButton("M  N  O  P  Q  R");
JButton button4 = new JButton("S  T  U  V  W  X");
JButton button5 = new JButton("Y  Z");
alphaLabel = new JLabel(" ALPHABET LETTER ");
button5 = new JButton("Y  Z");
panel.add(button5);
button5.addActionListener(this);
panel.add(button1);
panel.add(button2);
panel.add(button3);
panel.add(button4);
panel.add(alphaLabel);
JButton a = new JButton("A");
JButton b = new JButton("B");
JButton c = new JButton("C");
JButton d = new JButton("D");
JButton e = new JButton("E");
JButton f = new JButton("F");
JButton g = new JButton("G");
JButton h = new JButton("H");
JButton i = new JButton("I");
JButton j = new JButton("J");
JButton k = new JButton("K");
JButton l = new JButton("L");
JButton m = new JButton("M");
JButton n = new JButton("N");
JButton o = new JButton("O");
JButton p = new JButton("P");
JButton q = new JButton("Q");
JButton r = new JButton("R");
JButton s = new JButton("S");
JButton t = new JButton("T");
JButton u = new JButton("U");
JButton v = new JButton("V");
JButton w = new JButton("W");
JButton x = new JButton("X");
JButton y = new JButton("Y");
JButton z = new JButton("Z");
con.add(a);
con.add(b);
con.add(c);
con.add(d);
con.add(e);
con.add(f);
con.add(g);
con.add(h);
con.add(i);
con.add(j);
con.add(k);
con.add(l);
con.add(m);
con.add(n);
con.add(o);
con.add(p);
con.add(q);
con.add(r);
con.add(s);
con.add(t);
con.add(u);
con.add(v);
con.add(w);
con.add(x);
con.add(y);
con.add(z);

}

public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();

if (source == button5)
{
alphaLabel.setText("Folder X");

} 
}
}

Request for Question Clarification by secret901-ga on 29 Nov 2003 20:25 PST
Hi charbrad,

Is the layout like at this page what you're looking for:
http://www.illegalcombatant.com/ga/Alphabet.htm

secret901-ga

Clarification of Question by charbrad-ga on 29 Nov 2003 20:45 PST
no there should be five buttons....in the first 4 there should be six
letters in each box of the alphabet.  In the fifth button there should
be 2.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy