package int_test;

import java.io.*;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import java.awt.Color;
import java.awt.Dialog;
import java.util.Vector;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

public class Main_forma extends FrameView {

    public int stan=0;

    public double granica_dol;
    public double granica_gora;
    public double krok;

    // metoda siecznych
    public int ile_krokow;
    public double EPSX; 
   
    public String rownanie;
    public Watek pasek;

    public Vector<String> wyniki_vektor=new Vector<String>();
    public Vector<String> historia_vektor=new Vector<String>();
    public Main_forma(SingleFrameApplication app) {
       super(app);

       initComponents();
       this.edEPSX.hide();
       this.jLabel4.hide();

       pasek= new Watek(this.progressBar);
       Thread w2 =new Thread(pasek);
       w2.setName("watek");
       w2.start();
       this.progressBar.setVisible(false);
       JFrame mainFrame=this.getFrame();
       mainFrame.setResizable(false);
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = main.getApplication().getMainFrame();
            aboutBox = new About_box(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        main.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        mainPanel = new javax.swing.JPanel();
        panel_rownanie = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        panel_metoda = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        panel_dane = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        edit_granica_dol = new javax.swing.JFormattedTextField();
        edit_granica_gora = new javax.swing.JFormattedTextField();
        edit_kroki = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        edEPSX = new javax.swing.JFormattedTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        historia = new javax.swing.JEditorPane();
        jPanel5 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        wyniki = new javax.swing.JEditorPane();
        panel_rownanie1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setMaximumSize(new java.awt.Dimension(0, 0));
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(700, 350));
        mainPanel.setRequestFocusEnabled(false);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(int_test.main.class).getContext().getResourceMap(Main_forma.class);
        panel_rownanie.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("panel_rownanie.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("panel_rownanie.border.titleFont"))); // NOI18N
        panel_rownanie.setFont(resourceMap.getFont("panel_rownanie.font")); // NOI18N
        panel_rownanie.setMaximumSize(new java.awt.Dimension(0, 0));
        panel_rownanie.setName("panel_rownanie"); // NOI18N

        jTextField1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextField1.setName("jTextField1"); // NOI18N

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jTextField1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        javax.swing.GroupLayout panel_rownanieLayout = new javax.swing.GroupLayout(panel_rownanie);
        panel_rownanie.setLayout(panel_rownanieLayout);
        panel_rownanieLayout.setHorizontalGroup(
            panel_rownanieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_rownanieLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addContainerGap())
        );
        panel_rownanieLayout.setVerticalGroup(
            panel_rownanieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_rownanieLayout.createSequentialGroup()
                .addGroup(panel_rownanieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panel_metoda.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("panel_metoda.border.title"))); // NOI18N
        panel_metoda.setFont(resourceMap.getFont("panel_metoda.font")); // NOI18N
        panel_metoda.setMaximumSize(new java.awt.Dimension(0, 0));
        panel_metoda.setName("panel_metoda"); // NOI18N

        jComboBox1.setFont(resourceMap.getFont("jComboBox1.font")); // NOI18N
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "przeszukiwanie przedziału", "metoda Regula falsi", "metoda Newtona" }));
        jComboBox1.setName("jComboBox1"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jComboBox1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jComboBox1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBox1ItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout panel_metodaLayout = new javax.swing.GroupLayout(panel_metoda);
        panel_metoda.setLayout(panel_metodaLayout);
        panel_metodaLayout.setHorizontalGroup(
            panel_metodaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_metodaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jComboBox1, 0, 181, Short.MAX_VALUE)
                .addContainerGap())
        );
        panel_metodaLayout.setVerticalGroup(
            panel_metodaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_metodaLayout.createSequentialGroup()
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panel_dane.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("panel_dane.border.title"))); // NOI18N
        panel_dane.setToolTipText(resourceMap.getString("panel_dane.toolTipText")); // NOI18N
        panel_dane.setFont(resourceMap.getFont("panel_dane.font")); // NOI18N
        panel_dane.setMaximumSize(new java.awt.Dimension(0, 0));
        panel_dane.setName("panel_dane"); // NOI18N
        panel_dane.setPreferredSize(new java.awt.Dimension(236, 170));

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        edit_granica_dol.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        edit_granica_dol.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###.#########"))));
        edit_granica_dol.setText(resourceMap.getString("gora.text")); // NOI18N
        edit_granica_dol.setName("gora"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), edit_granica_dol, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        edit_granica_gora.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        edit_granica_gora.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###.#########"))));
        edit_granica_gora.setText(resourceMap.getString("dol.text")); // NOI18N
        edit_granica_gora.setName("dol"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), edit_granica_gora, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        edit_kroki.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        edit_kroki.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###.#########"))));
        edit_kroki.setText(resourceMap.getString("krok.text")); // NOI18N
        edit_kroki.setName("krok"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), edit_kroki, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        edEPSX.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        edEPSX.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,###.#########"))));
        edEPSX.setText(resourceMap.getString("edEPSX.text")); // NOI18N
        edEPSX.setMaximumSize(new java.awt.Dimension(0, 0));
        edEPSX.setName("edEPSX"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), edEPSX, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout panel_daneLayout = new javax.swing.GroupLayout(panel_dane);
        panel_dane.setLayout(panel_daneLayout);
        panel_daneLayout.setHorizontalGroup(
            panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_daneLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(edEPSX, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
                    .addComponent(edit_kroki, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
                    .addComponent(edit_granica_gora, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
                    .addComponent(edit_granica_dol, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
                .addContainerGap())
        );
        panel_daneLayout.setVerticalGroup(
            panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_daneLayout.createSequentialGroup()
                .addGroup(panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(edit_granica_dol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(edit_granica_gora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(edit_kroki, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panel_daneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(edEPSX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(45, Short.MAX_VALUE))
        );

        jTabbedPane1.setFont(resourceMap.getFont("jTabbedPane1.font")); // NOI18N
        jTabbedPane1.setMaximumSize(new java.awt.Dimension(0, 0));
        jTabbedPane1.setMinimumSize(new java.awt.Dimension(0, 0));
        jTabbedPane1.setName("jTabbedPane1"); // NOI18N
        jTabbedPane1.setPreferredSize(new java.awt.Dimension(400, 400));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jTabbedPane1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        jPanel4.setMaximumSize(new java.awt.Dimension(0, 0));
        jPanel4.setMinimumSize(new java.awt.Dimension(500, 32767));
        jPanel4.setName("jPanel4"); // NOI18N

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jButton3, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        historia.setContentType(resourceMap.getString("historia.contentType")); // NOI18N
        historia.setEditable(false);
        historia.setName("historia"); // NOI18N
        jScrollPane1.setViewportView(historia);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
                    .addComponent(jButton3))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N

        jPanel5.setMaximumSize(new java.awt.Dimension(0, 0));
        jPanel5.setName("jPanel5"); // NOI18N

        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jButton4, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        wyniki.setContentType(resourceMap.getString("wyniki.contentType")); // NOI18N
        wyniki.setEditable(false);
        wyniki.setName("wyniki"); // NOI18N
        jScrollPane2.setViewportView(wyniki);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
                    .addComponent(jButton4))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel5.TabConstraints.tabTitle"), jPanel5); // NOI18N

        panel_rownanie1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        panel_rownanie1.setMaximumSize(new java.awt.Dimension(0, 0));
        panel_rownanie1.setName("panel_rownanie1"); // NOI18N

        jButton1.setFont(resourceMap.getFont("jButton1.font")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(resourceMap.getFont("jButton2.font")); // NOI18N
        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, mainPanel, org.jdesktop.beansbinding.ELProperty.create("${enabled}"), jButton2, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panel_rownanie1Layout = new javax.swing.GroupLayout(panel_rownanie1);
        panel_rownanie1.setLayout(panel_rownanie1Layout);
        panel_rownanie1Layout.setHorizontalGroup(
            panel_rownanie1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_rownanie1Layout.createSequentialGroup()
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton2)
                .addContainerGap(53, Short.MAX_VALUE))
        );
        panel_rownanie1Layout.setVerticalGroup(
            panel_rownanie1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_rownanie1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1)
                .addComponent(jButton2))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panel_rownanie1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_dane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                    .addComponent(panel_rownanie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_metoda, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 461, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(panel_rownanie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panel_metoda, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panel_dane, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panel_rownanie1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(29, 29, 29))
        );

        jTabbedPane1.getAccessibleContext().setAccessibleName(resourceMap.getString("jTabbedPane1.AccessibleContext.accessibleName")); // NOI18N

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setFont(resourceMap.getFont("fileMenu.font")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(int_test.main.class).getContext().getActionMap(Main_forma.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setFont(resourceMap.getFont("exitMenuItem.font")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setToolTipText(resourceMap.getString("exitMenuItem.toolTipText")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setFont(resourceMap.getFont("helpMenu.font")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setFont(resourceMap.getFont("aboutMenuItem.font")); // NOI18N
        aboutMenuItem.setText(resourceMap.getString("aboutMenuItem.text")); // NOI18N
        aboutMenuItem.setToolTipText(resourceMap.getString("aboutMenuItem.toolTipText")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N
        statusPanel.setPreferredSize(new java.awt.Dimension(670, 27));

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        progressBar.setDoubleBuffered(true);
        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addContainerGap(536, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14))
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged
    //this.jTextField1.setText(this.jComboBox1.getSelectedItem().toString());    // TODO add your handling code here:
    stan = this.jComboBox1.getSelectedIndex();

    switch (stan)
                {
                case 0:
                   this.jLabel3.setText("Krok:");
                   this.edit_kroki.setText("");

                   this.edEPSX.hide();
                   this.edEPSX.setText("");
                   this.edEPSX.setVisible(false);
                   this.jLabel4.setVisible(false);

                   this.edit_granica_gora.setVisible(true);
                   this.jLabel2.setVisible(true);
                   this.jLabel1.setText("Granica dolna:");
                   this.panel_dane.repaint();
                break;
                case 1:
                   this.jLabel3.setText("Ilość kroków:");
                   this.edit_kroki.setText("32");

                   this.edEPSX.setVisible(true);
                   this.edEPSX.setText("0,000000001");
                   this.jLabel4.setText("εx");
                   this.jLabel4.setVisible(true);
                   this.edit_granica_gora.setVisible(true);
                   this.jLabel2.setVisible(true);
                   this.jLabel1.setText("Granica dolna:");
                   this.panel_dane.repaint();
                      try {
                        this.edit_kroki.commitEdit();
                        this.edEPSX.commitEdit();
                       }
                       catch (Exception e) {
                         System.out.println(e.getMessage());
                       }
                break;
                case 2:
                   this.jLabel3.setText("Ilość kroków:");
                   this.edit_kroki.setText("32");

                   this.edEPSX.setVisible(true);
                   this.edEPSX.setText("0,000000001");
                   this.jLabel4.setText("εx");
                   this.jLabel4.setVisible(true);

                   this.edit_granica_gora.setVisible(false);
                   this.jLabel2.setVisible(false);
                   this.jLabel1.setText("Punkt startu:");
                   this.panel_dane.repaint();
                   try {
                     this.edit_kroki.commitEdit();
                     this.edEPSX.commitEdit();
                   }
                   catch (Exception e) {
                     System.out.println(e.getMessage());
                   }
                break;
                }
    }//GEN-LAST:event_jComboBox1ItemStateChanged

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Border loweredetched = BorderFactory.createLoweredBevelBorder();
        Border thickBorder = BorderFactory.createLineBorder(Color.red);
        boolean start = true;

        this.rownanie = this.jTextField1.getText();

        if (this.rownanie.length() != 0) {
               this.jTextField1.setBorder(loweredetched);
             } else {
              start = false;
              this.jTextField1.setBorder(thickBorder);
             }

         if (this.edit_granica_dol.getText().length() == 0) {
               this.edit_granica_dol.setBorder(thickBorder);
               start = false;
             } else {
               Number buff_granica_dol = (Number)this.edit_granica_dol.getValue();
               this.granica_dol = buff_granica_dol.doubleValue();
               this.edit_granica_dol.setBorder(loweredetched);
             }
        
         if (this.stan < 2) {
               if (this.edit_granica_gora.getText().length() == 0) {
                 start = false;
                 this.edit_granica_gora.setBorder(thickBorder);
               } else {
                 Number buff_granica_gora = (Number)this.edit_granica_gora.getValue();
                 this.granica_gora = buff_granica_gora.doubleValue();
                 this.edit_granica_gora.setBorder(loweredetched);
               }

              if (this.granica_dol >= this.granica_gora) {
                start = false;
                 this.edit_granica_dol.setBorder(thickBorder);
                 this.edit_granica_gora.setBorder(thickBorder);
               } else {
                 this.edit_granica_dol.setBorder(loweredetched);
                 this.edit_granica_gora.setBorder(loweredetched);
               }
             }
        
             try {
               this.jTextField1.setBorder(loweredetched);
               this.rownanie=this.rownanie.replace(",",".");
               double licz_rownanie = statyczne_metody.licz_rownanie(this.rownanie, this.granica_dol);
               try {
                    Integer.parseInt(this.rownanie);
                    start = false;
                    this.jTextField1.setBorder(thickBorder);
                 } catch(Exception e) { }
                try {
                    Double.parseDouble(this.rownanie);
                    start = false;
                    this.jTextField1.setBorder(thickBorder); 
                 } catch(Exception e) {}
             } catch (Exception ex) {
               double licz_rownanie;
               start = false;
               this.jTextField1.setBorder(thickBorder);
             }

             this.jScrollPane1.setBorder(loweredetched);
             this.jScrollPane2.setBorder(loweredetched);
             
             switch (this.stan){
             case 0:
               if (this.edit_kroki.getText().length() == 0){
                 start = false;
                 this.edit_kroki.setBorder(thickBorder);
               } else {
                 Number buff_krok = (Number)this.edit_kroki.getValue();
                this.krok = buff_krok.doubleValue();
                 this.edit_kroki.setBorder(loweredetched);
               }
               if (!start) break;

               Double wek=statyczne_metody.wektor(this.granica_dol,this.granica_gora);
               Double il_krokow=wek/this.krok;
               final JOptionPane option=new JOptionPane("Program wykona "+il_krokow.intValue()+" kroków, może to chwilę potrwać.\n Chcesz rozpocząć obliczenia?",JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION);
               Object wynik = option.getValue();
               
               if(il_krokow>2000) {
                   Dialog okno =option.createDialog(mainPanel,"Rozpocząć obliczenia ?");
                   okno.show();
                   wynik = option.getValue();
                   } else wynik=0;
              
               if(wynik.hashCode()==0) {
                   Silnik_przeszukiwanie_przedzialu log_silnik = new Silnik_przeszukiwanie_przedzialu();

                   log_silnik.his_v=historia_vektor;    // vektor historia
                   log_silnik.wyn_v=wyniki_vektor;  // vektor wyniki

                   log_silnik.rownanie = this.rownanie;
                   log_silnik.dol    = this.granica_dol;
                   log_silnik.gora   = this.granica_gora;
                   log_silnik.krok   = this.krok;

                   log_silnik.log    = this.historia;
                   log_silnik.wyniki = this.wyniki;
                   
                   log_silnik.panel=this.mainPanel;
                   log_silnik.progres = this.progressBar;
                   
                   try {
                     log_silnik.start();
                   } catch (Exception e) {
                     System.out.print("Init przeszukiwanie:"+e);
                   }
                 
                 }
             break;
             case 1:
               if (!start) break;
               Number buff_ile_krokow = (Number)this.edit_kroki.getValue();
               Number nu_epsx = (Number)this.edEPSX.getValue();

               Silnik_regula_falsi log_silnik2 = new Silnik_regula_falsi();
               log_silnik2.rownanie = this.rownanie;
               log_silnik2.dol = this.granica_dol;
               log_silnik2.gora = this.granica_gora;

               log_silnik2.kroki_ile = buff_ile_krokow.intValue();
               log_silnik2.EPSX = nu_epsx.doubleValue();

               log_silnik2.his_v=historia_vektor;   // vektor historia
               log_silnik2.wyn_v=wyniki_vektor;     // vektor wyniki

               log_silnik2.log = this.historia;  //EditPane - historia
               log_silnik2.wyniki = this.wyniki; //EditPane - wyniki

               log_silnik2.panel=this.mainPanel; // główny panel
               log_silnik2.progres = this.progressBar;
               try {
                 log_silnik2.start();
               } catch (Exception e) {
                 System.out.print("Init Regulafalsi:"+e);
               }
             break;
             case 2:
               if (!start) break;
               Number buff_ile_krokow2 = (Number)this.edit_kroki.getValue();
               Number nu_epsx2 = (Number)this.edEPSX.getValue();

               Silnik_metoda_newtona log_silnik3 = new Silnik_metoda_newtona();
               log_silnik3.rownanie = this.rownanie;
               log_silnik3.start = this.granica_dol;
               log_silnik3.kroki_ile = buff_ile_krokow2.intValue();
               log_silnik3.EPSX = nu_epsx2.doubleValue();

               log_silnik3.his_v=historia_vektor;     // vektor historia
               log_silnik3.wyn_v=wyniki_vektor;       // vektor wyniki

               log_silnik3.log = this.historia;         // komponent swing z dziennikiem obliczen
               log_silnik3.wyniki = this.wyniki;        // komponent swing z wynikami
               log_silnik3.panel=this.mainPanel;        // głowny panel strony
               log_silnik3.progres = this.progressBar;  
               try {
                 log_silnik3.start();
               } catch (Exception e) {
                 System.out.print(e);
               }
            break;
            }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        this.wyniki.setText("<html><head></head><body></body></html>");
        this.historia.setText("<html><head></head><body></body></html>");
         wyniki_vektor.clear();
         historia_vektor.clear();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

       Border loweredetched =  BorderFactory.createLoweredBevelBorder();
       Border thickBorder = BorderFactory.createLineBorder(Color.red);

       if(historia_vektor.size()==0) {
             jScrollPane1.setBorder(thickBorder);
             return;
             } else jScrollPane1.setBorder(loweredetched);
        String wd = System.getProperty("user.dir");
        JFileChooser fc = new JFileChooser(wd);
        File f = new File("dziennik.html");
        fc.setSelectedFile(f);
        int rc = fc.showDialog(null, "Zapisz");

        if (rc == JFileChooser.APPROVE_OPTION)
            {
            File file = fc.getSelectedFile();
            String filename = file.getAbsolutePath();
            try{
                FileWriter fstream = new FileWriter(filename);
                BufferedWriter out = new BufferedWriter(fstream);
                out.write(historia.getText());
                out.close();
             }catch (Exception e){//Catch exception if any
              System.err.println("Error: " + e.getMessage());
                }
            }
        else
           System.out.println("File chooser cancel button clicked");
           return;
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

       Border loweredetched =  BorderFactory.createLoweredBevelBorder();
       Border thickBorder = BorderFactory.createLineBorder(Color.red);
        if(wyniki_vektor.size()==0) {
             jScrollPane2.setBorder(thickBorder);
             return;
             } else jScrollPane2.setBorder(loweredetched);
        String wd = System.getProperty("user.dir");
        JFileChooser fc = new JFileChooser(wd);
        File f = new File("wyniki.html");
        fc.setSelectedFile(f);
        int rc = fc.showDialog(null, "Zapisz");

        if (rc == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            String filename = file.getAbsolutePath();

            try{
            // Create file
                FileWriter fstream = new FileWriter(filename);
                BufferedWriter out = new BufferedWriter(fstream);
                out.write(wyniki.getText());
                out.close();
            }catch (Exception e){//Catch exception if any
              System.err.println("Error: " + e.getMessage());
              }
            }
        else
           System.out.println("File chooser cancel button clicked");
           return;
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
      // TODO add your handling code here:
      // ukrywanie/pokazywanie przyciskow zapisz wyniki/dziennik
      this.jButton3.setEnabled(this.jTabbedPane1.isEnabled());
      this.jButton4.setEnabled(this.jTabbedPane1.isEnabled());
    }//GEN-LAST:event_jTabbedPane1StateChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFormattedTextField edEPSX;
    private javax.swing.JFormattedTextField edit_granica_dol;
    private javax.swing.JFormattedTextField edit_granica_gora;
    private javax.swing.JFormattedTextField edit_kroki;
    private javax.swing.JEditorPane historia;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPanel panel_dane;
    private javax.swing.JPanel panel_metoda;
    private javax.swing.JPanel panel_rownanie;
    private javax.swing.JPanel panel_rownanie1;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JEditorPane wyniki;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    private JDialog aboutBox;
}
