Java 类javax.swing.FocusManager 实例源码

项目:geomapapp    文件:LayerManager.java   
private void remove(LayerPanel layerPanel) {
    layerPanels.remove(layerPanel);
    overlays.remove(layerPanel.layer);
    this.remove((Component)layerPanel);

    Dimension lmMaxSize = getMaximumSize();

    Dimension size = new Dimension(
            lmMaxSize.width+20,
            lmMaxSize.height+40);
    Dimension maxSize = lmFrame.getMaximumSize();

    size.height = Math.min(size.height, maxSize.height);
    size.width = Math.min(size.width, maxSize.width);

    lmFrame.setMinimumSize(size);
    lmFrame.setSize(size);
    lmFrame.pack();
    this.revalidate();
    this.repaint();
    if ( lmFrame.isVisible() ) {
        Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
        lmFrame.toFront();
        if (activeWindow != null) activeWindow.requestFocus();
    }
}
项目:openjdk-jdk10    文件:FocusTraversal.java   
private static void isFocusOwner(Component queriedFocusOwner,
        String direction)
        throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Component actualFocusOwner
                    = FocusManager.getCurrentManager().getFocusOwner();
            if (actualFocusOwner != queriedFocusOwner) {
                frame.dispose();
                throw new RuntimeException(
                        "Focus component is wrong after " + direction
                        + " direction ");

            }
        }
    });
}
项目:geomapapp    文件:ProcessingDialog.java   
public void setVisible(boolean tf) {
    if (tf && !isVisible()) {
        stolenFocus = FocusManager.getCurrentManager().getActiveWindow();
    }

    if (owner != null)  {
        setLocation(owner.getX() + 60, owner.getY() + 60);
    }
    super.setVisible(tf);

    if (!tf) {
        if (hasFocus()) {
            if (stolenFocus != owner && 
                    stolenFocus != null && 
                    stolenFocus.isVisible()) {
                stolenFocus.requestFocus();
            } else
            {
                owner.requestFocus();
                map.requestFocusInWindow();
            }
        }
        stolenFocus = null;
    }
}
项目:scorekeeperfrontend    文件:Menus.java   
protected void editChallenge()
{
    UUID curid = ChallengeGUI.state.getCurrentChallengeId();
    for (Challenge c : Database.d.getChallengesForEvent(ChallengeGUI.state.getCurrentEventId()))
    {
        if (c.getChallengeId().equals(curid))
        {
            String response = (String)JOptionPane.showInputDialog(FocusManager.getCurrentManager().getActiveWindow(), "Edit Challenge", c.getName());
            if (response != null)
            {
                c.setName(response);
                Database.d.updateChallenge(c);
                Messenger.sendEvent(MT.NEW_CHALLENGE, c);
            }
        }
    }
}
项目:scorekeeperfrontend    文件:BaseDialog.java   
@Override
public void actionPerformed(ActionEvent ae)
{
    if (ae.getSource() == cancel)
    {
        close();
    }
    else if (ae.getSource() == ok)
    {
        errorMessage = null;
        if (verifyData())
        {
            valid = true;
            close();
        }
        else if (errorMessage != null)
        {
            JOptionPane.showMessageDialog(FocusManager.getCurrentManager().getActiveWindow(), errorMessage, "Dialog Error", JOptionPane.WARNING_MESSAGE);
        }
        else
        {
            Toolkit.getDefaultToolkit().beep();
        }
    }
}
项目:scorekeeperfrontend    文件:AppSetup.java   
/**
 * Do some common setup for all applications at startup
 * @param name the application name used for Java logging and database logging
 */
