Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to create a nice buttons

Posted on 2004-03-25
6
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

715 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