Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: swing or javafx or ?

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default swing or javafx or ?

    hi expert people!

    i do not have any experience in GUI in Java and i suddenly have a task to create an application that performs the following:

    users should be able
    1) to draw initial rectangle area
    2) place or draw and be able to move, rotate and scale smaller rectangles on the first area
    3) for every smaller rectangle it should be possible to assign two numbers
    4) place or draw some kind of connection lines between rectangles (roads) (should be possible to set width of the connection line)

    the application should be able
    1) return the area of the first big rectangle and area of every smaller rectangle
    2) return the total area of the connection roads
    3) return the assigned two numbers for every small rectangle
    4) return the exact position of every smaller rectangle and distances between them

    so, the question is - is Swing a good choice for that, should i look into JafaFX for instance or something else?
    i would be glad to receive any tips and thoughts on how to achieve that)
    might be you can advice me some good books on Swing or 2D graphics in Java.

    thanks a lot!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: swing or javafx or ?

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    You'll find the most tutorials online and help in forums like this one if you choose the Swing route. JavaFX is an okay option, and you'll be smarter at it than most if you complete the task using JavaFX, but you'll be largely blazing your own trail.

    The basics for drawing or painting in Swing are in the lesson, Performing Custom Painting. There are similar, largely 3rd party, tutorials for JavaFX that you should be able to find.

    Good luck!

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Location
    Denmark, Albertslund
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: swing or javafx or ?

    You can also use booth off them.

    But swing is best to painting and graphics things.

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: swing or javafx or ?

    But swing is best to painting and graphics things.
    I'd like to disagree with this statement. I've been blow away by some of the painting and drawing abilities in JavaFX. With that being said, if you are familiar with Swing, there is a bit of a learning curve which can make JavaFX feel worse, but once I got used to it, I found it far better.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  5. #5

    Default Re: swing or javafx or ?

    JavaFX the latest desktop development tool which also supports CSS and themes. If you want to have a desktop feel in browser and you want to use Java, GWT is another option, but it's just as bulky as JavaFX, although much less than AWT and Swing.

  6. #6
    Member
    Join Date
    Apr 2014
    Posts
    92
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: swing or javafx or ?

    They're both fully capable of doing simple 2D drawing, but Oracle intends for JavaFX to be a replacement for AWT/Swing, and I think that's a great thing because JavaFX is superior in many ways. Drawing performance is excellent by comparison, and it uses floating point APIs across the board which means you can draw lines 1.5 pixels wide and the JFX runtime will antialias it for you automatically, making it actually appear 1.5 pixels wide on the screen. It also has superior support for touch screens, including multi-touch and 10-finger. AWT/Swing is not good for touch screens if you need timely mousePressed and mouseReleased events.

  7. #7
    Member
    Join Date
    Apr 2014
    Posts
    92
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: swing or javafx or ?

    I should clarify my last statement: "AWT/Swing is not good for touch screens if you need timely mousePressed and mouseReleased events." Touch screens use press-and-hold for right-click gestures, which means your mousePressed listener events don't get called on a touch press, they get called on the touch release (pressed, released, clicked all at once). That's what I meant by "timely." JavaFX has explicit support for touchPressed and touchReleased events, along with the normal hardware mouse events.

  8. #8

    Default Re: swing or javafx or ?

    Java FX has new features and is more promoted. Things like Properties concept, support for CSS and modern touch devices, animations etc.

    Oracle has made JavaFX different than swing only conceptually. Otherwise JavaFX is Swing+new features.
    Last edited by kadammanali987; December 18th, 2018 at 06:14 AM.

  9. #9
    Member
    Join Date
    Dec 2013
    Location
    Honolulu
    Posts
    83
    Thanks
    1
    Thanked 4 Times in 2 Posts

    Default Re: swing or javafx or ?

    Thank you. Swing it is. With the platform and the OS, I could probably connect from the internet with enough memory, to print out any picture I wanted. That picture would uploaded in a buffer area in memory, just like scanning a document. I could then use the Graphics class to print out one of the pictures onto a transparency sheet or stencil sheet. This would allow me then to transfer the sheet onto a t shirt. I have yet to figure out two main class files. The PrintClass file, and inner class file called Graphics. Javax.swing, layout manager, actionPerformed method, JTextArea, JTextField, FileInput/FileOutput file, and java.lang.Object. This would create a program I would need on the internet to perform this print out off the internet and possibly print out to the stencil sheet or transparency sheet. From there print it out and transfer it to a white t shirt.

  10. #10
    Junior Member
    Join Date
    Aug 2020
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: swing or javafx or ?

    Great Information.Thanks for sharing. best router table
    Last edited by Aviyo1; January 14th, 2021 at 05:23 AM.

Similar Threads

  1. JavaFX
    By bodylojohn in forum JavaFX
    Replies: 2
    Last Post: October 16th, 2017, 04:06 AM
  2. javafx problem
    By darshan.bhogale in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 7th, 2013, 07:29 AM
  3. JavaFX on javaprogrammingforums
    By cselic in forum Forum Updates & Feedback
    Replies: 1
    Last Post: July 31st, 2012, 03:48 PM
  4. [SOLVED] JavaFx
    By chronoz13 in forum Java Theory & Questions
    Replies: 2
    Last Post: August 28th, 2009, 09:13 PM