Hi all, I'm trying to write code so that when a button is clicked, a JColorChooser pops up. For some reason, the code I wrote i snot working and I can't figure out the reason. Any help would be greatly appreciated thanks.
[CODE]
private static JButton changeColorButt on = new JButton("Change Color");
private static JButton loadButton = new JButton("Open") ;
public void actionPerformed (ActionEvent ae) {
String command = ae.getActionCom mand();
if (command == "Open") {
JFileChooser chooser = new JFileChooser();
chooser.showOpe nDialog(loadBut ton);
file = chooser.getSele ctedFile();
loadPic(file);
repaint();
}
else if (command == "Change Color") {
JColorChooser colors = new JColorChooser() ;
colors.setPrevi ewPanel(changeC olorButton);
}
}
[\CODE]
[CODE]
private static JButton changeColorButt on = new JButton("Change Color");
private static JButton loadButton = new JButton("Open") ;
public void actionPerformed (ActionEvent ae) {
String command = ae.getActionCom mand();
if (command == "Open") {
JFileChooser chooser = new JFileChooser();
chooser.showOpe nDialog(loadBut ton);
file = chooser.getSele ctedFile();
loadPic(file);
repaint();
}
else if (command == "Change Color") {
JColorChooser colors = new JColorChooser() ;
colors.setPrevi ewPanel(changeC olorButton);
}
}
[\CODE]
Comment