
import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField;
import javax.swing.SwingUtilities; import java.awt.*; import java.awt.event.*;
import javax.swing.*; import javax.swing.border.*; import java.io.FileReader;
public class gui extends JApplet {
{
final JTextPane pane = new JTextPane();
JFrame frame = new JFrame("filedemo");
frame.setVisible(true);
frame.setSize(200,200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Enter the filename with file path:");
JLabel label2= new JLabel("Press the button");
JPanel panel = new JPanel();
frame.add(panel);
panel.add(label);
panel.add(label2);
JButton b1 = new JButton("file1");
panel.add(b1);
JButton b2 = new JButton("file2");
panel.add(b2);
JButton b3 = new JButton("Quit");
panel.add(b3);
JLabel label1= new JLabel("Supervisor");
panel.add(label1);
JLabel label3= new JLabel("Student");
panel.add(label3);
// button to insert an icon
final ImageIcon icon11 = new ImageIcon("bluepaw.gif");
JButton iconButton1 = new JButton(icon11);
iconButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
pane.insertIcon(icon11);
}
});
}
}
hi friend,i am using eclipse software.my question is :how to write filepath for JButton.and also how to open that filepath .Thanking in advance.bala
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.