I want to use a variable inside and outside my class

Simply I have the application below, and I want from another application to check the value of the integer (action). how can I do this without doing this :

Properties prop =new Properties();

which opens the frame and this is what i dont want to do.

// Here Is my program

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

publicclass Propertiesextends JFrame

{

private JRadioButton adfButton, normalButton, hiddenButton;

private ButtonGroup radioGroup;

publicint action;

// GUI

public Properties()

{

super ("Properties");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container container = getContentPane();

container.setLayout(new FlowLayout() );

JLabel message =new JLabel("Choose a way for scanning : \n");

container.add(message);

adfButton =new JRadioButton("\nADF scanning",true );

container.add( adfButton);

normalButton =new JRadioButton("Normal scanning",false );

container.add( normalButton );

hiddenButton =new JRadioButton("Hidden Interface scanning",false);

container.add( hiddenButton );

getAction handler =new getAction();

adfButton.addItemListener( handler );

normalButton.addItemListener( handler );

hiddenButton.addItemListener( handler );

radioGroup =new ButtonGroup();

radioGroup.add( adfButton );

radioGroup.add( normalButton );

radioGroup.add( hiddenButton );

setSize( 300, 200 );

setVisible(true );

}// end constructor

publicclass getActionimplements ItemListener

{

publicvoid itemStateChanged( ItemEvent event )

{

if (event.getSource()==adfButton)

action = 1;

elseif ( event.getSource()== normalButton )

action = 2;

elseif ( event.getSource()== hiddenButton )

action = 3;

}

}

publicstaticvoid main( String args[] )

{

Properties application =new Properties();

application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

}

}

[3861 byte] By [tleis1a] at [2007-9-30 23:42:30]
# 1

I don't understand completely. You can not set the value of 'action' without creating a Properties object and have the user select an item. This requires that somewhere you have a "new Properties()" statement.

Perhaps you need to write the action or the Properties object to a file, then read it back in later?

atmguya at 2007-7-7 14:56:39 > top of Java-index,Administration Tools,Sun Connection...
# 2

Remove the call to setVisible in the constructor. Then expose that method with your own method, such as:

final public void show() {

super.setVisible(true);

}

- Saish

"Shamadoo!" - B. Madison

Saisha at 2007-7-7 14:56:39 > top of Java-index,Administration Tools,Sun Connection...