How to create colour full button in java
Button component part of abstract window toolkit(awt).Button component is more important in java for graphical user interface based program.
Button is use to generate an event .when any user click at Button component then some thing
hanpped in application program .Button component is main and most used component of an applications.So it is required always showing better and nice .it look is so important because it provided better look to your application .Better application always so popular now first need to developer how to make better look environment with help of component here we give some tips how to make a colour full button in java.
tips
1.always Button choose in java from javax
2.set nice looking font.
3.set height and width in balanced ratio.
4.set balanced font size according button size
5.set background colour matching with form component
6.Text colour (fore colour) is matching from button background colour show correctly text.
How make colour full button follow steps
1.click at start button in windows os.
2.double click at NetBeans IDE
3.click at file then click at new projects
4.choose java and java application and then click and next button
5.type the project name click at finish button.
6.Right click at project and jframe
7.drag a jButton at jframe
8.Right click at jButton and set background colour and foreground colour
9.choose font and their size and type
10.Open Button project file and type some code
Button mm=new Button();
mm.setVisible(true);
11.run your projects.
if you want to create form code then type code and run it
//create colourless button component in java source code
import java.awt.*;
public class frame
{
public static void main(String args[])
{
Button b;
Frame f=new Frame("welcome in internationalyouthacuity");
f.setSize(250,150);
b=new Button("Press me");
f.add(b);
f.setLocation(200,200);
f.setVisible(true);
System.out.println("Return to Dos promt and press control+c fro quit");
}
}
//create colorfull Button source code
//color full code Button make some changes like this
import java.awt.*;
import java.awt.Color;
public class frame
{
public static void main(String args[])
{
Button b=new Button("Press me");
b.setBackground(new Color(255, 102, 51));
b.setFont(new Font("Dialog", 1, 12)); // NOI18N
b.setForeground(new Color(51, 255, 0));
Frame f=new Frame("welcome in internationalyouthacuity");
f.setSize(250,150);
f.add(b);
f.setLocation(200,200);
f.setVisible(true);
System.out.println("Return to Dos promt and press control+c fro quit");
}
}
0 comments:
Post a Comment