Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a Java Expert!

Join 307,221 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,683 people online right now. Registration is fast and FREE... Join Now!




How to I store and retrieve data for pop up windows in Java?

 

How to I store and retrieve data for pop up windows in Java?, Store and retrieve data for pop up windows in Java?

bizzorg

5 Aug, 2008 - 12:48 PM
Post #1

New D.I.C Head
*

Joined: 5 Aug, 2008
Posts: 1

CODE
/*
* MortgageFrameCombo2.java
*
* Created on July 29, 2008, 8:38 PM
*/

import java.text.NumberFormat;
import java.text.DecimalFormat;



/**
*
* @author  bizzorg
*/
public class MortgageFrameCombo2 extends javax.swing.JFrame {

    /** Creates new form MortgageFrameCombo2 */
    public MortgageFrameCombo2() {
        initComponents();
    }

    /** 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">                          
    private void initComponents() {

        principalLabel = new javax.swing.JLabel();
        termLabel = new javax.swing.JLabel();
        InterestLabel = new javax.swing.JLabel();
        mortgagePrincipalTextField = new javax.swing.JTextField();
        termComboBox = new javax.swing.JComboBox();
        interestComboBox = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        paymentValueField = new javax.swing.JTextField();
        paymentLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        principalLabel.setText("Principal");

        termLabel.setText("Term");

        InterestLabel.setText("Interest");

        termComboBox.setEditable(true);
        termComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "360", "300", "240" }));

        interestComboBox.setEditable(true);
        interestComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "5.5", "5.75", "6" }));
        interestComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                interestComboBoxActionPerformed(evt);
            }
        });

        jButton1.setText("Calculate");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        paymentLabel.setText("Payment");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(termComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(termLabel)
                            .addComponent(principalLabel))
                        .addGap(73, 73, 73)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(InterestLabel)
                            .addComponent(interestComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(mortgagePrincipalTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(143, 143, 143)
                        .addComponent(jButton1)))
                .addContainerGap(69, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(90, Short.MAX_VALUE)
                .addComponent(paymentLabel)
                .addGap(62, 62, 62)
                .addComponent(paymentValueField, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(80, 80, 80))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(principalLabel)
                    .addComponent(mortgagePrincipalTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(termLabel)
                    .addComponent(InterestLabel))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(termComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(interestComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(64, 64, 64)
                .addComponent(jButton1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(paymentLabel)
                    .addComponent(paymentValueField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(57, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {                                      
MortgageCalculator mc = new MortgageCalculator();
    String prin = mortgagePrincipalTextField.getText();
    String inter = "0.0";
    String ter = "0";
    ter = (String)termComboBox.getSelectedItem();
    inter = (String)interestComboBox.getSelectedItem();
    mc.setLoanValue(prin, inter, ter);
    double pay = mc.getInterestPayment() + mc.getPrincipalPayment();
    NumberFormat formatter = new DecimalFormat("$#,##0.00");
    String s = formatter.format(pay);
    paymentValueField.setText(s);
    MortgagePopUp p = new MortgagePopUp();
    Thread t = new Thread(p);
    t.start();

}                                    

private void interestComboBoxActionPerformed(java.awt.event.ActionEvent evt) {                                                
// TODO add your handling code here:
}                                                

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MortgageFrameCombo2().setVisible(true);
            }
        });
    }
            
private void mortgagePrincipalTextFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                          
// TODO add your handling code here:
    
}                                                          


    


    // Variables declaration - do not modify                    
    private javax.swing.JLabel InterestLabel;
    private javax.swing.JComboBox interestComboBox;
    private javax.swing.JButton jButton1;
    private javax.swing.JTextField mortgagePrincipalTextField;
    private javax.swing.JLabel paymentLabel;
    private javax.swing.JTextField paymentValueField;
    private javax.swing.JLabel principalLabel;
    private javax.swing.JComboBox termComboBox;
    private javax.swing.JLabel termLabel;
    // End of variables declaration                  
}


Here's the pop up code...
/*
* MortgagePopUp.java
*
* Created on July 29, 2008, 8:39 PM
*/



/**
*
* @author  bizzorg
*/
public class MortgagePopUp extends javax.swing.JFrame implements Runnable{

    /** Creates new form MortgagePopUp */
    public MortgagePopUp() {
        initComponents();
    }

    /** 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">                          
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        popupTextArea = new javax.swing.JTextArea();
        popupButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        popupTextArea.setColumns(20);
        popupTextArea.setRows(5);
        jScrollPane1.setViewportView(popupTextArea);

        popupButton.setText("Exit");
        popupButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                popupButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(43, 43, 43)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(150, 150, 150)
                        .addComponent(popupButton)))
                .addContainerGap(68, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addComponent(popupButton)
                .addGap(23, 23, 23))
        );

        pack();
    }// </editor-fold>                        

private void popupButtonMouseClicked(java.awt.event.MouseEvent evt) {                                        
// TODO add your handling code here:
    dispose();
}                                        

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MortgagePopUp().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                    
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton popupButton;
    private javax.swing.JTextArea popupTextArea;
    // End of variables declaration                  

    public void run() {
        setVisible(true);
    }

}


User is offlineProfile CardPM
+Quote Post


lordms12

RE: How To I Store And Retrieve Data For Pop Up Windows In Java?

6 Aug, 2008 - 11:19 AM
Post #2

D.I.C Regular
Group Icon

Joined: 16 Feb, 2008
Posts: 335



Thanked: 26 times
Dream Kudos: 250
My Contributions
What do you mean?
User is offlineProfile CardPM
+Quote Post

pbl

RE: How To I Store And Retrieve Data For Pop Up Windows In Java?

6 Aug, 2008 - 05:13 PM
Post #3

Java Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 9,968



Thanked: 1188 times
Dream Kudos: 450
My Contributions
OK this is NOT a pop up window
A pop up window is somenthing from the JOptionPane class
Here you wrote (or your teacher wrote) his/your own class named MortgagePopUp

You have to have a method that will retreive the text (getText()) from the JTextField in that class
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:38PM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month