
**I have two classes. class 1:** public class askfigures extends JFrame {
method from class1: public void button4ActionPerformed(ActionEvent e) {String n1 = textField1.getText(); int number = Integer.parseInt(n1); System.out.println("dsf") this.dispose(); Askvalues values = new Askvalues(); values.initComponents();
I want to use the variable number in another class.
another class: public class Askvalues extends JFrame {
in the method: private void button4ActionPerformed(ActionEvent e){

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class AskFigures{
AskFigures(){
JLabel lab=new JLabel("Enter Number: ");
final JTextField text=new JTextField();
JButton b=new JButton("Get");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String value=text.getText();
int num=Integer.parseInt(value);
AskValues v=new AskValues(num);
}
});
JFrame f=new JFrame();
JPanel p=new JPanel(new GridLayout(2,2));
p.add(lab);
p.add(text);
p.add(b);
f.add(p);
f.setVisible(true);
f.pack();
}
public static void main(String[] args)
{
new AskFigures();
}
}
class AskValues{
AskValues(int number){
JLabel lab=new JLabel();
lab.setText(Integer.toString(number));
lab.setBounds(10,10,100,20);
JFrame frame=new JFrame();
frame.setLayout(null);
frame.add(lab);
frame.setSize(100,60);
frame.setVisible(true);
}
}

Eres un genio!!! You're a genious. thankyou so much!!! I get it now,
the class that send the variable I should create an object to send it. and the receiving it I have to get through the method with it's type "eg.(int)"
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.