Change Look and Feel of JFrame? - java

How would I go about changing the Look and Feel of a JFrame and Swing components to custom pictures and what not? Is there a set of methods and API's or do I need to just make a custom JFrame that allows me to customize my JFrame further?
I'm trying to get something that looks like the World of Warcraft launcher or League of Legends launcher( best examples i've seen with custom everything xD). I'm pretty new to GUIs.

Not exactly an answer to the question, but since you're just staring with Java GUI, I'd recommend diving right into JavaFX -- a modern Java UI toolkit.
Please be sure to start with JavaFX 2.x -- not JavaFX 1.x, which is basically deprecated.

Related

Mixing Swing and JavaFX in a Java desktop chat application

I know that there are already some question about this, but I can't find my way!
I want to implement a desktop chat application with java which is able to send text,image, video, etc.
Now I am using swing component for my chat conversation window.
I create a JFrame and add JTabbedPane to it inorder to have tab for each new conversation.
for creating each tab I act as follow :
create JPanel (I add this to my JTabbedPane as tab)
newtab = new JPanel();
newtab.setLayout(new BoxLayout(newtab, BoxLayout.PAGE_AXIS));
create JTextPane for display's part of the chat (to have style for conversation like android application such as viber, ....)
I want to be able for following styling:
diffrent alignment
change font, color
insert JComponent (to show other type of messages )
setborder of each message round (I don't want the squre one)
...
context = new StyleContext();
kit = new HTMLEditorKit();
chatPane = new JTextPane();
chatPane.setEditable(false);
chatPane.setContentType("text/html");
chatPane.setEditorKit(kit);
chatPane.setText("");
doc = (HTMLDocument) chatPane.getStyledDocument();
CSS(); // it is for adding ccs style to stylesheet of document
JScrollPane scroll = new JScrollPane(chatPane);
newtab.add(scroll , BorderLayout.CENTER);
My problem is to set perfect stying to my display part, since javax.swing.text.html.CSS provides HTML 3.2 support, so the CSS properties that are supported are limited!
while searching on Internet I find JavaFX, but I don't know is it good to use JavaFX and swing together or even is it possible?!
also which layout manager is better for the JPanel (newtab) to have my JTextPane with scroll.
As its already been said, it is possible to mix Swing and JavaFX especially since Java 8 you can do it both ways:
Embed Swing Components in JavaFX with SwingNode
Embed JavaFX Components in Swing with JFXPanel
Recently we had to make the same decision. We had an application and wanted to migrate to JavaFX to get a more modern design and to make use of all the introduced language features like PropertiesBindings etc., which is nicely supported by JavaFX Components.
So first we tried to embed JavaFX in Swing. All new components were embedded with the help of JFXPanel. It was really easy, but from time to time we had some rendering issues which got more and more annoying. "Unfortunatly" we got used to the new JavaFX API, which is why we deceided redesigning our appliction to make it a JavaFX application with some Swing Parts in it, which was possible, when Java 8 was released, since we didn`t wonna waste time on fixing thoses kind of rendering issues. The redesign was actually some work since some concepts are just different. Benefitting from the new API caused some refactorings, we didnt really wonna do in first place.
But then again mixing Swing and JavaFX got a bit fuzzy, and the look and feel of the application didnt really feel convincing, so then we finally removed all Swing Parts and replaced them by JavaFX Components. So far we don`t regret that step, but it was more work then we expected it to be, eventhough we already used patterns like MVP, where only Views had to be refactored, since presenters were (mostly) free from UI stuff (which was really an interesting process, were we learned a lot about MVP and designing an application).
So in conclusion I just can suggest to create a list of views you have and think of all the components you would need and try to find the corresponding components in JavaFX. Make small examples for the most complex components to see if they fullfill all your usecases. If that is the case and you still have enough time to switch to JavaFX I personally would go for a pure JavaFX approach, because of the experiences I made with mixing JavaFX/Swing, especially since your UI design seems to be in an early state. In the end it is just a question of time you have available for your project and if you are really up to learn about the new concepts and components of JavaFX.
Concerning the JavaFX CSS Support, you find a reference here.
It IS possible to mix JavaFX and Swing. But I have no experience in it. I just did a little FX-UI for a small project which was pretty nice. Especially the CSS-Feature is great.
According to mixing, I just recently found a blog which discouraged mixing both technologies: http://dlemmermann.wordpress.com/2014/07/17/javafx-tip-9-do-not-mix-swing-javafx/
Maybe this gives you a little help.
Recently I was asked same question.
About one month ago I started new project with my team. We use Java 8.0 + JavaFX 2.2.
What problems did I find in JavaFX?
It's new technology, so many issues still not answered. And you must look for it own.
No tray supporting, so you must use java.awt.SystemTray.
Also I found one problem in the design.
For example you want to make beautiful list with cells which contains label which stuck to left side and checkbox about right side. But there is no good way to do it and you have to calculate length of cells and etc..
But JavaFX provide great opportunities for cutomizing GUI. And you can incapsulate your design in jxml file. It's very convient, because it even more separate code from design.
About mixing I think that if platform allows it than you have to use a solution that provided a platform.
And I think that the decision to use JavaFX correct, if only because it is a relatively new technology, developed by Oracle and it probably will soon replace the swing.

How to show GUI design view in java.class?

I'm linking a database to NetBeans now and I need to create a interface for this. But when I need to adjust the position of button, label is difficult. Is it possible that show a GUI design view that easy for me to adjust without use the JFrame component?
If I understood your question correctly, you're looking for a GUI builder for Swing.
Netbeans ships with the Matisse Swing GUI Builder which will help you build GUIs easily and quickly. Tutorials aren't uncommon (such as the official tutorial or some user created videos on YouTube).
Some folks are fine with this work flow (since it speeds up development quite a bit). Others want to use custom frameworks and have requirements to use specific layouts in which case I recommend reading about different layout managers.
Take your pick and happy development! :)
Instead of trying to design your entire application in the GUI editor, you may be able to adapt the approach shown here. This will let you focus on a single container at a time. Also, remember to backup your .form files; more here.

