I made this in Photoshop and I plan to use it for my file sharing application:
I was wondering if it was possible to create GUI for my application that is gonna
I have to disagree with you! Actually you can use NetBeans to create such a GUI. It is easy too, you have a lot of options to work with! The ones I personally use are:
1) Create graphics with a painting software, and set it as Icon to the component. I use for the designing process InkScape, but any software should do the trick. You have to be preatty careful in this process, becouse you can't resize images in NetBeans (well, I never tried).
2) extend the UI class (Example: public class CustomButtonUI extend BasicButtonUI), and override the method paint, then use the function setUI (componentName.setUI(new CustomButtonUI);)
This is an example code:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicButtonUI;
/**
*
* @author Ionut Cicio
*/
public class CustomButton extends BasicButtonUI{
int borderThickness, edgeRoundness;
@Override
public void paint(Graphics g, JComponent c) {
Graphics2D g2 = (Graphics2D)g;
g2.setColor(c.getBackground());
borderThickness = 2;
edgeRoundness = 20;
g2.setColor(c.getForeground());
g2.fillRoundRect(0, 0, c.getWidth(), c.getHeight(), edgeRoundness+5, edgeRoundness+5);
g2.drawRoundRect(0, 0, c.getWidth(), c.getHeight(), edgeRoundness+5, edgeRoundness+5);
//g2.fillRect(0, 0, c.getWidth(), c.getHeight());
//g2.drawRect(0, 0, c.getWidth(), c.getHeight());
g2.setColor(c.getBackground());
g2.fillRoundRect(borderThickness, borderThickness, c.getWidth()-(int)(borderThickness*2.5), c.getHeight()-(int)(borderThickness*2.5), edgeRoundness, edgeRoundness);
g2.drawRoundRect(borderThickness, borderThickness, c.getWidth()-(int)(borderThickness*2.5), c.getHeight()-(int)(borderThickness*2.5), edgeRoundness, edgeRoundness);
super.paint(g, c);
}
@Override
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
}
}
It always happens to use both methods together, and it gives you a really big benefit whe working on animations!
For some kinds of UI's as BasicTextFieldUI, understanding how painting works is preatty tricky, but still understandable.