import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class OpenPdf extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
OpenPdf frame = new OpenPdf();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public OpenPdf() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 636, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JButton btnOpenPdf = new JButton("Open Pdf");
btnOpenPdf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
Desktop.getDesktop().open(new java.io.File("File/sc.pdf"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
});
btnOpenPdf.setBounds(35, 31, 108, 23);
contentPane.add(btnOpenPdf);
JButton btnOpenText = new JButton("Open Text");
btnOpenText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
Desktop.getDesktop().open(new java.io.File("File/scp.txt"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
});
btnOpenText.setBounds(197, 31, 89, 23);
contentPane.add(btnOpenText);
}
}
import java.awt.Desktop;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class OpenPdf extends JFrame {
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
OpenPdf frame = new OpenPdf();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public OpenPdf() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 636, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JButton btnOpenPdf = new JButton("Open Pdf");
btnOpenPdf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
Desktop.getDesktop().open(new java.io.File("File/sc.pdf"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
});
btnOpenPdf.setBounds(35, 31, 108, 23);
contentPane.add(btnOpenPdf);
JButton btnOpenText = new JButton("Open Text");
btnOpenText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
Desktop.getDesktop().open(new java.io.File("File/scp.txt"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
});
btnOpenText.setBounds(197, 31, 89, 23);
contentPane.add(btnOpenText);
}
}
No comments:
Post a Comment