Shiny GUI in Java

Is there any library I can use to create shiny user interfaces in Java?
e.g. The Intel Graphics & Media Control Panel is written in .Net.
Intel Graphics & Media Control Panel
I want to know how to create such UI in Java.
Well you can use and customize your UI with Swing.
Nowdays there is also JavaFx 2.0.
Also there are a lot of extensions like those from SwingLabs,JGoodies,Jide,Glazed List and the amazing Substance look& feel ,Steel Series etc.
Just google for this terms you get a lot of useful links.
http://download.oracle.com/javafx/
http://www.jgoodies.com/
http://swingx.java.net/
http://java.net/projects/substance/
http://harmoniccode.blogspot.com/
Be aware is not easy and out of the box functionality but you can do anything.
By default, Swing user interfaces use a look and feel called 'Metal'.
You could try making your own look and feel to accomplish something similar.

java swing app with a custom titlebar?

Is there a way to write a Java Swing application with a custom chrome? Please take a look* at the frame for Microsoft's Zune 4.0 software.
I realize that colors, the shape of scroll bars, etc. are controlled by skins or looks and feels. Right now I'm trying to tackle the native window which houses the java components--the title bar mainly.
Thanks
(*) http://www.winsupersite.com/zune/zune4_shots.asp
By default the frame of a JFrame is native. This can be removed by calling Frame.setUndecorated. The Sun Window PL&F does not provide a title bar. You could hack aJInternalFrame so that it draws the frame, although that probably isn't going to be as easy as it may seem. Of course, if you are going the full custom route, you can draw whatever you want. From 6u10, Sun's JRE also provides APIs to make windows transparent and non-rectangular.
No part of a Swing component's look and feel is "native" in any way. Swing components are "lightweight", which means they are entirely drawn on the Java side, and not at all on the windowing system side.
To create custom "chrome" you create the UI delegates for one or more components. In yor case, you'd want to muck around with the delegates for JRootPane and JInternalFrame.
The Look and Feel of Swing apps are pluggable..that is it can change on the fly. You can create your own look and feel but its not a simple undertaking. To get started this tutorial explains. This article does a little more.
This project demonstrates what could be done. So its up to your imagination.

What Java GUI framework is good for a first GUI project?

The title description basically says it all. I'd like to use something that requires a relatively short learning curve since it is my first project and I'd like to spend at least some of it actually writing the code, not just learning how to do it, but also something that has good documentation in a way that some new bleeding edge framework probably wouldn't. Any ideas?
If what you want to do, is actually create a working program with a GUI, and you just want to do that I would recommend looking at the Swing GUI editor in NetBeans, as it is very easy to work with and powerful too.
There is an old demonstration floating around showing how to implement a preference panel like the one in Netscape Navigator (the predecessor to Firefox), but I cannot find it right now.
The Java tutorial trail is here: http://java.sun.com/docs/books/tutorial/uiswing/learn/index.html
EDIT: It appears the preference panel demo has been taken offline. You may want to see this demo for NetBeans 6.0 instead: http://www.javalobby.org/eps/matisse-updates/
It's not clear if you mean a desktop or Web GUI.
For a desktop GUI, just use Java's Swing framework. Creating a GUI With JFC/Swing is a starting point for that. Sure it's old but then again so is Swing. You could also try The Java Swing tutorial.
For a Web GUI, start with servlets/JSPs. Try Servlets and JavaServer Pages (JSP) 1.0: A Tutorial.
Swing + MiGLayout ^^
I know you did say you wanted a simple and easy to learn GUI toolkit. #cletus has nailed that answer :)
But if need to look for alternatives and evaluate them before you decide how to write a GUI, check out this list of alternatives to Swing and AWT.
Swing + GroupLayout
I've been posting on these a couple of times.

Categories

Resources