[nbusers] Buttons At Runtime

  • From: "bartonn" < >
  • To:
  • Subject: [nbusers] Buttons At Runtime
  • Date: Mon, 08 Mar 2010 16:31:36 +0000

Thanks for your response David. Ii have changed my DrawScreen routine to 
include what you've suggested. It now looks like this:
    public void DrawScreen(){
       JButton courseBoxButton = new javax.swing.JButton();
courseBoxButton.setText("Hello");
courseBoxButton.setBounds(100, 100, 100, 100);
GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0; // whatever x coord makes sense
gridBagConstraints.gridy = 0; // whatever y makes sense
gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
mainPanel.add(courseBoxButton, gridBagConstraints);

courseBoxButton.setVisible(true);
}

DrawScreen is called from the Initialisation routine after         
initComponents();
It still does not appear! 
I agree that I could create millions of buttons to handle every possibility 
but this doesn't seem very efficient as I will only need a few of them when I 
know what they are. All my Java books (& experience outside of Netbeans) 
suggests that just adding the component to the panel should make it show. Can 
you spot what I'm doing wrong? It must be something really dumb!

Thanks,
Neil






[nbusers] Buttons At Runtime

bartonn 03/06/2010

[nbusers] Re: Buttons At Runtime

djohnson 03/07/2010

[nbusers] Buttons At Runtime

bartonn 03/08/2010

[nbusers] Re: Buttons At Runtime

Mark Wade 03/08/2010

[nbusers] Re: Buttons At Runtime

Gregg Wonderly 03/08/2010

[nbusers] Buttons At Runtime

bartonn 03/09/2010

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close