I am new to AWT UI development, and I have experience building apps for android. So naturally I am relating the UI components from both of them.
Currently I am developing a desktop application where I want have an ImageButton. In Android we generally use .9.png images for that, it is handy and has it's own advantages.
My question is, is there any concept of .9.png in java AWT.
I am not aware of anything like that on J2SE, specially using AWT.
AWT is old. If you have the choice, I recommend you to use Swing instead.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am currently working on an application with a code base that dates back to at least 2001. One of the components of this system is a desktop client that is written using Java Swing. It uses most of the good old layouts including BorderLayout, FlowLayout, and Gridbag layout. There are a number of fairly complex screens we need to manage and update periodically and we sometimes need to create new features with new user interfaces.
Is there something better than Swing we could look into migrating to?
Would it be possible to do this migration in stages (i.e. we would have a mix of the old Swing components with the new components during a prolonged migration phase)?
If we were to re-write the desktop client in Java today should we still use Swing?
I find myself using primarily GridBagLayout, is this still the tool of choice for more complex layouts or are there better layouts I could be using?
I was reading in book that Oracle intend to replace Swing by JavaFX.
Take a look in the question and answer bellow:
6. Is JavaFX replacing Swing as the new client UI library for Java SE?
Yes. However, Swing will remain part of the Java SE specification for the foreseeable future, and therefore included in the JRE. While we recommend developers to leverage JavaFX APIs as much as possible when building new applications, it is possible to extend a Swing application with JavaFX, allowing for a smoother transition.
You can see there original comment here.
In this case, I believe that you can consider to user JavaFX.
More details here and good examples here.
If you are using Java 8 you can use javafx for new componant. It's possible to use Swing componant with javafx.
you can still use java swing, but if you need to migrate you can migrate in stages using JavaFX (again a Desktop Client). if you need to use Web Client, then you could use GWT (this helps since the developers already have knowlege of UI Components) and GWT code is in Java and Javascript gets generated in Compile Time.
Java FX is more powerful and beautiful
We can say that swing is replaced with java FX.
Now a days no body is using swing because there are lot of advantage in java FX over swing
It has good feature called scaneBuilder we can just drag and drop the components to appropriate position so lot of time is saving.
Different type of layout are there to place the components attractively.
Impertinently we can use CSS to disign the UI so is more beautiful and attractive
we can integrate with web components also.
If you're redoing a layout entirely, I'd look at Matisse which uses Spring Layout.
https://netbeans.org/features/java/swing.html
It's far easier to get the relationships between components using a layout tool than trying to line everything up manually in GridBag or something similar.
If you're not redoing a major part of the code, I wouldn't touch it. Don't fix what ain't broken.
Regarding JavaFX, I personally have not been impressed by it. You can take a look at it, but JavaFX struck me as needing more "bake" time. I would not abandon Swing just yet.
If you need to have a Java desktop client looks like native application for some platform (Windows, MacOS, Linux) you can look on Standard Widget Toolkit (SWT) library.
One famous application example of usage of this library is Eclipse IDE. Another - Angry IP Scan, sources are at GitHub.
I am coding in Java for sometime now. But many a times, in graphics and user interface part, the awt section is skipped or omitted and swing is placed instead and said that awt is of no use or less important. I wish to make android applications in studio.....so is learning and studying awt important in respect to android app development or should i jump over to swing and advance java section?
so is learning and studying awt important in respect to android app development
No, as Android does not have AWT.
or should i jump over to swing
No, as Android does not have Swing. Android has its own UI framework.
Focus on language fundamentals, threads, exceptions, and the like. I wrote a blog post a long time ago outlining the key topics, though the Wikibooks links in that post may no longer work in some cases.
This question already has answers here:
Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot? [closed]
(9 answers)
Closed 8 years ago.
Is there any alternative of swing?
I need a high performance GUI toolkit to create desktop application on linux (Ubuntu). I've been creating swing application for 2 years, therefore I want use java.
Yes, there's a number of other UI toolkits available - AWT, SWT, JavaFX, QT to name a few.
I'd primarily recommend JavaFX as the new UI toolkit (it's now part of Java8 and is still under heavy development) or perhaps SWT if you want the "native" feel (since it uses native OS components.) QT does this as well of course, but it requires bindings and is generally more of a faff - so its use is relatively rare in Java land.
On the other sided of things, I'd recommend staying away from AWT (it's the old, original Java GUI framework that lacks many common components in other UI toolkits, and is not really supported any more.)
Try Java FX. It will give you better performance than java Swing. Java FX
Take a look at JavaFX it's now part of the JRE/JDK for Java 8.
http://docs.oracle.com/javase/8/javase-clienttechnologies.htm
You can probably use SWT as an alternative.
https://www.eclipse.org/swt/
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
There are many good books about Java and (almost) every one contains a big section about Swing.
I'm involved in web-development. Is knowing about "Swing" useful for Java web-development?
Applets can be embedded into a web-app., and applications can connect to them. Either provide a richer GUI than is possible with JavaScript/HTML, but unless they bring something specific to the web-app. (rarely the case), it is better to avoid the rich client GUIs & stick with D/HTML.
You could perhaps learn patterns that could be reused in a web application, but no, Swing is not used in webapps.
Probably not. Swing isn't used at all in web development, unless your web app involves Java applets -- Java GUI code which is downloaded to the client and run inside the web browser.
If you want to develop web application using a 'component' approach - like GWT - having knowledge of Swing can help you.
GWT or Vaadin framework are using widgets (window, panel, menu, text area) and layout them to organize the client view. The application is not going from pages to pages but instead have a single entry point that will show and hide windows and panels.
In this way they are very close to Swing (even if they are simpler to handle).
You'll find easier to switch from Swing to GWT (and vis-versa) than to switch from a page based framework (like struts) to GWT.
Understanding the concepts involved in Swing can help in understanding the concepts of Java Server Faces.
But no, other than in applets, Swing is not used for web development.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Most of the desktop application development I do is in Swing, and I'm curious to hear people's thoughts on using JavaFX and/or Adobe Flex for building desktop applications. Have you had success building desktop apps with these? Or would you stick with Swing for now and use tools to help make Swing development more productive?
If you're making desktop apps, I'd stick to Swing. JavaFX/Flex/Silverlight would be more appropriate for RIA - rich internet apps. Although I'd argue that none of them would be a choice for the long term - looks to me like HTML5/CSS3/Ajax are winning the day, but thats a pretty subjective area. But for desktop apps - I'm a big fan of Swing (also Java Web Start is a very underrated technology)
I would say that JavaFX can be seen as a kind of extension of Swing with a new way of developing a Java GUI by using a declarative programming language: the JavaFX Script. JavaFX Script code looks exactly like a JSON script, unlike Adobe Flex or Microsoft Silverlight which uses an XML syntax.
JavaFX Script can interface with Java and therefore can call Swing components easily. It's really a new generation of GUI API, like Swing was for AWT: nice graphical components, new easy ways to manage layouts, really nice features to build dynamic interfaces: bindings, timers (to build animations), etc. Have a look here: http://www.javafx.com/samples/ and to the tutorials and see how fast you can build a kind of Google Picasa application... The API even contains some tools to use easily web services: you can find plenty of samples of GUI built in JavaFX connected to some public web services (like a Weather Forecast tool).
And the best... is the deployment part. You can embed your application within an html page, like an applet, and the user can drag and drop the application to her/his desktop to use it whenever she/he wants (without returning to its browser)!
Really, I think JavaFX, at its early stage though (v1.2), is a really good tool and represents the first step for Java toward the next generation of applications: the Rich Internet Applications (RIA).
Java Swing is an established and mature technology for desktop development. You'll be able to find lots of information online and plenty of sample programs. With that said, however, you might want to consider Adobe AIR. AIR is basically a runtime that lets you run your Flex apps on the desktop, and gives them access to local resources such as the file system. I've written Java Swing apps for 10 years and I am amazed at how much more productive I am using Flex/Adobe AIR. One nice aspect of Flex is that you can create your GUIs declaritively, much like how you use HTML to declare the layout of a webpage. It's a much more concise way to specify a GUI, and much faster and easier to maintain than the reams of Java Swing code you need to do the same thing. I wouldn't recommend JavaFX since it is so late to the party and hasn't really gotten with mainstream developers.
You should try them all and see which one fits best with your requirements. If you want to see what you can do with Flex and how to do it then check out Tour de Flex.
Some of the advantages of Flex are that it is mature (over 5 years old now) and a significant area of investment for Adobe. You can also find numerous examples of AIR apps built with Flex in the Adobe AIR Marketplace.
Swing can look good with Substance L&F.
However, if you are developing alone (as opposed to with a team), trying JavaFX might be a good idea.
Please read the about this, write extremely lightweight swing applications and with the same code base move it to web.
demos
runtime
I had evaluated these for desktop application and finally desided to go for JavaFx . This have very good media library and hardware accelerated graphics and media capabilities . With Jdk 7 update 6 onwards contains JavaFx totally I integrated no separate installation is required . Java swing is very good technology and will be continued but I see JavaFx is the future for GUI and Internet application to some extent. Biggest advantage for me was that JavaFx app could be converted to exe files with native packaging
Also try scenebuilder for drag and drop component designer
I feel that I do not have enough information to answer this question. There are many applications in which an AIR approach is a better choice, other applications use other technologies better. I am primarily an AS3/Flex developer, but I know there are many instances where one of the Java platforms is a better choice. Now that Flex is no longer an Adobe product but rather a Apache product, it will either improve the product as the users will create the roadmap, or kill it off completely.