Need some logic help - someone with a fresh brain!
Ok i have a problem where i need to get an x/y coordinate from the user...
it is used when the user pastes an image into my program (they choose the point where they want the image to start from).
when the user presses ctrl v this method is called:
publicstatic Point getCords()
{
String title ="Set Co-ordinates of pasted image";
final JInternalFrame frame =new JInternalFrame(title, false, true, false,true);
JPanel container =new JPanel();
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
//create Jpanels which will contain components
JPanel panel =new JPanel();
panel.setLayout(new BorderLayout());
JPanel panel2 =new JPanel();
panel2.setLayout(new BorderLayout());
//create labels
JLabel width =new JLabel("X - Coordinate: ");
JLabel height =new JLabel ("Y - Coordinate: ");
//create text fields
final JTextField enterX =new JTextField(10);
final JTextField enterY =new JTextField(10);
enterX.setBorder(new LineBorder(Color.black, 1,true));
enterY.setBorder(new LineBorder(Color.black, 1,true));
//position components in jpanels
panel.add(width, BorderLayout.WEST);
panel.add(enterX, BorderLayout.EAST);
panel2.add(height, BorderLayout.WEST);
panel2.add(enterY, BorderLayout.EAST);
//create button to add
JButton okButton =new JButton("Ok");
okButton.addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent e)
{
int x, y;
try
{
x = Integer.parseInt(enterX.getText());
y = Integer.parseInt(enterY.getText());
}
catch(Exception egger)
{
JOptionPane.showMessageDialog(null,"Coordinates must be integers");
return;
}
setP(x, y);
}
});
container.add(panel);
container.add(panel2);
frame.getContentPane().add(container);
frame.setVisible(true);
frame.setSize(100, 100);
desktop.add(frame, JDesktopPane.POPUP_LAYER);
return p;
}
most of that is GUI, just setting up a JInternalFrame which displays two labels, two textFields and an ok button. when the user clicks the ok button, a point is made from the two coordinates entered.
at the moment though the point ("p") is being returned straight away without it letting me fill in the form, i know why but i dont know how i can get it to wait for me to fill in the form first.
please help me, thanks