public static void appSetup(String name)
{
    // Set our platform wide L&F 
    System.setProperty("swing.defaultlaf", "javax.swing.plaf.nimbus.NimbusLookAndFeel");
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    defaults.put("Table.gridColor", new Color(140,140,140));
    defaults.put("Table.showGrid", true);

    // Set the program name which is used by PostgresqlDatabase to identify the app in logs
    System.setProperty("program.name", name);

    // Start with a fresh root set at warning
    Logger root = LogManager.getLogManager().getLogger("");
    Formatter format = new SingleLineFormatter();

    root.setLevel(Level.WARNING);
    for(Handler handler : root.getHandlers()) {
        root.removeHandler(handler);
    }

    // Set prefs levels before windows preference load barfs useless data on the user
    Logger.getLogger("java.util.prefs").setLevel(Level.SEVERE);
    // postgres JDBC spits out a lot of data even though we catch the exception
    Logger.getLogger("org.postgresql.jdbc").setLevel(Level.OFF);
    Logger.getLogger("org.postgresql.Driver").setLevel(Level.OFF);

    // Add console handler if running in debug mode
    if (Prefs.isDebug()) {
        ConsoleHandler ch = new ConsoleHandler();
        ch.setLevel(Level.ALL);
        ch.setFormatter(format);
        root.addHandler(ch);
    }

    // For our own logs, we can set super fine level or info depending on if debug mode and attach dialogs to those
    Logger applog = Logger.getLogger("org.wwscc");
    applog.setLevel(Prefs.isDebug() ? Level.FINEST : Level.INFO);
    applog.addHandler(new AlertHandler());

    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread t, Throwable e) {
            applog.log(Level.WARNING, String.format("\bUncaughtException in %s: %s", t, e), e);
        }});

    try {
        File logdir = Prefs.getLogDirectory().toFile();
        if (!logdir.exists())
            if (!logdir.mkdirs())
                throw new IOException("Can't create log directory " + logdir);
        FileHandler fh = new FileHandler(new File(logdir, name+".%g.log").getAbsolutePath(), 1000000, 10, true);
        fh.setFormatter(format);
        fh.setLevel(Level.ALL);
        root.addHandler(fh);
    } catch (IOException ioe) {
        JOptionPane.showMessageDialog(FocusManager.getCurrentManager().getActiveWindow(),
                "Unable to enable logging to file: " + ioe, "Log Error", JOptionPane.ERROR_MESSAGE);
    }

    // force the initialization of IdGenerator on another thread so app can start now without an odd delay later
    new Thread() {
        public void run() {
            IdGenerator.generateId();
        }
    }.start();
}
项目:openjdk9    文件:FocusTraversal.java   
private static void isFocusOwner(Component queriedFocusOwner,
        String direction)
        throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Component actualFocusOwner
                    = FocusManager.getCurrentManager().getFocusOwner();
            if (actualFocusOwner != queriedFocusOwner) {
                frame.dispose();
                throw new RuntimeException(
                        "Focus component is wrong after " + direction
                        + " direction ");

            }
        }
    });
}
项目:intellij-ce-playground    文件:EditorFixture.java   
/**
 * Requests focus in the editor, waits and returns editor component
 */
@Nullable
private JComponent getFocusedEditor() {
  Editor editor = execute(new GuiQuery<Editor>() {
    @Override
    @Nullable
    protected Editor executeInEDT() throws Throwable {
      FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
      return manager.getSelectedTextEditor(); // Must be called from the EDT
    }
  });

  if (editor != null) {
    JComponent contentComponent = editor.getContentComponent();
    new ComponentDriver(robot).focusAndWaitForFocusGain(contentComponent);
    assertSame(contentComponent, FocusManager.getCurrentManager().getFocusOwner());
    return contentComponent;
  } else {
    fail("Expected to find editor to focus, but there is no current editor");
    return null;
  }
}
项目:phon    文件:MergeGroupEdit.java   
@Override
public void doIt() {
    RecordDataEditorView recordDataView = 
            (RecordDataEditorView)getEditor().getViewModel().getView(RecordDataEditorView.VIEW_NAME);
    if(recordDataView.currentGroupIndex() == groupIndex) {
        final Component focusedComp = 
                FocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if(focusedComp != null && focusedComp instanceof GroupField) {
            final GroupField<?> grpField = (GroupField<?>)focusedComp;
            grpField.validateAndUpdate();
        }
    }

    if(groupIndex+1 >= record.numberOfGroups()) return;

    wordIndex = record.mergeGroups(groupIndex, groupIndex+1);

    queueEvent(EditorEventType.GROUP_LIST_CHANGE_EVT, getSource(), null);
}
项目:consulo    文件:SingleInspectionProfilePanel.java   
private static void setConfigPanel(final JPanel configPanelAnchor, final ScopeToolState state) {
  configPanelAnchor.removeAll();
  final JComponent additionalConfigPanel = state.getAdditionalConfigPanel();
  if (additionalConfigPanel != null) {
    final JScrollPane pane = ScrollPaneFactory.createScrollPane(additionalConfigPanel, SideBorder.NONE);
    FocusManager.getCurrentManager().addPropertyChangeListener("focusOwner", new PropertyChangeListener() {
      @Override
      public void propertyChange(PropertyChangeEvent evt) {
        if (!(evt.getNewValue() instanceof JComponent)) {
          return;
        }
        final JComponent component = (JComponent)evt.getNewValue();
        if (component.isAncestorOf(pane)) {
          pane.scrollRectToVisible(component.getBounds());
        }
      }
    });
    configPanelAnchor.add(pane);
  }
  UIUtil.setEnabled(configPanelAnchor, state.isEnabled(), true);
}
项目:MonkeyBoard    文件:JHintTextField.java   
@Override
    protected void paintComponent(java.awt.Graphics g) {
        super.paintComponent(g);

        if (getText().isEmpty()
                && !(FocusManager.getCurrentKeyboardFocusManager()
                        .getFocusOwner() == this)) {
            Graphics2D g2 = (Graphics2D) g.create();
            // g2.setBackground(Color.gray);
            // g2.setPaint(UIManager.getDefaults().getColor("TextField.shadow"));
//          g2.setPaint(this.getForeground().brighter().brighter().brighter()
//                  .brighter().brighter().brighter().brighter());
             g2.setPaint(Color.gray);
            g2.setFont(getFont().deriveFont(Font.ITALIC));
            g2.drawString(hint, 5, 20); // figure out x, y from font's
                                        // FontMetrics and size of component.
            g2.dispose();
        }
    }
项目:incubator-netbeans    文件:ResultView.java   
public boolean isFocused() {
    ResultViewPanel rvp = getCurrentResultViewPanel();
    if (rvp != null) {
        Component owner = FocusManager.getCurrentManager().getFocusOwner();
        return owner != null && SwingUtilities.isDescendingFrom(owner, rvp);
    } else {
        return false;
    }
}
项目:incubator-netbeans    文件:NbPresenter.java   
/** Requests focus for <code>currentMessage</code> component.
 * If it is of <code>JComponent</code> type it tries default focus
 * request first. */
private void requestFocusForMessage() {
    Component comp = currentMessage;

    if(comp == null) {
        return;
    }

    if (/*!Constants.AUTO_FOCUS &&*/ FocusManager.getCurrentManager().getActiveWindow() == null) {
        // Do not steal focus if no Java window have it
        Component defComp = null;
        Container nearestRoot =
            (comp instanceof Container && ((Container) comp).isFocusCycleRoot()) ? (Container) comp : comp.getFocusCycleRootAncestor();
        if (nearestRoot != null) {
            defComp = nearestRoot.getFocusTraversalPolicy().getDefaultComponent(nearestRoot);
        }
        if (defComp != null) {
            defComp.requestFocusInWindow();
        } else {
            comp.requestFocusInWindow();
        }
    } else {
        if (!(comp instanceof JComponent)
            || !((JComponent)comp).requestDefaultFocus()) {

            comp.requestFocus();
        }
    }
}
项目:incubator-netbeans    文件:NavigatorController.java   
public void actionPerformed (ActionEvent evt) {
    Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
    // move focus away only from navigator AWT children,
    // but not combo box to preserve its ESC functionality
    if (lastActivatedRef == null ||
        focusOwner == null ||
        !SwingUtilities.isDescendingFrom(focusOwner, navigatorTC.getTopComponent()) ||
        focusOwner instanceof JComboBox) {
        return;
    }
    TopComponent prevFocusedTc = lastActivatedRef.get();
    if (prevFocusedTc != null) {
        prevFocusedTc.requestActive();
    }
}
项目:scorekeeperfrontend    文件:StateControl.java   
public void backupRequest()
{
    String msg = "Backup failed. See logs.";
    if (doBackup())
        msg = "Backup complete";
    JOptionPane.showMessageDialog(FocusManager.getCurrentManager().getActiveWindow(), msg);
}
项目:scorekeeperfrontend    文件:Actions.java   
public void actionPerformed(ActionEvent e) {
    String host = JOptionPane.showInputDialog(FocusManager.getCurrentManager().getActiveWindow(), "Enter the remote host name");
    if ((host != null) && !host.trim().equals("")) {
        Database.d.mergeServerSetRemote(host, "", 10);
        Messenger.sendEvent(MT.POKE_SYNC_SERVER, true);
    }
}
项目:scorekeeperfrontend    文件:Menus.java   
protected void deleteChallenge()
{
    List<Challenge> current = Database.d.getChallengesForEvent(ChallengeGUI.state.getCurrentEventId());
    Challenge response = (Challenge)JOptionPane.showInputDialog(FocusManager.getCurrentManager().getActiveWindow(), "Delete which challenge?", "Delete Challenge", JOptionPane.QUESTION_MESSAGE, null, current.toArray(), null);
    if (response == null)
        return;

    int answer = JOptionPane.showConfirmDialog(this, "Are you sure you with to delete " + response + ".  All current activity will be 'lost'", "Confirm Delete", JOptionPane.WARNING_MESSAGE);
    if (answer == JOptionPane.OK_OPTION)
    {
        Database.d.deleteChallenge(response.getChallengeId());
        Messenger.sendEvent(MT.CHALLENGE_DELETED, null);
    }
}
项目:scorekeeperfrontend    文件:OpenSeriesAction.java   
@Override
public void actionPerformed(ActionEvent e)
{
    String options[] = Database.d.getSeriesList().toArray(new String[0]);
    String series = (String)JOptionPane.showInputDialog(FocusManager.getCurrentManager().getActiveWindow(), "Select the series", "Series Selection", JOptionPane.QUESTION_MESSAGE, null, options, null);
    if (series == null)
        return;

    if (Database.openSeries(series, 0))
    {
        Prefs.setSeries(series);
        return;
    }
}
项目:scorekeeperfrontend    文件:AppSetup.java   
public void publish(LogRecord logRecord)
{
    if (isLoggable(logRecord))
    {
        int type;
        String title;
        if (logRecord.getMessage().charAt(0) != '\b') {
            return;
        }

        int val = logRecord.getLevel().intValue();
        if (val >= Level.SEVERE.intValue())
        {
            title = "Error";
            type = JOptionPane.ERROR_MESSAGE;
        }
        else if (val >= Level.WARNING.intValue())
        {
            title = "Warning";
            type = JOptionPane.WARNING_MESSAGE;
        }
        else
        {
            title = "Note";
            type = JOptionPane.INFORMATION_MESSAGE;
        }

        String record = getFormatter().formatMessage(logRecord).replaceAll("[\b]","");
        if (record.contains("\n"))
            record = "<HTML>" + record.replace("\n", "<br>") + "</HTML>";

        // stay off FX or other problem threads
        final String msg = record;
        SwingUtilities.invokeLater(new Runnable() {
            @Override public void run() {
                JOptionPane.showMessageDialog(FocusManager.getCurrentManager().getActiveWindow(), msg, title, type);
            }
        });
    }
}
项目:PhET    文件:PCanvas.java   
/** {@inheritDoc} */
public boolean postProcessKeyEvent(final KeyEvent keyEvent) {
    Component owner = FocusManager.getCurrentManager().getFocusOwner();
    while (owner != null) {
        if (owner == PCanvas.this) {
            sendInputEventToInputManager(keyEvent, keyEvent.getID());
            return true;
        }
        owner = owner.getParent();
    }
    return false;
}
项目:Matlab-Editor-Plugin    文件:JTextFieldSearch.java   
@Override
protected void paintComponent(Graphics g) {
    // paint rounded rectangle if isRounded
    Graphics2D g1 = (Graphics2D) g.create();
    if (isRounded) {
        g1.setColor(getBackground());
        g1.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 25, 25);
        repaint();
    }
    super.paintComponent(g1);

    // paint string "Search ..." and search icon if empty and not-focused
    if (getText().isEmpty() && !(FocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == this)) {
        Graphics2D g2 = (Graphics2D) g.create();
        g2.setColor(Color.lightGray);
        g2.setFont(getFont().deriveFont(Font.BOLD));
        EIcons.SEARCH_15.getIcon().paintIcon(this, g, this.getWidth() - 21, 3);
        g2.drawString(" Search...", 7, 15);
        g2.dispose();
        repaint();
    }

    // set listener for emptying the search bar on click to the right end of the field
    if (!getText().isEmpty()) {
        EIcons.TOOLBAR_DELETE_16.getIcon().paintIcon(this, g, this.getWidth() - 17, 2);
    }
}
项目:intellij-ce-playground    文件:SingleInspectionProfilePanel.java   
private static void setConfigPanel(final JPanel configPanelAnchor, final ScopeToolState state) {
  configPanelAnchor.removeAll();
  final JComponent additionalConfigPanel = state.getAdditionalConfigPanel();
  if (additionalConfigPanel != null) {
    // assume that the panel does not need scrolling if it already contains a scrollable content
    if (UIUtil.hasScrollPane(additionalConfigPanel)) {
      configPanelAnchor.add(additionalConfigPanel);
    }
    else {
      final JScrollPane pane = ScrollPaneFactory.createScrollPane(additionalConfigPanel, SideBorder.NONE);
      FocusManager.getCurrentManager().addPropertyChangeListener("focusOwner", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
          if (!(evt.getNewValue() instanceof JComponent)) {
            return;
          }
          final JComponent component = (JComponent)evt.getNewValue();
          if (component.isAncestorOf(pane)) {
            pane.scrollRectToVisible(component.getBounds());
          }
        }
      });
      configPanelAnchor.add(pane);
    }
  }
  UIUtil.setEnabled(configPanelAnchor, state.isEnabled(), true);
}
项目:piccolo2d.java    文件:PCanvas.java   
/** {@inheritDoc} */
public boolean postProcessKeyEvent(final KeyEvent keyEvent) {
    Component owner = FocusManager.getCurrentManager().getFocusOwner();
    while (owner != null) {
        if (owner == PCanvas.this) {
            sendInputEventToInputManager(keyEvent, keyEvent.getID());
            return true;
        }
        owner = owner.getParent();
    }
    return false;
}
项目:minimal-j    文件:SwingFrontend.java   
private static void focusFirstComponentNow(JComponent component) {
    FocusTraversalPolicy focusPolicy = component.getFocusTraversalPolicy();
    if (component instanceof JTextComponent || component instanceof JComboBox || component instanceof JCheckBox) {
        component.requestFocus();
    } else if (focusPolicy != null && focusPolicy.getFirstComponent(component) != null) {
        focusPolicy.getFirstComponent(component).requestFocus();
    } else {
        FocusManager.getCurrentManager().focusNextComponent(component);
    }
}
项目:phon    文件:SplitGroupEdit.java   
@Override
public void doIt() {
    RecordDataEditorView recordDataView = 
            (RecordDataEditorView)getEditor().getViewModel().getView(RecordDataEditorView.VIEW_NAME);
    if(recordDataView.currentGroupIndex() == gIndex) {
        final Component focusedComp = 
                FocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if(focusedComp != null && focusedComp instanceof GroupField) {
            final GroupField<?> grpField = (GroupField<?>)focusedComp;
            grpField.validateAndUpdate();
        }
    }

    final Record record = getRecord();
    if(record == null) return;

    int wIdx = wIndex;
    if(wIdx < 0) {
        record.addGroup(gIndex);
    } else if(wIdx >= record.getGroup(gIndex).getAlignedWordCount()) {
        record.addGroup(gIndex+1);
    } else {
        record.splitGroup(gIndex, wIdx);
    }

    queueEvent(EditorEventType.GROUP_LIST_CHANGE_EVT, getSource(), null);
}
项目:Harmonia-1.5    文件:RTFEditor.java   
private void updateKeymap() {
    FocusManager.setCurrentManager(new CtrlFocusManager());

    Keymap map = JTextComponent.addKeymap("StyleMap", myEditorPane.getKeymap());

    KeyStroke bold = KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK, false);
    KeyStroke italic = KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK, false);
    KeyStroke underline = KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK, false);

    map.addActionForKeyStroke(bold, getActionByName("font-bold"));
    map.addActionForKeyStroke(italic, getActionByName("font-italic"));
    map.addActionForKeyStroke(underline, getActionByName("font-underline"));

    myEditorPane.setKeymap(map);
}
项目:scorekeeperfrontend    文件:StateControl.java   
public void importRequest()
{
    Window active = FocusManager.getCurrentManager().getActiveWindow();
    final JFileChooser fc = new JFileChooser() {
        @Override
        public void approveSelection(){
            File f = getSelectedFile();
            String pieces[] = f.getName().split("[#._]");
            if (!pieces[0].equals("date") || !pieces[2].equals("schema")) {
                JOptionPane.showMessageDialog(active, f.getName() + " is not a recognized backup filename of the format date_<DATE>#schema_<SCHEMA>");
                return;
            }

            if (Integer.parseInt(pieces[3]) < 20180000) {
                JOptionPane.showMessageDialog(active, "Unable to import backups with schema earlier than 2018, selected file is " + pieces[3]);
                return;
            }

            super.approveSelection();
        }
    };

    fc.setDialogTitle("Specify a backup file to import");
    fc.setCurrentDirectory(Prefs.getRootDir().toFile());
    int returnVal = fc.showOpenDialog(active);
    if ((returnVal != JFileChooser.APPROVE_OPTION) || (fc.getSelectedFile() == null))
        return;

    if (JOptionPane.showConfirmDialog(active, "This will overwrite any data in the current database, is that okay?",
                                        "Import Data", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION)
        return;

    for (Process p : launched) {
        if (p.isAlive())
            p.destroy();
    }

    pmonitor.setPause(true);
    Database.d.close();
    cmonitor.importRequest(fc.getSelectedFile().toPath());
    cmonitor.poke();
}
项目:AtomScript    文件:GUI.java   
public boolean confirm(String message){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    int i = JOptionPane.showConfirmDialog(activeWindow, message, "Confirm", JOptionPane.YES_NO_OPTION);

    if(i == 0){

        return true;

    }else{

        return false;

    }

}
项目:AtomScript    文件:GUI.java   
public boolean confirm(String message, String title){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    int i = JOptionPane.showConfirmDialog(activeWindow, message, title, JOptionPane.YES_NO_OPTION);

    if(i == 0){

        return true;

    }else{

        return false;

    }

}
项目:JCEditor    文件:Pesquisar.java   
/**
* Constrói a GUI e adiciona eventos aos botões.
*/
public void construirGUI() {
    fieldPesquisar = new JTextField(15) {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);

            if (getText().isEmpty() && ! (FocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == this)) {
                Graphics2D g2 = (Graphics2D) g.create();
                g2.setBackground(Color.GRAY);
                g2.setFont(getFont().deriveFont(Font.PLAIN));
                g2.drawString("Pesquisar", 5, 18);
                g2.dispose();
            }
        }};
    fieldSubstituir = new JTextField(15) {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);

            if (getText().isEmpty() && ! (FocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == this)) {
                Graphics2D g2 = (Graphics2D) g.create();
                g2.setBackground(Color.GRAY);
                g2.setFont(getFont().deriveFont(Font.PLAIN));
                g2.drawString("Substituir", 5, 18);
                g2.dispose();
            }
        }};;

    fieldPesquisar.addActionListener(new PesquisarListener());
    fieldPesquisar.addKeyListener(new OcultarBarraListener());
    fieldSubstituir.addKeyListener(new OcultarBarraListener());
    this.add(fieldPesquisar);
    this.add(fieldSubstituir);

    for (int i = 0; i < botoes.length; i++) {
        botoes[i] = new JButton(new ImageIcon(getClass().getResource("imagens/25x25/" + imagens[i] + ".png")));
        botoes[i].addActionListener(eventos[i]);
        botoes[i].setToolTipText(toolTip[i]);
        EfeitoBtn efBtn = new EfeitoBtn(botoes[i]);
        this.add(botoes[i]);
    }
}
项目:AtomScript    文件:GUI.java   
public void showErrorDialog(String error){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    JOptionPane.showMessageDialog(activeWindow, error, "AtomScript Error", JOptionPane.ERROR_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public void showErrorDialog(Exception error){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    JOptionPane.showMessageDialog(activeWindow, error.getLocalizedMessage(), "AtomScript Error", JOptionPane.ERROR_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public void showErrorDialog(String error, String title){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    JOptionPane.showMessageDialog(activeWindow, error, title, JOptionPane.ERROR_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public void showErrorDialog(Exception error, String title){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    JOptionPane.showMessageDialog(activeWindow, error.getLocalizedMessage(), title, JOptionPane.ERROR_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public void alert(String message){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    JOptionPane.showMessageDialog(activeWindow, message, "Alert", JOptionPane.PLAIN_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public String prompt(String message){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    return JOptionPane.showInputDialog(activeWindow, message, "Prompt", JOptionPane.QUESTION_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public void alert(String message, String title){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    JOptionPane.showMessageDialog(activeWindow, message, title, JOptionPane.PLAIN_MESSAGE);

}
项目:AtomScript    文件:GUI.java   
public String prompt(String message, String title){

    Window activeWindow = FocusManager.getCurrentManager().getActiveWindow();
    return JOptionPane.showInputDialog(activeWindow, message, title, JOptionPane.QUESTION_MESSAGE);

}
项目:javamelody    文件:MSwingUtilities.java   
/**
 * Retourne le focusOwner permanent.<br/>
 * Le focusOwner permanent est défini comme le dernier Component à avoir reçu un événement FOCUS_GAINED permanent.<br/>
 * Le focusOwner et le focusOwner permanent sont équivalent sauf si un changement temporaire de focus<br/>
 * est en cours. Si c'est le cas, le focusOwner permanent redeviendra &galement<br/>
 * le focusOwner à la fin de ce changement de focus temporaire.
 *
 * @return Component
 */
public static Component getPermanentFocusOwner() {
    // return new DefaultKeyboardFocusManager().getPermanentFocusOwner();
    return FocusManager.getCurrentManager().getPermanentFocusOwner();
}
项目:javamelody    文件:MSwingUtilities.java   
/**
 * Retourne la fenêtre possédant le focus.
 *
 * @return Component
 */
public static Window getFocusedWindow() {
    // return new DefaultKeyboardFocusManager().getFocusedWindow();
    return FocusManager.getCurrentManager().getFocusedWindow();
}