开发者

Java - unable to set dialog modal to enable a backframe while dialog is waiting for input

开发者 https://www.devze.com 2023-04-10 05:42 出处:网络
for(int i=0;i<index_imageList.getModel().getSize();i++) { //displaying the image viewer ImageZoomerFrame imageZoomer = new ImageZoomerFrame(image, zoom_percentage, imagePath);
  for(int i=0;i<index_imageList.getModel().getSize();i++)
   {

   //displaying the image viewer 
   ImageZoomerFrame imageZoomer = new ImageZoomerFrame(image, zoom_percentage, imagePath);
   imageZoomer.setSize(Toolkit.getDefaultToolkit().getScreenSize());
   imageZoomer.validate();

   //creating JOptionPane with Input Method

   JOptionPane pane = new JOptionPane();
   pane.setMessage("Please Enter Data To Index");
   pane.setWantsInput(true);



   // Pachking pane with dialog
   JDialog dialog= pane.createDialog(this, "Index");
   dialog.pack();
   dialog.setAlwaysOnTop(true);
   dialog.setVisible(true); 

    //wait for the input
   index=pane.getInputValue().toString();

    //dispose image viewer
   imageZoomer.dispose();
  }

In this Java code after the JOptionPane InputDialog show I cannot control the imageviewer frame and if I add a dialog.setModal(false); then it doesnt wait for 开发者_运维百科input and the forloop just continue.

What I exactly need is to be able to control the imageviewer frame as to zoom in or out and at same time make the program wait for user input to continue.


Use a (non-modal) JDialog with an input box, an OK (and Cancel) button, add an action handler to the OK button, and do the zooming in that action handler.


why do you multiplay JOptionPane and with JDialog, you can customize JOptionPane or add any of JComponent to the JOptionPane, nothing better as post by @Andrew Thompson about that around

0

精彩评论

暂无评论...
验证码 换一张
取 消