Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help with JApplet

Name: Anonymous 2008-12-19 18:04

I need to write an event driven JApplet, with 15 labeled buttons. The buttons say nearly identical things, with the exception of a number. I do not want to write them individually, and I need to know a way I can group them in a JApplet.

Essentially I need a way I can just write one string such as:
buttons [i] = new JButton ("Seat " + (i+1) + " is open.");
and have it label all the buttons.

I have an hour to figure out how to do this.
Help is greatly appreciated.

Name: Anonymous 2008-12-19 20:01


package org.fourchan.dis.prog.t1229727637.p16;

public class Java101 extends Object {
  public static final int BUTTONS = 15;

  public static void main(String[] argv) {
    /* FRAME SECTION. */
    JFrame frame = new JFrame();
    frame.setSize(800, 600);

    /* CUNT SECTION. */
    Container cunt = frame.getContentPane();
    cunt.setLayout(new GridLayout(2, 1));

    /* LABEL SECTION. */
    JLabel label = new JLabel("fag");
    cunt.add(label, BorderLayout.NORTH);

    /* PANEL SECTION. */
    JPanel buttonPanel = new JPanel();
    cunt.add(buttonPanel, BorderLayout.CENTER);

    /* BUTTON SECTION. */
    JButton[] buttons = new JButton[NUM_BUTTONS];
    for (int i=0; i < buttons.length; i++) {
      buttons[i] = new JButton("Seat " + (i+1) + " is open");
      buttons[i].add(new );
      cunt.add(buttons[i]);
    }

    /* SETUP SECTION. */
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List