File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Swing simple Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing simple" Watch "Swing simple" New topic
Author

Swing simple

abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635


I can't see any button in this form. Why?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Because a JFrame has a default BorderLayout.

Learn all about the standard AWT and Swing layout managers here.


luck, db
There are no new questions, but there may be new answers.
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
I use BorderLayout, But it doesn't work!


Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol : constructor BorderLayout()
location: class BorderLayout
at simplegui.Main.main(Main.java:19)
Java Result: 1

Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 563
Did you,


?

But I think Darryl's point was that JFrame uses BorderLayout by default, and you weren't using it correctly or maybe it wasn't the right layout for your application. The link he provided was to give you details on how to use BorderLayout - or another layout - correctly.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Noel Alex
Greenhorn

Joined: Jul 25, 2011
Posts: 7



Counting the brackets is a good thing to make sure that you get not errors during compiling..

The class BorderLayout is may be required for import..

Here is working code:



INMHO:: There is tools such as Eclipse to help with code typo errors..



MWaNDuLu
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
Thanks!
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635


Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static method setPreferredSize(java.awt.Dimension) cannot be referenced from a static context
at simplegui.SimpleGui.main(SimpleGui.java:24)
Java Result: 1


I looked at this code in this site:



http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JPanel.html
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

abalfazl hossein wrote:

That should be


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635


The button does not react.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19785
    
  20

That code doesn't even compile. Please post a proper SSCCE.
abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635


I see this message:

Package frame does not exist.

Why this message appears?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

What Rob said.
Rob Spoor wrote:That code doesn't even compile. Please post a proper SSCCE.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing simple