2 Replies - 168 Views - Last Post: 09 December 2012 - 10:02 PM Rate Topic: -----

#1 hhpaet  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 10-November 12

JPositionalButtons not showing up

Posted 08 December 2012 - 07:03 PM

I am attempting to put together a networked Bingo game. I was using JButtons for my bingo card, and my instructor advised me to switch to JPositionalButtons, which I did. We both looked at the code and said what was there looked good, but when I got home to hit play, it window showed up with no buttons on it! I'm having a hard time finding information about the JPositionalButton, but I'm not sure that that's even where I need to be looking. Please give me some sort of direction. Thank you!

private void buildPanel()
    {

        panel = new JPanel();
        panel.setLayout(new GridLayout(ROWS, COLS));
        buttons = new PositionalJButton[ROWS * COLS];

        panel.setPreferredSize(new Dimension(ROWS * COLS * 10, ROWS * COLS * 10));

        Random gen = new Random();

        selections = new int[ROWS][COLS];
        //resetSelections();

        for (int row = 0; row < buttons.length; row++)
        {
            for (int col = 0; col < buttons.length; col++)
            {
                PositionalJButton temp = new PositionalJButton(gen.toString(), row, col);
                temp.addActionListener(new SubmitButtonListener());
                this.add(temp);
            }

        }
    }



Is This A Good Question/Topic? 0
  • +

Replies To: JPositionalButtons not showing up

#2 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1373
  • View blog
  • Posts: 3,027
  • Joined: 05-April 11

Re: JPositionalButtons not showing up

Posted 08 December 2012 - 08:35 PM

JPositionalButtons ? That isn't a standard swing component?
Kinda hard for us to help when you don't post the JPositionalButtons class or any doc

Anyway... You do not add the JPositionalButtons to your panel, instead you add it to some other container (which I do not think was intentional)

Change
this.add(temp);


With
panel.add(temp);


Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: JPositionalButtons not showing up

Posted 09 December 2012 - 10:02 PM

Just have a feeling of what you are tying to do :)

A GridLayout would be a lot more appropriate :)
It has been designed by Java professionals and had been tested in millions of applications over the world
So just gorget about your own designed JPositionnalButtons... it is a bad designed to start with :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1