Results 1 to 11 of 11
Thread: First day of Swing
- 06-01-2011, 02:27 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
First day of Swing
Hello everyone!
It's my first day of learing swing and i'm kinda lost already
i'm doing everything by the book, using NetBeans
and it's just not working =(
Can anyone help?
import java.awt.*;
import java.util.*;
import java.text.*;
import javax.swing.*;
public class SS {
Swing () Error "Invalid method declaration; return type required"
{
JFrame mySS = new JFrame();
mySS.setText("Pes app"); Error "Cannot find symbol; symbol method setText (java.lang.String, location : variable.mySS of type javax.swing.JFrame)
mySS.setSize (300,300);
mySS.show(); This Line is striked out
}
public static void main(String[] args) {
new SS ();
}
}Last edited by Grish; 06-01-2011 at 02:51 PM.
- 06-01-2011, 02:29 PM #2
- 06-01-2011, 02:35 PM #3
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
Ok
So I'm just tring to bring up a simple window with title.
on line Swing () it's telling me "Invalid method declaration"
on line mySS.setText("Pes app"); there is an error "Cannot find symbol"
and mySS.show(); is just striked out.
I'm so sorry for this type of question, but I'm just starting to learn.
- 06-01-2011, 03:05 PM #4
Read : Defining Methods
Because there is no method called setText for JFrame
They are deprecated methods. For more details : What "Deprecated" Means
Hope that helps,
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 06-01-2011, 03:11 PM #5
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
Thank you so much!
Huh...I guess my book is pretty outdated? Everything runs well for the author.gif)
Can I ask the last question, just to make sure, so what would I use instead of setText for title of the simple frame?
UPD: I got it! THANK YOU SO MUCH!
yay, i was going crazy there :DLast edited by Grish; 06-01-2011 at 03:17 PM.
- 06-01-2011, 03:15 PM #6
See: setTitle
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 06-01-2011, 05:34 PM #7
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,158
- Rep Power
- 5
Maybe you can start by using the Swing tutorial:
Trail: Creating a GUI With JFC/Swing: Table of Contents (The Java Tutorials)
- 06-01-2011, 08:55 PM #8
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
Thanks guys.
I was really thrown off by this textbook, which I should ditch I guess :) It's extremely outdated
- 06-02-2011, 04:23 AM #9
Member
- Join Date
- Feb 2011
- Posts
- 83
- Rep Power
- 0
Sorry for late response but another way to create a JFrame is to make it a parent class which is done by: public class classname extends JFrame.
then you can add or set properties without have to specify the JFrame each time so you would do this like: super(title)
Java Code:public class whatever extends JFrame{ public whatever(){ super("MY FIRST WINDOW); setSize(400,400); setVisible(true); } }
- 06-02-2011, 11:51 AM #10
- 06-02-2011, 01:02 PM #11
Similar Threads
-
About Swing
By satimis in forum New To JavaReplies: 2Last Post: 05-01-2010, 05:37 PM -
swing.jar
By krrishnak in forum AWT / SwingReplies: 2Last Post: 04-05-2009, 05:29 AM -
What is next to Swing
By javaplus in forum AWT / SwingReplies: 1Last Post: 01-13-2008, 10:16 PM -
AWT or Swing
By bugger in forum AWT / SwingReplies: 4Last Post: 11-22-2007, 09:44 AM -
map javax.swing.text.Element to javax.swing.text.View
By elizabeth in forum New To JavaReplies: 1Last Post: 07-30-2007, 07:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks