• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

traversing between frames

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hii...
i need to traverse between the frames in java swings.i am able to go to the second frame from the first one but unable to go to the third frame from second frame..please help..urgent...!!!

code fro first frame:
/*
* first_1.java
*
* Created on April 6, 2010, 1:34 AM
*/

package first;

import javax.swing.JFrame;

/**
*
* @author Amrit Raj
*/
public class first_1 extends javax.swing.JFrame {

/** Creates new form first_1 */
public first_1() {
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() {

buttonGroup1 = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 204));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

jLabel1.setFont(new java.awt.Font("Bradley Hand ITC", 1, 15)); // NOI18N
jLabel1.setForeground(new java.awt.Color(204, 0, 0));
jLabel1.setText("N WAY COMBINATORIAL TEST CASE GENERATOR");

buttonGroup1.add(jRadioButton1);
jRadioButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jRadioButton1.setForeground(new java.awt.Color(0, 51, 255));
jRadioButton1.setText("FILE TO READ");
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});

buttonGroup1.add(jRadioButton2);
jRadioButton2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jRadioButton2.setForeground(new java.awt.Color(0, 0, 255));
jRadioButton2.setText("INPUT FROM THE USER");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 0, 255));
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(109, 109, 109)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jRadioButton1)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jButton1)
.add(jRadioButton2)))
.addContainerGap(215, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(42, 42, 42)
.add(jLabel1)
.addContainerGap(48, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.add(11, 11, 11)
.add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(55, 55, 55)
.add(jRadioButton1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(jRadioButton2)
.add(48, 48, 48)
.add(jButton1)
.addContainerGap(72, Short.MAX_VALUE))
);

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

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

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JFrame framex=first.second.getInstance();
framex.setVisible(true);

//JFrame framey=first.third.getInstance();
//framey.setVisible(true);


// 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 first_1().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JSeparator jSeparator1;
// End of variables declaration

}


code for second frame:

/*
* second.java
*
* Created on April 6, 2010, 2:10 AM
*/

package first;

import javax.swing.JFrame;

/**
*
* @author Amrit Raj
*/
public class second extends javax.swing.JFrame {

private static final second framex = new second();

public static second getInstance() {
return framex;
}

/** Creates new form second */
public second() {
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() {

buttonGroup1 = new javax.swing.ButtonGroup();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Bradley Hand ITC", 1, 15)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 0, 0));
jLabel1.setText("PARAMETER ENRTY SPACE");

jRadioButton1.setBackground(new java.awt.Color(255, 255, 51));
buttonGroup1.add(jRadioButton1);
jRadioButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jRadioButton1.setForeground(new java.awt.Color(0, 0, 153));
jRadioButton1.setText("YES");

jRadioButton2.setBackground(new java.awt.Color(255, 255, 0));
buttonGroup1.add(jRadioButton2);
jRadioButton2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jRadioButton2.setForeground(new java.awt.Color(0, 0, 153));
jRadioButton2.setText("NO");

jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 0, 255));
jLabel2.setText("INPUT FROM THE USER");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0, 0, 255));
jLabel3.setText("CONSTRAINTS");

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 532, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.add(175, 175, 175)
.add(jLabel1))
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(18, 18, 18)
.add(jLabel2))
.add(layout.createSequentialGroup()
.add(55, 55, 55)
.add(jLabel3)))
.add(24, 24, 24)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(jRadioButton1)
.add(45, 45, 45)
.add(jRadioButton2))
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 239, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(28, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(254, Short.MAX_VALUE)
.add(jButton1)
.add(245, 245, 245))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.add(11, 11, 11)
.add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel2)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 96, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(24, 24, 24)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jRadioButton2)
.add(jRadioButton1)
.add(jLabel3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 46, Short.MAX_VALUE)
.add(jButton1)
.add(29, 29, 29))
);

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

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
JFrame framey=first.third.getInstance();
framey.setVisible(true);

// 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 second().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField jTextField1;
// End of variables declaration

}


code for third frame:

/*
* third.java
*
* Created on April 6, 2010, 2:25 AM
*/

package first;

/**
*
* @author Amrit Raj
*/
public class third extends javax.swing.JFrame {

private static final third framey = new third();

public static third getInstance() {
return framey;
}

/** Creates new form third */
public third() {
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() {

jLabel1 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("Bradley Hand ITC", 1, 15)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 0, 0));
jLabel1.setText("CONSTRAINT HANDLER");

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(0, 0, 255));
jLabel2.setText("CONSTRAINTS TO BE GIVEN");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0, 0, 255));
jLabel3.setText("COVERAGE");

jComboBox1.setBackground(new java.awt.Color(255, 204, 0));
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2", "3", "4" }));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 0, 204));
jButton1.setText("SUBMIT");

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(64, 64, 64)
.add(jLabel2)
.add(18, 18, 18)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 193, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(126, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(87, 87, 87)
.add(jLabel3)
.add(44, 44, 44)
.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(304, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(276, Short.MAX_VALUE)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 113, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(177, 177, 177))
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(193, Short.MAX_VALUE)
.add(jLabel1)
.add(184, 184, 184))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel1)
.add(18, 18, 18)
.add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 44, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(68, 68, 68)
.add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(247, 247, 247))
);

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

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

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextField jTextField1;
// End of variables declaration

}

anyone please help me...how to resolve this problem...
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "travserse between the frames" as this is kind of fuzzy to me? What precisely are you trying to do?

Some suggestions:
1) simplify the problem as much as possible so that you don't have to worry about extra code getting in your way, and so if you post your code, we don't have to plow through miles of code most of it unrelated to your problem.
2) ditch the NetBeans code generation and learn to code Swing yourself. The Sun tutorials will explain how, and if you do this, it will help you when / if you go back to using NetBeans to generate code as you'll understand what you are doing.
3) Use code tags when posting code. The FAQs will show you the way.
4) Provide more detail about the problem and not so much your proposed solution. Perhaps multiple JFrames are not the answer here.
5) Avoid using "urgent' in your posts. No one likes to feel pushed or rushed, especially volunteers who might help you. Again, the FAQs have something to say about this.

Best of luck and much success!
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
worked OK for me.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic