Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to create a nice buttons

Posted on 2004-03-25
6
Medium Priority
?
250 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
5 Comments
 

Accepted Solution

by:
pradeepbkumar earned 150 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

772 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