aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/launcher/ChangeJVMFrame.java
blob: 8f839da342375319f653e873eb7a5db84a3775d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.java.sip.communicator.launcher;

import java.awt.*;

import javax.swing.*;
import javax.swing.event.*;

/**
 * The <tt>ChangeJVMFrame</tt> will ask the user to install the newest java
 * version if she's using an old and incompatible one.
 *
 * @author Yana Stamcheva
 */
public class ChangeJVMFrame
    extends JFrame
{
    /**
     * Serial version UID.
     */
    private static final long serialVersionUID = 0L;

    /**
     * The MacOSX operating system.
     */
    public static final String MAC_OSX = "MacOSX";

    /**
     * The Windows operating system.
     */
    public static final String WINDOWS = "Windows";

    /**
     * The Linux operating system.
     */
    public static final String LINUX = "Linux";

    private JTextArea textArea = new JTextArea();

    private JEditorPane javaLinkPane = new JEditorPane();

    private String text = "Sorry. Your Java version is too old. The minimum"
        + " Java version required is 1.6. Please folow the link below to install"
        + " the newest version for your environment.";

    private String defaultLink = "<a href=\"https://www.java.com/inc/"
        + "BrowserRedirect1.jsp?locale=en\">Download Java</a>";

    private JPanel mainPanel = new JPanel(new BorderLayout());

    /**
     * Initializes new frame that will ask the user to install the newest java
     * version if she's using an old and incompatible one.
     *
     * @param osName OS name
     */
    public ChangeJVMFrame(String osName)
    {
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        this.setTitle("Jitsi requirements");

        this.mainPanel.setPreferredSize(
            new Dimension(450, 150));

        this.mainPanel.setBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10));

        this.textArea.setOpaque(false);
        this.textArea.setLineWrap(true);
        this.textArea.setWrapStyleWord(true);
        this.textArea.setText(text);
        this.textArea.setEditable(false);

        this.javaLinkPane.setOpaque(false);
        this.javaLinkPane.setContentType("text/html");
        this.javaLinkPane.setEditable(false);

        this.javaLinkPane.setText(defaultLink);

        this.javaLinkPane.addHyperlinkListener(new HyperlinkListener()
        {
            public void hyperlinkUpdate(HyperlinkEvent e)
            {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
                    new BrowserLauncher().openURL(e.getDescription());
            }
        });

        this.mainPanel.add(textArea, BorderLayout.NORTH);
        this.mainPanel.add(javaLinkPane, BorderLayout.CENTER);

        this.getContentPane().add(mainPanel);

        this.pack();
    }
}