Java Swing- Metal Buttons?
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?
thanks
thanks
Comments
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).
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.
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),
jonwickes(at)yahoo(dot)com
But I don't know how much help I can be.
/* 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)
{
System.exit(0);
}
}
);}
}
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);
fullNameResult.setEditable(false);
fullAge.setEditable(false);
monthAge.setEditable(false);
weekAge.setEditable(false);
hourAge.setEditable(false);
minAge.setEditable(false);
secAge.setEditable(false);
JPanel inFieldPane = new JPanel();
inFieldPane.setLayout(new GridLayout(3,2));
inFieldPane.add(new JLabel("First Name:"));
inFieldPane.add(firstName);
inFieldPane.add(new JLabel("Last Name:"));
inFieldPane.add(lastName);
inFieldPane.add(new JLabel("Age:"));
inFieldPane.add(nAge);
nAge.addActionListener(this);
pane.add(inFieldPane,BorderLayout.NORTH);
JPanel okPane = new JPanel();
okPane.setLayout(new FlowLayout());
okPane.add(new JLabel("Press OK when information is entered correctly"));
JButton okButton = new JButton("OK");
okButton.addActionListener(this);
okPane.add(okButton);
pane.add(okPane,BorderLayout.CENTER);
JPanel outFieldPane = new JPanel();
outFieldPane.setLayout(new GridLayout(7,2));
outFieldPane.add(new JLabel("Your full name is:"));
outFieldPane.add(fullNameResult);
outFieldPane.add(new JLabel("Your age is:"));
outFieldPane.add(fullAge);
outFieldPane.add(new JLabel("Your age in months:"));
outFieldPane.add(monthAge);
outFieldPane.add(new JLabel("Your age in weeks:"));
outFieldPane.add(weekAge);
outFieldPane.add(new JLabel("Your age in hours:"));
outFieldPane.add(hourAge);
outFieldPane.add(new JLabel("Your age in minutes:"));
outFieldPane.add(minAge);
outFieldPane.add(new JLabel("Your age in seconds:"));
outFieldPane.add(secAge);
pane.add(outFieldPane,BorderLayout.SOUTH);
pack();
setVisible(true);
}
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());
fullNameResult.setText(fullString);
fullAge.setText(String.valueOf(inValue));
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));
}
}
}
Also your program comes out with 8 errors:
age.java:36: cannot resolve symbol
symbol : class BorderLayout
age.java:56: cannot resolve symbol
symbol : class GridLayout
age.java:64: cannot resolve symbol
symbol : variable BorderLayout
age.java:67: cannot resolve symbol
symbol : class FlowLayout
age.java:72: cannot resolve symbol
symbol : variable BorderLayout
age.java:75: cannot resolve symbol
symbol : class GridLayout
age.java:91: cannot resolve symbol
symbol : variable BorderLayout
I can compile it fine on my end.
add.
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.
Have you been able to do more than that in java or is that as far as u can go?
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.
That why i can chat with u.
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...