user6737469 user6737469 - 1 month ago 10
Java Question

Click JButton and open a file.java

I have a jComoBox and JButton NewJDialog.java. How to pen A.java when i select "A" in JComboBox?

if (jComboBox1.getSelectedItem() == "A"){
A.java.setVisible(true);
}
else {
dispose();
}
}

Answer

If you are trying to open a file you could use a Desktop Object like so.

Desktop d = Desktop.getDesktop();
d.open("your File object here");