problem with layout manager in applets - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

problem with layout manager in applets

RibbletonRibbleton Posts: 152Member
Not sure why the button doesn't appear on the screen. I'm drawing objects at the top of the screen using the paint method. But i also want buttons to appear at the bottom of the screen. Could someone please help me thanks.


private JButton BStart;
private BorderLayout Layout;

public void init()
{
Layout = new BorderLayout(1,1);
Container c = getContentPane();
BStart = new JButton("START");
c.add(BStart, BorderLayout.SOUTH ); // Adding button to screen

offscreen = createImage(580, 450);
bufferGraphics = offscreen.getGraphics();

addKeyListener(k1);
myBall= new Ball(100,100);

sound1 = getAudioClip(
getCodeBase(), "Bsound.wav");
}

thanks
*Ribbleton _

Comments

  • arb123arb123 Posts: 696Member
    : Not sure why the button doesn't appear on the screen. I'm drawing objects at the top of the screen using the paint method. But i also want buttons to appear at the bottom of the screen. Could someone please help me thanks.

    You'll kick yourself ... you aren't setting the layout on the container. c.setLayout(Layout)

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

  • RibbletonRibbleton Posts: 152Member
    : : Not sure why the button doesn't appear on the screen. I'm drawing objects at the top of the screen using the paint method. But i also want buttons to appear at the bottom of the screen. Could someone please help me thanks.
    :
    : You'll kick yourself ... you aren't setting the layout on the container. c.setLayout(Layout)
    :
    : ---------------------------------
    : [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    :
    :

    Thanks for that help got it kinder working,
    When i mean kinder,( and i'm sure i will kick myself harder)

    When i run the applet the buttons only appear once i mouse click were they are suppose to be located.

    any ideas, i've tried moving the code about nut doesnt seem to do anything.

    Container c = getContentPane();

    RightPanel = new JPanel();
    RightPanel.setLayout( new GridLayout( 3, 1, 5, 5) );
    RightPanel.setBorder(BorderFactory.createLineBorder(Color.green));

    B1Player = new JButton("B1Player");
    B1Player.addActionListener ( this );
    // c.add(B1Player);
    B2Player = new JButton("B2Player");
    // c.add(B2Player);
    BComPlayer = new JButton("BComPlayer");
    //c.add(BComPlayer);

    RightPanel.add( B1Player );
    RightPanel.add( B2Player );
    RightPanel.add( BComPlayer );

    c.add( RightPanel, BorderLayout.EAST );

    Thanks
    *Ribbleton_

  • arb123arb123 Posts: 696Member
    The snippet you posted looks correct. I don't think the problem lies here.

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

Sign In or Register to comment.