IDEA-17650 Splash screen is too agressive on Linux - set focusable state to false
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ui / Splash.java
blobea69926b90161c282ce01d0eb6d8f9571df63994
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.ui;
18 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
19 import com.intellij.openapi.util.IconLoader;
20 import com.intellij.util.ui.UIUtil;
22 import javax.swing.*;
23 import java.awt.*;
25 public class Splash extends JDialog {
26 private final Icon myImage;
27 private final JLabel myLabel;
29 public Splash(String imageName, final Color textColor) {
30 setUndecorated(true);
31 setResizable(false);
32 setModal(false);
33 setFocusableWindowState(false);
35 Icon originalImage = IconLoader.getIcon(imageName);
36 myImage = new MyIcon(originalImage, textColor);
37 myLabel = new JLabel(myImage);
38 Container contentPane = getContentPane();
39 contentPane.setLayout(new BorderLayout());
40 contentPane.add(myLabel, BorderLayout.CENTER);
41 Dimension size = getPreferredSize();
42 setSize(size);
43 pack();
44 setLocationRelativeTo(null);
47 public void show() {
48 super.show();
49 toFront();
50 myLabel.paintImmediately(0, 0, myImage.getIconWidth(), myImage.getIconHeight());
53 public static boolean showLicenseeInfo(Graphics g, int x, int y, final int height, final Color textColor) {
54 if (ApplicationInfoImpl.getShadowInstance().showLicenseeInfo()) {
55 g.setFont(new Font(UIUtil.ARIAL_FONT_NAME, Font.BOLD, 11));
56 g.setColor(textColor);
57 LicenseeInfoProvider provider = LicenseeInfoProvider.getInstance();
58 if (provider != null) {
59 g.drawString(provider.getLicensedToMessage(), x + 20, y + height - 52);
60 g.drawString(provider.getLicenseRestrictionsMessage(), x + 20, y + height - 32);
62 return true;
64 return false;
67 private static final class MyIcon implements Icon {
68 private final Icon myOriginalIcon;
69 private final Color myTextColor;
71 public MyIcon(Icon originalIcon, Color textColor) {
72 myOriginalIcon = originalIcon;
73 myTextColor = textColor;
76 public void paintIcon(Component c, Graphics g, int x, int y) {
77 yeild();
78 myOriginalIcon.paintIcon(c, g, x, y);
80 showLicenseeInfo(g, x, y, getIconHeight(), myTextColor);
83 private static void yeild() {
84 try {
85 Thread.sleep(10);
87 catch (InterruptedException e) {
91 public int getIconWidth() {
92 return myOriginalIcon.getIconWidth();
95 public int getIconHeight() {
96 return myOriginalIcon.getIconHeight();