Insets (final @NotNull GraphicsConfiguration gc) { if (insetCache == null) { return calcInsets(gc); } synchronized (insetCache) { Pair<Insets, Long> data = insetCache.get(gc); long now = System.currentTimeMillis(); if (data == null || now > data.second + ourInsetsTimeout) { data = new Pair<>(calcInsets(gc), now); insetCache.put(gc, data); } return data.first; } }