Results 1 to 2 of 2
Thread: BorderLayout
- 04-17-2012, 07:55 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 4
- Rep Power
- 0
BorderLayout
I my program there are going to be multiple panels that I want to layout nicely for the user. How can I set a Border Layout in a JPanel and the set that JPanel in a Border Layout on a JFrame.
Ok, that sounds a little confusing. Let's make that simpler. I need to set a Border Layout on a part of the program that only extends JPanel. How would I set a Border Layout for a JPanel?
Because I keep getting an error: non-static method setLayout(java.awt.LayoutManager) cannot be referenced from a static context
- 04-17-2012, 08:12 AM #2
Re: BorderLayout
Nothing to do with JPanel or BorderLayout. Everything to do with your (need of) understanding of static vs non-static members.
Static methods are invoked on the class; non-static members on an instance of the class, created using the new keyword.Java Code:class A { public static void showStatic() { System.out.println("static method"); } public void showNonStatic() { System.out.println("non-static method"); } } class B { public static void main(String[] args) { A.showStatic(); A a = new A(); a.showNonStatic(); } }
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
Similar Threads
-
How to use BorderLayout
By Daman12 in forum New To JavaReplies: 15Last Post: 10-27-2011, 06:30 AM -
BorderLayout problem
By TGH in forum New To JavaReplies: 3Last Post: 05-27-2010, 10:51 PM -
BorderLayout
By oneself in forum New To JavaReplies: 3Last Post: 08-06-2009, 11:59 PM -
BorderLayout Demo
By Java Tip in forum SWT TipsReplies: 0Last Post: 07-11-2008, 05:51 PM -
Help with BorderLayout
By lenny in forum AWT / SwingReplies: 1Last Post: 07-31-2007, 08:26 AM
Bookmarks