Re: JButton's dont appear
You need to add the components to the user interface. The buttons have been added to a JPanel (pnl1), now that panel needs to be added to the JFrame. More information and code snippets can be found at:
Lesson: Using Swing Components (The Java™ Tutorials > Creating a GUI With JFC/Swing)
Re: JButton's dont appear
thank you for the reply
I dont understand, its exactly as it is in the book.
Could you please alter the code in my first post as an example?
Re: JButton's dont appear
What if you simply move the setVisible(true) to the bottom of the constructor so that it is called after all components have been added?
Also, your main method creates a Windows object, not a Buttons object. I think that you want to create Buttons so that its code will be called.
Re: JButton's dont appear
Disregard everything in my previous post except the link, which has valuable information and is important for you to visit (the JPanel is added, just in a different order) - I misread your code. As Fubarable mentioned, call setVisible after the components have been added
Re: JButton's dont appear
I have already tried setVisible at the end but same results :(
Re: JButton's dont appear
Quote:
Originally Posted by
k3eper
I have already tried setVisible at the end but same results :(
Have you followed my other recommendation? Does your main method still look like this?
Code:
public static void main (String[] args)
{
Window gui = new Window();
}
Or have you changed it as I recommended to:
Code:
public static void main (String[] args)
{
new Buttons();
}
The Buttons class's code won't run if you don't tell it to in the main method. Simple as that.
Re: JButton's dont appear
Arr thats done it, thank you for your time and patience. For some reason (newb) I thought the Window call was actualy spawning the window. :(y): thank you again