Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
Like Tree6Likes

Thread: hi, how to add a graphic component , say a line2D, to a swing?

  1. #21
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    Quote Originally Posted by Tolls View Post
    No.
    Go through the link above provided by Darryl.
    You will have to do this if you want to work with Swing GUIs.
    You clearly don't know enough about it at the moment. Providing code will simply make things worse.
    Java Code:
    import javax.swing.SwingUtilities;
    import javax.swing.JFrame;
    
    public class SwingPaintDemo1 {
        
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });
        }
        
        private static void createAndShowGUI() {
            System.out.println("Created GUI on EDT? "+
                    SwingUtilities.isEventDispatchThread());
            JFrame f = new JFrame("Swing Paint Demo");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(250,250);
            f.setVisible(true);
        }
    }
    this is the java code in the site..
    but the class deosn't extend JFrame, but it uses an object from JFrame.. is it possible in any case?
    the given code ran without any errors
    ---edited: and what is the use of "class classname extends JFrame"
    ---edited: thx
    regards
    dhilip
    Last edited by noobplus; 03-12-2012 at 04:15 PM.

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,574
    Rep Power
    23

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    There is more than one page on the site and there is more than one sample. I referred you to SwingPaintDemo2

    There are many ways to build a GUI using the JFrame class. One can extend the class, another can have it as a variable
    noobplus likes this.

  3. #23
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    Quote Originally Posted by Norm View Post
    There is more than one page on the site and there is more than one sample. I referred you to SwingPaintDemo2

    There are many ways to build a GUI using the JFrame class. One can extend the class, another can have it as a variable
    checking those samples.. between, GUI includes swing, and applet? or includes only swing?

    thx
    dhilip

  4. #24
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    Quote Originally Posted by noobplus View Post
    checking those samples.. between, GUI includes swing, and applet? or includes only swing?

    thx
    dhilip
    sorry.. the site said me "Swing GUI Components Includes everything from buttons to split panes to tables. Many components are capable of sorting, printing, and drag and drop, to name a few of the supported features." so GUI should also include Graphics and applets.. I'll Be right back .. working out the samples..

    regards dhilip

  5. #25
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    Quote Originally Posted by noobplus View Post
    thx, and how do we initialize graphics into the method "paintComponent()" ?
    You don't. It's an argument to the method.

    The questions you're asking suggest much bigger gaps in your knowledge than just how to use Swing. If this is your very first Java class ever, find a better teacher.
    noobplus likes this.
    Get in the habit of using standard Java naming conventions!

  6. #26
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    Quote Originally Posted by kjkrum View Post
    You don't. It's an argument to the method.

    The questions you're asking suggest much bigger gaps in your knowledge than just how to use Swing. If this is your very first Java class ever, find a better teacher.
    I am a giraffe man. i grow very fast

  7. #27
    noobplus's Avatar
    noobplus is offline Senior Member
    Join Date
    Feb 2012
    Location
    chennai,south of India(south east of asia)
    Posts
    232
    Rep Power
    3

    Default Re: hi, how to add a graphic component , say a line2D, to a swing?

    Quote Originally Posted by kjkrum View Post
    You don't. It's an argument to the method.

    The questions you're asking suggest much bigger gaps in your knowledge than just how to use Swing. If this is your very first Java class ever, find a better teacher.
    actuly i came here while doing my project work for my u.g. course final year . project final submission date is next week. i forgot some stuffs of java. i learnt it 2 yrs back

Page 2 of 2 FirstFirst 12

Similar Threads

  1. embed Flex component in Java Swing
    By monireh in forum AWT / Swing
    Replies: 0
    Last Post: 02-24-2011, 02:28 PM
  2. Which swing component is suitable for TextEditor...?
    By Dinesh_rockz in forum AWT / Swing
    Replies: 1
    Last Post: 02-23-2011, 05:41 AM
  3. swing component
    By cahyadiakbar in forum AWT / Swing
    Replies: 0
    Last Post: 09-22-2010, 10:40 AM
  4. Require Links for free swing component
    By Gajesh Tripathi in forum Advanced Java
    Replies: 2
    Last Post: 08-11-2007, 10:24 PM
  5. Swing Graphic interface
    By Daniel in forum AWT / Swing
    Replies: 2
    Last Post: 06-28-2007, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •