Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ROFOMS {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- FormMain frm = new FormMain();
- frm.setVisible(true);
- }
- }
- /*==========================================================================*/
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.filechooser.*;
- public class FormMain extends JFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private JTextField xlsTextField = new JTextField(35);
- private JTextField dbfTextField = new JTextField(35);
- private JButton xlsButton = new JButton("XLS");
- private JButton dbfButton = new JButton("DBF");
- private JButton runButton = new JButton("Порезать!");
- private JProgressBar progressBar = new JProgressBar();
- public FormMain() {
- initForm();
- initListeners();
- }
- private void initForm() {
- this.setSize(500, 170);
- this.setTitle("РОФОМС 2011");
- Container p = this.getContentPane();
- GridBagLayout gbl = new GridBagLayout();
- GridBagConstraints gbc = new GridBagConstraints();
- p.setLayout(gbl);
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.insets.bottom = 10;
- gbc.insets.right = 5;
- p.add(xlsTextField, gbc);
- gbc.gridx = 1;
- p.add(xlsButton, gbc);
- gbc.gridx = 0;
- gbc.gridy = 1;
- p.add(dbfTextField, gbc);
- gbc.gridx = 1;
- p.add(dbfButton, gbc);
- gbc.gridx = 0;
- gbc.gridy = 2;
- gbc.gridwidth = 2;
- gbc.fill = GridBagConstraints.NONE;
- p.add(runButton, gbc);
- gbc.gridx = 0;
- gbc.gridy = 3;
- gbc.gridwidth = 2;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- p.add(progressBar, gbc);
- }
- private void initListeners() {
- xlsButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- choose_file("Книга Excel (*.xls)","xls", xlsTextField);}});
- dbfButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- choose_file("Файл dBase (*.dbf)","dbf", dbfTextField);}});
- runButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- execute();}});
- }
- private void choose_file(String title, String type, JTextField textField) {
- JFileChooser fc = new JFileChooser();
- FileNameExtensionFilter filter =
- new FileNameExtensionFilter(title,type);
- fc.setFileFilter(filter);
- int retVal = fc.showOpenDialog(this);
- if (retVal == JFileChooser.APPROVE_OPTION) {
- textField.setText(fc.getSelectedFile().getAbsolutePath());
- }
- }
- private void execute() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement