/** {@inheritDoc} */
  public void setPressed(boolean b) {
    if ((isPressed() == b) || !isEnabled()) {
      return;
    }

    if (b) {
      stateMask |= PRESSED;
    } else {
      stateMask &= ~PRESSED;
    }

    if (!isPressed() && isArmed()) {
      int modifiers = 0;
      AWTEvent currentEvent = EventQueue.getCurrentEvent();
      if (currentEvent instanceof InputEvent) {
        modifiers = ((InputEvent) currentEvent).getModifiers();
      } else if (currentEvent instanceof ActionEvent) {
        modifiers = ((ActionEvent) currentEvent).getModifiers();
      }
      fireActionPerformed(
          new ActionEvent(
              this,
              ActionEvent.ACTION_PERFORMED,
              getActionCommand(),
              EventQueue.getMostRecentEventTime(),
              modifiers));
    }

    fireStateChanged();
  }
示例#2
0
  @Override
  public ActionCallback show() {
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    if (myTypeAheadCallback != null) {
      IdeFocusManager.getInstance(myProject).typeAheadUntil(myTypeAheadCallback);
    }
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    final ActionCallback result = new ActionCallback();

    final AnCancelAction anCancelAction = new AnCancelAction();
    final JRootPane rootPane = getRootPane();
    anCancelAction.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), rootPane);
    myDisposeActions.add(
        new Runnable() {
          @Override
          public void run() {
            anCancelAction.unregisterCustomShortcutSet(rootPane);
          }
        });

    if (!myCanBeParent && myWindowManager != null) {
      myWindowManager.doNotSuggestAsParent(myDialog.getWindow());
    }

    final CommandProcessorEx commandProcessor =
        ApplicationManager.getApplication() != null
            ? (CommandProcessorEx) CommandProcessor.getInstance()
            : null;
    final boolean appStarted = commandProcessor != null;

    if (myDialog.isModal() && !isProgressDialog()) {
      if (appStarted) {
        commandProcessor.enterModal();
        LaterInvocator.enterModal(myDialog);
      }
    }

    if (appStarted) {
      hidePopupsIfNeeded();
    }

    try {
      myDialog.show();
    } finally {
      if (myDialog.isModal() && !isProgressDialog()) {
        if (appStarted) {
          commandProcessor.leaveModal();
          LaterInvocator.leaveModal(myDialog);
        }
      }

      myDialog.getFocusManager().doWhenFocusSettlesDown(result.createSetDoneRunnable());
    }

    return result;
  }
示例#3
0
  /**
   * Main method. Begins the GUI, and the rest of the program.
   *
   * @param args the command line arguments
   */
  public static void main(String args[]) {
    // playSound();
    try {
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (ClassNotFoundException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException ex) {
      Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex);
    }
    // </editor-fold>

    /* Create and display the form */
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            new mainForm().setVisible(true);
          }
        });
  }
 public void insertUpdate(final DocumentEvent e) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           try {
             String inserted = e.getDocument().getText(e.getOffset(), e.getLength());
             int i = inserted.indexOf('\n');
             if (i >= 0) {
               int offset = e.getOffset() + i;
               if (offset + 1 == e.getDocument().getLength()) {
                 returnResponse();
               } else {
                 // remove the '\n' and put it at the end
                 e.getDocument().remove(offset, 1);
                 e.getDocument().insertString(e.getDocument().getLength(), "\n", null);
                 // insertUpdate will be called again, since we have inserted the '\n' at
                 // the end
               }
             } else if (maxLen >= 0
                 && e.getDocument().getLength() - initialPos >= maxLen) {
               returnResponse();
             }
           } catch (BadLocationException ex) {
             returnResponse();
           }
         }
       });
 }
示例#5
0
  /** Is called when the applet wants to be resized. */
  @Override
  public void appletResize(int width, int height) {
    currentAppletSize.width = width;
    currentAppletSize.height = height;
    final Dimension currentSize = new Dimension(currentAppletSize.width, currentAppletSize.height);

    if (loader != null) {
      AppContext appCtxt = loader.getAppContext();
      if (appCtxt != null) appEvtQ = (java.awt.EventQueue) appCtxt.get(AppContext.EVENT_QUEUE_KEY);
    }

    final AppletPanel ap = this;
    if (appEvtQ != null) {
      appEvtQ.postEvent(
          new InvocationEvent(
              Toolkit.getDefaultToolkit(),
              new Runnable() {
                @Override
                public void run() {
                  if (ap != null) {
                    ap.dispatchAppletEvent(APPLET_RESIZE, currentSize);
                  }
                }
              }));
    }
  }
示例#6
0
    @Override
    public void keyPressed(KeyEvent evt) {
      switch (evt.getKeyCode()) {
        case KeyEvent.VK_SPACE:
          goToSelectedNode(M_OPEN);

          // f**k me dead
          EventQueue.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  resultTree.requestFocus();
                }
              });

          evt.consume();
          break;
        case KeyEvent.VK_ENTER:
          goToSelectedNode(M_OPEN);
          evt.consume();
          break;
        case KeyEvent.VK_DELETE:
          removeSelectedNode();
          evt.consume();
          break;
        default:
          break;
      }
    }
示例#7
0
 /* (non-Javadoc)
  * @see java.awt.Component#doLayout()
  */
 public void doLayout() {
   if (EventQueue.isDispatchThread()) {
     Dimension size = this.getSize();
     this.rblock.setBounds(0, 0, size.width, size.height);
     this.removeAll();
     this.rblock.layout(size.width, size.height);
     this.rblock.updateWidgetBounds();
   } else {
     EventQueue.invokeLater(
         new Runnable() {
           public void run() {
             HtmlBlock.this.doLayout();
           }
         });
   }
 }
示例#8
0
  // {{{ BrowserView constructor
  BrowserView(final VFSBrowser browser) {
    this.browser = browser;

    tmpExpanded = new HashSet<String>();
    DockableWindowManager dwm = jEdit.getActiveView().getDockableWindowManager();
    KeyListener keyListener = dwm.closeListener(VFSBrowser.NAME);

    parentDirectories = new ParentDirectoryList();
    parentDirectories.addKeyListener(keyListener);
    parentDirectories.setName("parent");

    parentDirectories.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    parentDirectories.setCellRenderer(new ParentDirectoryRenderer());
    parentDirectories.setVisibleRowCount(5);
    parentDirectories.addMouseListener(new ParentMouseHandler());

    final JScrollPane parentScroller = new JScrollPane(parentDirectories);
    parentScroller.setMinimumSize(new Dimension(0, 0));

    table = new VFSDirectoryEntryTable(this);
    table.addMouseListener(new TableMouseHandler());
    table.addKeyListener(new TableKeyListener());
    table.setName("file");
    JScrollPane tableScroller = new JScrollPane(table);
    tableScroller.setMinimumSize(new Dimension(0, 0));
    tableScroller.getViewport().setBackground(table.getBackground());
    tableScroller.getViewport().addMouseListener(new TableMouseHandler());
    splitPane =
        new JSplitPane(
            browser.isHorizontalLayout() ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT,
            parentScroller,
            tableScroller);
    splitPane.setOneTouchExpandable(true);

    EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            String prop =
                browser.isHorizontalLayout()
                    ? "vfs.browser.horizontalSplitter"
                    : "vfs.browser.splitter";
            int loc = jEdit.getIntegerProperty(prop, -1);
            if (loc == -1) loc = parentScroller.getPreferredSize().height;

            splitPane.setDividerLocation(loc);
            parentDirectories.ensureIndexIsVisible(parentDirectories.getModel().getSize());
          }
        });

    if (browser.isMultipleSelectionEnabled())
      table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    else table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    setLayout(new BorderLayout());

    add(BorderLayout.CENTER, splitPane);

    propertiesChanged();
  } // }}}
示例#9
0
文件: Server.java 项目: w4-pwr/studia
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           new Server();
         }
       });
 }
示例#10
0
 /**
  * ** Queues the invocation of the specified Runnable on the EventQueue, and waits for the
  * EventQueue ** thread to complete execution of the specified Runnable. ** @param r The Runnable
  * to execute
  */
 public static void invokeAndWait(Runnable r)
     throws InterruptedException, InvocationTargetException {
   if (r != null) {
     // call from a child thread only! (will block otherwise)
     // Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(r);
     EventQueue.invokeAndWait(r);
   }
 }
示例#11
0
 public static void main(String... args) {
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           createAndShowGUI();
         }
       });
 }
 public static void main(String[] args) throws Exception {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           JFrame frame = new SwingWorkerFrame();
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
         }
       });
 }
示例#13
0
 @Override
 public void actionPerformed(ActionEvent e) {
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           fireEditingStopped();
         }
       });
 }
示例#14
0
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           JFrame frame = new PostTestFrame();
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
         }
       });
 }
 String response() {
   EventQueue.invokeLater(this);
   try {
     return resultQueue.take();
   } catch (InterruptedException ex) {
     return null;
   } finally {
     cleanup();
   }
 }
 public void removeUpdate(final DocumentEvent e) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           if ((e.getDocument().getLength() < initialPos || e.getOffset() < initialPos)
               && e instanceof UndoableEdit) {
             ((UndoableEdit) e).undo();
             run.setCaretPosition(e.getOffset() + e.getLength());
           }
         }
       });
 }
 void cleanup() { // not required to be called from the GUI thread
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           run.getDocument().removeDocumentListener(listener);
           run.setEditable(false);
           run.setNavigationFilter(null);
           run.setCaretPosition(run.getDocument().getLength());
           Simulator.getInstance().removeStopListener(stopListener);
         }
       });
 }
 /** Launch the application. */
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           try {
             TestSauvegardeChargement window = new TestSauvegardeChargement();
             window.frame.setVisible(true);
           } catch (Exception e) {
             e.printStackTrace();
           }
         }
       });
 }
 /**
  * Launch the application.
  *
  * <p>APIs
  *
  * <p>EmailValidator Class https://commons.apache.org/proper/commons-validator/apidocs/org/apache/
  * commons/validator/routines/EmailValidator.html
  */
 public static void main(String[] args) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           try {
             LoginView window = new LoginView();
             window.frmSignIn.setVisible(true);
           } catch (Exception e) {
             e.printStackTrace();
           }
         }
       });
 }
示例#20
0
 /**
  * Launch the application
  *
  * @param args
  */
 public static void main(String args[]) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           try {
             DateTimer frame = new DateTimer();
             frame.setVisible(true);
           } catch (Exception e) {
             e.printStackTrace();
           }
         }
       });
 }
 public void changedUpdate(DocumentEvent e) {
   assert EventQueue.isDispatchThread();
   //      System.err.println("changedUpdate fired!");
   //      Utilities.invokeLater(new Runnable() {
   //        public void run() {
   removeListener();
   _pim.setMask(_textField.getText());
   updateExtensionLabel();
   updateList();
   addListener();
   //        }
   //      });
 }
示例#22
0
 public static void main(String[] args) {
   System.setProperty("java.security.policy", "permissions/PermissionTest.policy");
   System.setSecurityManager(new SecurityManager());
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           JFrame frame = new PermissionTestFrame();
           frame.setTitle("PermissionTest");
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
         }
       });
 }
示例#23
0
  public static void main(String args[]) {
    Runnable runner =
        new Runnable() {

          public void run() {
            if (SystemTray.isSupported()) {
              final SystemTray tray = SystemTray.getSystemTray();
              Image image = Toolkit.getDefaultToolkit().getImage("gifIcon.gif");
              PopupMenu popup = new PopupMenu();
              final TrayIcon trayIcon = new TrayIcon(image, "The Tip Text", popup);
              MenuItem item = new MenuItem("Error");
              item.addActionListener(
                  new ShowMessageListener(
                      trayIcon, "Error Title", "Error", TrayIcon.MessageType.ERROR));
              popup.add(item);
              item = new MenuItem("Warning");
              item.addActionListener(
                  new ShowMessageListener(
                      trayIcon, "Warning Title", "Warning", TrayIcon.MessageType.WARNING));
              popup.add(item);
              item = new MenuItem("Info");
              item.addActionListener(
                  new ShowMessageListener(
                      trayIcon, "Info Title", "Info", TrayIcon.MessageType.INFO));
              popup.add(item);
              item = new MenuItem("None");
              item.addActionListener(
                  new ShowMessageListener(
                      trayIcon, "None Title", "None", TrayIcon.MessageType.NONE));
              popup.add(item);
              item = new MenuItem("Close");
              item.addActionListener(
                  new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                      tray.remove(trayIcon);
                    }
                  });
              popup.add(item);
              try {
                tray.add(trayIcon);
              } catch (AWTException e) {
                System.err.println("Can't add to tray");
              }
            } else {
              System.err.println("Tray unavailable");
            }
          }
        };
    EventQueue.invokeLater(runner);
  }
示例#24
0
  public static void main(String[] args) {
    EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            try {
              SotrudnikDialog frame = new SotrudnikDialog();
              frame.setVisible(true);

            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
  }
示例#25
0
  @Override
  @SuppressWarnings("SSBasedInspection")
  protected void dispose() {
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    for (Runnable runnable : myDisposeActions) {
      runnable.run();
    }
    myDisposeActions.clear();
    final JRootPane root = myDialog.getRootPane();

    Runnable disposer =
        new Runnable() {
          @Override
          public void run() {
            myDialog.dispose();
            myProject = null;

            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    if (myDialog != null && root != null) {
                      myDialog.remove(root);
                    }
                  }
                });
          }
        };

    if (EventQueue.isDispatchThread()) {
      disposer.run();
    } else {
      SwingUtilities.invokeLater(disposer);
    }
  }
示例#26
0
  public static void main(String[] args) {

    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            try {
              ScreenShotWindow ssw = new ScreenShotWindow();
              ssw.setVisible(true);
            } catch (AWTException e) {
              e.printStackTrace();
            }
          }
        });
  }
 private void performGazeteerAction(final ActionEvent e) {
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           try {
             handleEntryAction(e);
           } catch (NoItemException e) {
             controller.showMessageDialog(
                 "No search string was specified", "No Search String", JOptionPane.ERROR_MESSAGE);
           } catch (Exception e) {
             controller.showMessageDialog(
                 "Location not found", "Location Unknown", JOptionPane.ERROR_MESSAGE);
           }
         }
       });
 }
示例#28
0
 /**
  * Perform the specified Action on the object
  *
  * @param i zero-based index of actions
  * @return true if the action was performed; otherwise false.
  */
 public boolean doAccessibleAction(int i) {
   if (i == 0) {
     // Simulate a button click
     Toolkit.getEventQueue()
         .postEvent(
             new ActionEvent(
                 MenuItem.this,
                 ActionEvent.ACTION_PERFORMED,
                 MenuItem.this.getActionCommand(),
                 EventQueue.getMostRecentEventTime(),
                 0));
     return true;
   } else {
     return false;
   }
 }
示例#29
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   System.out.println("getTableCellEditorComponent");
   setFont(table.getFont());
   setText(Objects.toString(value, ""));
   EventQueue.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           setCaretPosition(getText().length());
           requestFocusInWindow();
           System.out.println("invokeLater: getTableCellEditorComponent");
         }
       });
   return scroll;
 }
示例#30
0
 public void run() {
   try {
     while (true) {
       EventQueue.invokeLater(
           new Runnable() {
             public void run() {
               combo.showPopup();
               int i = Math.abs(generator.nextInt());
               if (i % 2 == 0) combo.insertItemAt(new Integer(i), 0);
               else if (combo.getItemCount() > 0) combo.removeItemAt(i % combo.getItemCount());
             }
           });
       Thread.sleep(1);
     }
   } catch (InterruptedException e) {
   }
 }