private DynamicUIManager() { final PropertyChangeListener l = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { handlePropertyChanges(); } }; UIManager.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName().equals("lookAndFeel")) { setupPropertyListener(l); fireLookAndFeelChanging(); fireLookAndFeelChanged(); } } }); UIManager.getDefaults() .addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (!(event.getNewValue() instanceof Class)) handlePropertyChanges(); } }); setupPropertyListener(l); }
public JoSplitPane( int newOrientation, int dividerMethod, JoComponent newLeftComponent, JoComponent newRightComponent, Dimension size) { super(newOrientation, false, (Component) newLeftComponent, (Component) newRightComponent); /** * workaround for GTK look & feel. This value is missing and would crash JoSplitPaneUI (note * that the actual divider size will be overwritten, anyway) */ // System.out.println(UIManager.getDefaults().get("SplitPaneUI")); UIManager.getDefaults().put("SplitPane.dividerSize", new Integer(6)); setUI(new JoSplitPaneUI()); if (size == null) size = getSize(); else setSize(size); // setDividerSize(3); setOneTouchExpandable(false); this.dividerMethod = dividerMethod; if (size.width > 0 && size.height > 0) adjustDivider(size); updateContinuousLayout(); AbstractApplication.theCommandDispatcher.addCommandListener(this); }
protected void installDefaults() { String string = UIManager.getLookAndFeel().getName(); Color defaultGridColor = UIManager.getColor("Table.gridColor"); Color defaultForegroundColor = UIManager.getColor("TableHeader.foreground"); Color defaultBackgroundColor = UIManager.getColor("TableHeader.background"); Font defaultGridFont = UIManager.getFont("Table.font"); Border defaultGridBorder = UIManager.getBorder("TableHeader.border"); Color defaultSelectionForegroundColor = defaultForegroundColor.brighter(); Color defaultSelectionBackgroundColor = defaultBackgroundColor; Color defaultFocusForegroundColor = defaultForegroundColor.brighter(); Color defaultFocusBackgroundColor = defaultBackgroundColor.brighter(); if (!installedHeader) { UIManager.getDefaults().put("GridHeader.gridColor", defaultGridColor); UIManager.getDefaults().put("GridHeader.foreground", defaultForegroundColor); UIManager.getDefaults().put("GridHeader.background", defaultBackgroundColor); UIManager.getDefaults() .put("GridHeader.selectionForegroundColor", defaultSelectionForegroundColor); UIManager.getDefaults() .put("GridHeader.selectionBackgroundColor", defaultSelectionBackgroundColor); UIManager.getDefaults().put("GridHeader.focusForegroundColor", defaultFocusForegroundColor); UIManager.getDefaults().put("GridHeader.focusBackgroundColor", defaultFocusBackgroundColor); UIManager.getDefaults().put("GridHeader.border", defaultGridBorder); UIManager.getDefaults().put("GridHeader.font", defaultGridFont); } Color foregroundColor = gridHeader.getForeground(); Color backgroundColor = gridHeader.getBackground(); Font gridFont = gridHeader.getFont(); Border gridBorder = gridHeader.getBorder(); Color gridColor = gridHeader.getGridColor(); Color selectionForegroundColor = gridHeader.getSelectionForegroundColor(); Color selectionBackgroundColor = gridHeader.getSelectionBackgroundColor(); Color focusForegroundColor = gridHeader.getFocusForegroundColor(); Color focusBackgroundColor = gridHeader.getFocusBackgroundColor(); if (foregroundColor == null || foregroundColor instanceof UIResource) gridHeader.setForeground(defaultForegroundColor); if (backgroundColor == null || backgroundColor instanceof UIResource) gridHeader.setBackground(defaultBackgroundColor); if (gridColor == null || gridColor instanceof UIResource) gridHeader.setGridColor(defaultGridColor); if (gridFont == null || gridFont instanceof UIResource) gridHeader.setFont(defaultGridFont); if (gridBorder == null || gridBorder instanceof UIResource) gridHeader.setBorder(defaultGridBorder); if (selectionForegroundColor == null || selectionForegroundColor instanceof UIResource) gridHeader.setSelectionForegroundColor(defaultSelectionForegroundColor); if (selectionBackgroundColor == null || selectionBackgroundColor instanceof UIResource) gridHeader.setSelectionBackgroundColor(defaultSelectionBackgroundColor); if (focusForegroundColor == null || focusForegroundColor instanceof UIResource) gridHeader.setFocusForegroundColor(defaultFocusForegroundColor); if (focusBackgroundColor == null || focusBackgroundColor instanceof UIResource) gridHeader.setFocusBackgroundColor(defaultFocusBackgroundColor); }
/** @param args command line params */ public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); f = UIManager.getDefaults().getFont("TabbedPane.font"); f = new Font(f.getFamily(), Font.BOLD, f.getSize()); } catch (Exception x) { } new TestProgram().start(); }
/** p:初始化look and feel, 把一切放到这个里面.可以让多个地方调用. */ public static void initLookAndFeel() { // p:隐藏对话框的系统标题风格,用look and feel定义的标题风格. try { UIManager.setLookAndFeel(UILookAndFeel.class.getName()); } catch (Exception e) { FRLogger.getLogger().log(Level.WARNING, "Substance Raven Graphite failed to initialize"); } // 获取当前系统语言下设计器用的默认字体 FRFont guiFRFont = getCurrentLocaleFont(); // 指定UIManager中字体 Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { String key = keys.nextElement().toString(); if (key.endsWith(".font")) { UIManager.put(key, isTextField(key) ? getNamedFont("Dialog") : guiFRFont); } } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { Icon icon = (Icon) _originalIcon.createValue(UIManager.getDefaults()); if (isSynthIcon(icon)) { int state = getComponentState((JComponent) c); if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) state &= ~SynthConstants.SELECTED; SynthContext context = new SynthContext( (JComponent) c, Region.CHECK_BOX, SynthLookAndFeel.getStyle((JComponent) c, Region.CHECK_BOX), state); final int w = ((SynthIcon) icon).getIconWidth(context); final int h = ((SynthIcon) icon).getIconHeight(context); ((SynthIcon) icon).paintIcon(context, g, x, y, w, h); } else { if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) { ((TristateButtonModel) ((TristateCheckBox) c).getModel()).internalSetSelected(false); } icon.paintIcon(c, g, x, y); if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) { ((TristateButtonModel) ((TristateCheckBox) c).getModel()).internalSetSelected(true); } } g.setColor(UIManager.getColor("CheckBox.foreground")); if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) drawSquare(c, g, x, y); }
public static void main(String[] argv) { try { String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { String laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; UIManager.setLookAndFeel(laf); } else { UIManager.put("swing.boldMetal", Boolean.FALSE); javax.swing.plaf.FontUIResource f = new javax.swing.plaf.FontUIResource("SansSerif", Font.PLAIN, 11); java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, f); } } UIManager.put("TitledBorder.titleColor", Color.blue); } catch (java.lang.Exception exc) { } VncViewer viewer = new VncViewer(argv); viewer.start(); }
private void setDefault() { UIManager.getDefaults().put("LinkButtonUI", "BasicLinkButtonUI"); }
public Viewport(CConn cc_) { cc = cc_; updateTitle(); setFocusable(false); setFocusTraversalKeysEnabled(false); setIconImage(VncViewer.frameImage); UIManager.getDefaults() .put("ScrollPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {})); sp = new JScrollPane(); sp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); sp.getViewport().setBackground(Color.BLACK); InputMap im = sp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); int ctrlAltShiftMask = Event.SHIFT_MASK | Event.CTRL_MASK | Event.ALT_MASK; if (im != null) { im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ctrlAltShiftMask), "unitScrollUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ctrlAltShiftMask), "unitScrollDown"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ctrlAltShiftMask), "unitScrollLeft"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ctrlAltShiftMask), "unitScrollRight"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, ctrlAltShiftMask), "scrollUp"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, ctrlAltShiftMask), "scrollDown"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, ctrlAltShiftMask), "scrollLeft"); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, ctrlAltShiftMask), "scrollRight"); } tb = new Toolbar(cc); add(tb, BorderLayout.PAGE_START); getContentPane().add(sp); if (VncViewer.os.startsWith("mac os x")) { macMenu = new MacMenuBar(cc); setJMenuBar(macMenu); if (VncViewer.getBooleanProperty("turbovnc.lionfs", true)) enableLionFS(); } // NOTE: If Lion FS mode is enabled, then the viewport is only created once // as a non-full-screen viewport, so we tell showToolbar() to ignore the // full-screen state. showToolbar(cc.showToolbar, canDoLionFS); addWindowFocusListener( new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { if (sp.getViewport().getView() != null) sp.getViewport().getView().requestFocusInWindow(); if (isVisible() && keyboardTempUngrabbed) { vlog.info("Keyboard focus regained. Re-grabbing keyboard."); grabKeyboardHelper(true); keyboardTempUngrabbed = false; } } public void windowLostFocus(WindowEvent e) { if (cc.keyboardGrabbed && isVisible()) { vlog.info("Keyboard focus lost. Temporarily ungrabbing keyboard."); grabKeyboardHelper(false); keyboardTempUngrabbed = true; } } }); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { cc.close(); } }); addComponentListener( new ComponentAdapter() { public void componentResized(ComponentEvent e) { if (cc.opts.scalingFactor == Options.SCALE_AUTO || cc.opts.scalingFactor == Options.SCALE_FIXEDRATIO) { if ((sp.getSize().width != cc.desktop.scaledWidth) || (sp.getSize().height != cc.desktop.scaledHeight)) { cc.desktop.setScaledSize(); sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); sp.validate(); if (getExtendedState() != JFrame.MAXIMIZED_BOTH && !cc.opts.fullScreen) { sp.setSize(new Dimension(cc.desktop.scaledWidth, cc.desktop.scaledHeight)); int w = cc.desktop.scaledWidth + VncViewer.insets.left + VncViewer.insets.right; int h = cc.desktop.scaledHeight + VncViewer.insets.top + VncViewer.insets.bottom; if (tb.isVisible()) h += tb.getHeight(); if (cc.opts.scalingFactor == Options.SCALE_FIXEDRATIO) setSize(w, h); } } } else if (cc.opts.desktopSize.mode == Options.SIZE_AUTO && !cc.firstUpdate && !cc.pendingServerResize) { Dimension availableSize = cc.viewport.getAvailableSize(); if (availableSize.width >= 1 && availableSize.height >= 1 && (availableSize.width != cc.desktop.scaledWidth || availableSize.height != cc.desktop.scaledHeight)) { sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sp.validate(); if (timer != null) timer.stop(); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Dimension availableSize = cc.viewport.getAvailableSize(); if (availableSize.width < 1 || availableSize.height < 1) throw new ErrorException("Unexpected zero-size component"); cc.sendDesktopSize(availableSize.width, availableSize.height, true); } }; timer = new Timer(500, actionListener); timer.setRepeats(false); timer.start(); } } else { sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sp.validate(); } if (cc.desktop.cursor != null) { Cursor cursor = cc.desktop.cursor; if (cursor.hotspot != null) // hotspot will be null until the first cursor update is received // from the server. cc.setCursor( cursor.width(), cursor.height(), cursor.hotspot, (int[]) cursor.data, cursor.mask); } if (((sp.getSize().width > cc.desktop.scaledWidth) || (sp.getSize().height > cc.desktop.scaledHeight)) && cc.opts.desktopSize.mode != Options.SIZE_AUTO) { int w = sp.getSize().width - adjustWidth; int h = sp.getSize().height - adjustHeight; dx = (w <= cc.desktop.scaledWidth) ? 0 : (int) Math.floor((w - cc.desktop.scaledWidth) / 2); dy = (h <= cc.desktop.scaledHeight) ? 0 : (int) Math.floor((h - cc.desktop.scaledHeight) / 2); } else { dx = dy = 0; } repaint(); } }); }
protected void installDefaults() { Color defaultGridColor = UIManager.getColor("Table.gridColor"); Color defaultForegroundColor = UIManager.getColor("Table.foreground"); Color defaultBackgroundColor = UIManager.getColor("Table.background"); Border defaultBorder = UIManager.getBorder("Table.scrollPaneBorder"); Color defaultSelectionForeground = UIManager.getColor("Table.selectionForeground"); Color defaultSelectionBackground = UIManager.getColor("Table.selectionBackground"); Color defaultFocusCellForeground = UIManager.getColor("Table.focusCellForeground"); Color defaultFocusCellBackground = new Color(153, 153, 204); Font defaultFont = UIManager.getFont("Table.font"); Border defaultGridBorder = UIManager.getBorder("Table.border"); InputMap inputMap = (InputMap) UIManager.get("Table.ancestorInputMap"); if (!installed) { UIManager.getDefaults().put("Grid.gridColor", defaultGridColor); UIManager.getDefaults().put("Grid.foreground", defaultForegroundColor); UIManager.getDefaults().put("Grid.background", defaultBackgroundColor); UIManager.getDefaults().put("Grid.selectionForegroundColor", defaultSelectionForeground); UIManager.getDefaults().put("Grid.selectionBackgroundColor", defaultSelectionBackground); UIManager.getDefaults().put("Grid.focusForegroundColor", defaultFocusCellForeground); UIManager.getDefaults().put("Grid.focusBackgroundColor", defaultFocusCellBackground); UIManager.getDefaults().put("Grid.border", defaultGridBorder); UIManager.getDefaults().put("Grid.font", defaultFont); UIManager.getDefaults().put("Grid.scrollPaneBorder", defaultBorder); UIManager.getDefaults().put("Grid.ancestorInputMap", inputMap); installed = true; } Color foregroundColor = grid.getForeground(); Color backgroundColor = grid.getBackground(); Font font = grid.getFont(); Border border = grid.getBorder(); Color gridColor = grid.getGridColor(); Color selectionForeground = grid.getSelectionForegroundColor(); Color selectionBackground = grid.getSelectionBackgroundColor(); Color focusForeground = grid.getFocusForegroundColor(); Color focusBackground = grid.getFocusBackgroundColor(); if (foregroundColor == null || foregroundColor instanceof UIResource) grid.setForeground(defaultForegroundColor); if (backgroundColor == null || backgroundColor instanceof UIResource) grid.setBackground(defaultBackgroundColor); if (font == null || font instanceof UIResource) grid.setFont(defaultFont); if (gridColor == null || gridColor instanceof UIResource) grid.setGridColor(defaultGridColor); if (border == null || border instanceof UIResource) grid.setBorder(defaultGridBorder); if (selectionForeground == null || selectionForeground instanceof UIResource) grid.setSelectionForegroundColor(defaultSelectionForeground); if (selectionBackground == null || selectionBackground instanceof UIResource) grid.setSelectionBackgroundColor(defaultSelectionBackground); if (focusForeground == null || focusForeground instanceof UIResource) grid.setFocusForegroundColor(defaultFocusCellForeground); if (focusBackground == null || focusBackground instanceof UIResource) grid.setFocusBackgroundColor(defaultFocusCellBackground); }
/** * Constructor * * @param game */ public SwingView(Game game) { this.game = game; // get frame size this.size = game.getSize(); this.side = size * 100; UIManager.getDefaults().put("Button.disabledText", Color.BLACK); // set size (the game field size + the status line size + the buttons panel) this.setSize(side, side + 20 + 30); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setTitle("TicTacToe"); // Create the main panel which will // contain all other panels JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); this.add(mainPanel); // The game status string JPanel status = new JPanel(); status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS)); status.setMaximumSize(new Dimension(side, 20)); statusStr = new JLabel(game.getState().toString()); status.add(statusStr); mainPanel.add(status); // The game field panel gameField = new JPanel(); gameField.setSize(side, side); gameField.setLayout(new GridLayout(size, size)); // Fill the game field with buttons for (int i = 0; i < size * size; i++) { gameField.add(createButton()); } mainPanel.add(gameField); // The buttons panel JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.setMaximumSize(new Dimension(side, 50)); JButton restartBtn = new JButton(); restartBtn.setMaximumSize(new Dimension(side, 50)); restartBtn.setText("Restart"); restartBtn.addActionListener( e -> { this.dispose(); this.game = new Game(); new SwingView(this.game); }); buttons.add(restartBtn); mainPanel.add(buttons); this.setResizable(false); // Game window appears on center this.setLocationRelativeTo(null); this.setVisible(true); }
/** Adds the ui class to UIDefaults. */ static { UIManager.getDefaults().put(UIClassID, BasicButtonUI.class.getName()); }
@Override public int getIconHeight() { Icon icon = (Icon) _originalIcon.createValue(UIManager.getDefaults()); return icon.getIconHeight(); }
@Override public void actionPerformed(AnActionEvent e) { final UIDefaults defaults = UIManager.getDefaults(); Enumeration keys = defaults.keys(); final Object[][] data = new Object[defaults.size()][2]; int i = 0; while (keys.hasMoreElements()) { Object key = keys.nextElement(); data[i][0] = key; data[i][1] = defaults.get(key); i++; } Arrays.sort( data, new Comparator<Object[]>() { @Override public int compare(Object[] o1, Object[] o2) { return StringUtil.naturalCompare(o1[0].toString(), o2[0].toString()); } }); final Project project = getEventProject(e); new DialogWrapper(project) { { setTitle("Edit LaF Defaults"); init(); } public JBTable myTable; @Nullable @Override public JComponent getPreferredFocusedComponent() { return myTable; } @Nullable @Override protected String getDimensionServiceKey() { return project == null ? null : "UI.Defaults.Dialog"; } @Override protected JComponent createCenterPanel() { final JBTable table = new JBTable( new DefaultTableModel(data, new Object[] {"Name", "Value"}) { @Override public boolean isCellEditable(int row, int column) { return column == 1 && getValueAt(row, column) instanceof Color; } }) { @Override public boolean editCellAt(int row, int column, EventObject e) { if (isCellEditable(row, column) && e instanceof MouseEvent) { final Object color = getValueAt(row, column); final Color newColor = ColorPicker.showDialog(this, "Choose Color", (Color) color, true, null); if (newColor != null) { final ColorUIResource colorUIResource = new ColorUIResource(newColor); final Object key = getValueAt(row, 0); UIManager.put(key, colorUIResource); setValueAt(colorUIResource, row, column); } } return false; } }; table.setDefaultRenderer( Object.class, new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final JPanel panel = new JPanel(new BorderLayout()); final JLabel label = new JLabel(value == null ? "" : value.toString()); panel.add(label, BorderLayout.CENTER); if (value instanceof Color) { final Color c = (Color) value; label.setText( String.format( "[r=%d,g=%d,b=%d] hex=0x%s", c.getRed(), c.getGreen(), c.getBlue(), ColorUtil.toHex(c))); label.setForeground(ColorUtil.isDark(c) ? Color.white : Color.black); panel.setBackground(c); return panel; } else if (value instanceof Icon) { try { final Icon icon = new IconWrap((Icon) value); if (icon.getIconHeight() <= 20) { label.setIcon(icon); } label.setText( String.format( "(%dx%d) %s)", icon.getIconWidth(), icon.getIconHeight(), label.getText())); } catch (Throwable e1) { // } return panel; } else if (value instanceof Border) { try { final Insets i = ((Border) value).getBorderInsets(null); label.setText( String.format( "[%d, %d, %d, %d] %s", i.top, i.left, i.bottom, i.right, label.getText())); return panel; } catch (Exception ignore) { } } return super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); } }); final JBScrollPane pane = new JBScrollPane(table); new TableSpeedSearch( table, new PairFunction<Object, Cell, String>() { @Nullable @Override public String fun(Object o, Cell cell) { return cell.column == 1 ? null : String.valueOf(o); } }); table.setShowGrid(false); final JPanel panel = new JPanel(new BorderLayout()); panel.add(pane, BorderLayout.CENTER); myTable = table; TableUtil.ensureSelectionExists(myTable); return panel; } }.show(); }
public FileTextFieldImpl( final JTextField field, Finder finder, LookupFilter filter, Map<String, String> macroMap, final Disposable parent) { myPathTextField = field; myMacroMap = new TreeMap<String, String>(); myMacroMap.putAll(macroMap); final InputMap listMap = (InputMap) UIManager.getDefaults().get("List.focusInputMap"); final KeyStroke[] listKeys = listMap.keys(); myDisabledTextActions = new HashSet<Action>(); for (KeyStroke eachListStroke : listKeys) { final String listActionID = (String) listMap.get(eachListStroke); if ("selectNextRow".equals(listActionID) || "selectPreviousRow".equals(listActionID)) { final Object textActionID = field.getInputMap().get(eachListStroke); if (textActionID != null) { final Action textAction = field.getActionMap().get(textActionID); if (textAction != null) { myDisabledTextActions.add(textAction); } } } } final FileTextFieldImpl assigned = (FileTextFieldImpl) myPathTextField.getClientProperty(KEY); if (assigned != null) { assigned.myFinder = finder; assigned.myFilter = filter; return; } myPathTextField.putClientProperty(KEY, this); final boolean headless = ApplicationManager.getApplication().isUnitTestMode(); myUiUpdater = new MergingUpdateQueue("FileTextField.UiUpdater", 200, false, myPathTextField); if (!headless) { new UiNotifyConnector(myPathTextField, myUiUpdater); } myFinder = finder; myFilter = filter; myFileSpitRegExp = myFinder.getSeparator().replaceAll("\\\\", "\\\\\\\\"); myPathTextField .getDocument() .addDocumentListener( new DocumentListener() { public void insertUpdate(final DocumentEvent e) { processTextChanged(); } public void removeUpdate(final DocumentEvent e) { processTextChanged(); } public void changedUpdate(final DocumentEvent e) { processTextChanged(); } }); myPathTextField.addKeyListener( new KeyAdapter() { public void keyPressed(final KeyEvent e) { processListSelection(e); } }); myPathTextField.addFocusListener( new FocusAdapter() { public void focusLost(final FocusEvent e) { closePopup(); } }); myCancelAction = new CancelAction(); new LazyUiDisposable<FileTextFieldImpl>(parent, field, this) { protected void initialize( @NotNull Disposable parent, @NotNull FileTextFieldImpl child, @Nullable Project project) { Disposer.register(child, myUiUpdater); } }; }