Java Swing- Metal Buttons?

in Genius Bar edited January 2014
Ok so i am making this program in Java using swing. I found out how to set the look and feel to the brushed metal. But now how do i make the buttons on my program those brushed metal buttons. When u use interface builder there are these metal looking buttons. They would really fit in with my program. Does ne1 here know how to turn a button into one of Mac OS metal buttons?



  • Reply 1 of 11
    I don't use an interface builder... shure they make life easy but if you learn how to set up an interface using just java then you will run into less problems down the line. Problems like trying to add or change things in the interface... or editing a open source java project when someone else made the layout. You just need to get used to reading code, it takes time.

    Umm... kind of program are you working on? What will it do? or are you just playing around?

    In any case can I get a copy (PM me with it). I like playing with code.

    Oh... and I am not an expert. I have just taken a highschool course on it (to which my teacher thought I was too advanced for).
  • Reply 2 of 11
    Well i think i must have phrased my post wrong. What i mean to say is that I am making the code in java swing and i agree with what you said. So what i want to do is to put the metal buttons (that are in interface builder) into my java swing program.

    Yes i will tell you when its finished. I am making some open source software that is pretty useful. Do you want me to email you, maybe u could work with me?

    If so then what is your email.

    Thanks for the support, i am in the middle of finsihing the code.
  • Reply 3 of 11

    Like I said, I only have a highschool course under my belt, but I would like to take a look at your code. I might be able to contribute (only if it is under the GPL),


    But I don't know how much help I can be.
  • Reply 4 of 11
    I hope this little program helps... it was my first Java programs that used a GUI. It uses awt and swing, and planes/grids to line up the interface.


    /* Jon Wickes

    * Jan. 13 2003

    * Current v0.6.2

    * <History>

    *v0.1 (First shot at GUI... but it looks ugly)

    *v0.3 (math code added, changed the layout... still looks ugly)

    *v0.5 (fixed incorrect code in minutes and secconds, changed layout... again)

    *v0.6 (changed the way the program prompts the user for his/her name, first and last)

    *v0.6.1 (change layout again to sute the extra text fields. Ready for use but still looks ugly.)

    *v0.6.2 (Fixed stupid Int problem... don't ask. This version was handed in for marking.)

    * The version above is the current v1.0rc1 version, however I feel that the

    *program is just too ugly for that title


    import javax.swing.*;

    import java.math.*;

    public class Age


    public static void main(String[] args)


    MainFrame frame = new MainFrame();

    frame.addWindowListener(new WindowAdapter()


    public void windowClosing(WindowEvent e)







    class MainFrame extends JFrame implements ActionListener


    private JTextField firstName;

    private JTextField lastName;

    private JTextField nAge;

    private JTextField fullNameResult;

    private JTextField fullAge;

    private JTextField monthAge;

    private JTextField weekAge;

    private JTextField hourAge;

    private JTextField minAge;

    private JTextField secAge;

    public MainFrame ()


    super("Your Age");

    JPanel pane = (JPanel) getContentPane();

    pane.setLayout(new BorderLayout());

    firstName = new JTextField(6);

    lastName = new JTextField(6);

    nAge = new JTextField(6);

    fullNameResult = new JTextField(6);

    fullAge = new JTextField(6);

    monthAge = new JTextField(6);

    weekAge = new JTextField(6);

    hourAge = new JTextField(6);

    minAge = new JTextField(6);

    secAge = new JTextField(6);








    JPanel inFieldPane = new JPanel();

    inFieldPane.setLayout(new GridLayout(3,2));

    inFieldPane.add(new JLabel("First Name:"));


    inFieldPane.add(new JLabel("Last Name:"));


    inFieldPane.add(new JLabel("Age:"));




    JPanel okPane = new JPanel();

    okPane.setLayout(new FlowLayout());

    okPane.add(new JLabel("Press OK when information is entered correctly"));

    JButton okButton = new JButton("OK");




    JPanel outFieldPane = new JPanel();

    outFieldPane.setLayout(new GridLayout(7,2));

    outFieldPane.add(new JLabel("Your full name is:"));


    outFieldPane.add(new JLabel("Your age is:"));


    outFieldPane.add(new JLabel("Your age in months:"));


    outFieldPane.add(new JLabel("Your age in weeks:"));


    outFieldPane.add(new JLabel("Your age in hours:"));


    outFieldPane.add(new JLabel("Your age in minutes:"));


    outFieldPane.add(new JLabel("Your age in seconds:"));






    public void actionPerformed (ActionEvent e)


    if (e.getActionCommand().equals("OK"))


    String fullString = firstName.getText().trim() + " " + lastName.getText().trim();

    int inValue = Integer.parseInt(nAge.getText().trim());



    monthAge.setText(String.valueOf(inValue * 12));

    weekAge.setText(String.valueOf(inValue * 52));

    hourAge.setText(String.valueOf(inValue * 4380));

    minAge.setText(String.valueOf(inValue * 262800));

    secAge.setText(String.valueOf(inValue * 15768000));




  • Reply 5 of 11
    A couple things, i think you should have import java.awt.event.*;

    Also your program comes out with 8 errors: cannot resolve symbol

    symbol : class BorderLayout cannot resolve symbol

    symbol : class GridLayout cannot resolve symbol

    symbol : variable BorderLayout cannot resolve symbol

    symbol : class FlowLayout cannot resolve symbol

    symbol : variable BorderLayout cannot resolve symbol

    symbol : class GridLayout cannot resolve symbol

    symbol : variable BorderLayout
  • Reply 6 of 11

    I can compile it fine on my end.
  • Reply 7 of 11


    import java.awt.*;

    I cut it out thinking it was not needed...

    However that code compiles and runs on my computer just fine so I am still confused.
  • Reply 8 of 11
    I got it to work, quite em impresive lol.

    Have you been able to do more than that in java or is that as far as u can go?
  • Reply 9 of 11

    This was just the first GUI based program I wrote last year in the highschool java (computer science) class I took. After that I have written many more. Now I use it as an example of basic GUI work in java. While I am not an expert, I can do much more then this.

    I am interested in hearing about your program.
  • Reply 10 of 11
    Yeah do u have ichat? Whats ur aim or .mac sn?

    That why i can chat with u.
  • Reply 11 of 11
    sorry no dice...

    I don't use aim, infact I have only had bad times with it.

    I use MSN, if you have it.

    Or my email is in one of the above posts.

    You make it seem super top secret...
Sign In or Register to comment.