Solved

how to create a nice buttons

Posted on 2004-03-25
6
231 Views
Last Modified: 2010-03-31
HI i have been looking for a how to create a different kind of button  much for example with round corners no the default button with a color in the background
thank you
0
Comment
Question by:dentrita
6 Comments
 

Accepted Solution

by:
pradeepbkumar earned 50 total points
ID: 10684542
Hi,
The best way to create a Button with good look and feel is to write ur own CSS. I could help u out with the CSS in the following code snippet. Take a look at it.

Example 1:
.Button {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 10px;
      background-color: #E4E9FC;
      padding-top: 1px;
      padding-right: 1px;
      padding-bottom: 1px;
      padding-left: 1px;
      border-color: #474747 #B3B7C6 #777A83 #6699CC;
      border-style: ridge;
      border-top-width: 1px;
      border-right-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      font-weight: bold;
}

Example 2:
.ButtonRed {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 10px;
      background-color: #FF6633;
      padding-top: 1px;
      padding-right: 1px;
      padding-bottom: 1px;
      padding-left: 1px;
      border-color: #474747 #B3B7C6 #777A83 #6699CC;
      border-style: ridge;
      border-top-width: 1px;
      border-right-width: 1px;
      border-bottom-width: 1px;
      border-left-width: 1px;
      color: #FFFFFF;
      font-weight: bold;

}

Put these snippets into ur Styles.css file and refrresh the page.


Also one more alternative would be to use ready made images of ur choices.. u will get them from any search engine.

Hope this was useful...

Regards,
Pradeep
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10685017
Hi Friend;

JButton b = new JButton();

// Set the button color . . .
b.setBackground(Color.blue);

// Add picture to button . . .
ImageIcon i2 = new ImageIcon("your path/picture2.gif");
b.setIcon(i2);

// Customize the buttons your way . . .
b.setPressedIcon(createImageIcon("sample2.gif"));
b.setRolloverIcon(createImageIcon("sample3.gif"));
b.setDisabledIcon(createImageIcon("sample4.gif"));
b.setMargin(new Insets(0,0,0,0));

Hope that helps . . .
Javatm
0
 
LVL 3

Expert Comment

by:oraelbis
ID: 10685158
Try use skinable look and feel, there are many diffrent skins for all elements, not only for buttons.
see:

https://skinlf.dev.java.net/
http://www.l2fprod.com/
http://www.shudo.net/java/skinlf/

0
 
LVL 3

Expert Comment

by:oraelbis
ID: 10685160
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 10688426
If you have JAVA JDK then you have excellent examples too:

look for the file      E:\j2sdk1.4.2_03\demo\jfc\SwingSet2\SwingSet2.jar

In my case it's on partition E: and it's version 1.4.2_03.

Run it with   javaw -jar <path>

If you like the demo's, click for the source code.

;JOOP!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Spring Framework HTTPSession management 1 45
table example 4 32
Tagging and Merging on Branch 1 30
Setup GlassFish 4 22
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question