[icedtea-web] RFC: add a description on top of the control panel

Deepak Bhole dbhole at redhat.com
Fri Dec 17 13:03:39 PST 2010


* Omair Majid <omajid at redhat.com> [2010-12-17 15:53]:
> Hi,
> 
> The attached patch adds a description to the top of the Control
> Panel. The attached image shows what the result of applying the
> patch looks like.
> 
> Thoughts?
> 

Looks fine to me. OK for HEAD.

Deepak

> ChangeLog:
> 2010-12-17  Omair Majid  <omajid at redhat.com>
> 
>     * netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
>     (ControlPanel): Create and add the topPanel.
>     (createTopPanel): New method. Creates a JPanel to display the
>     description on top of the Control Panel.
>     (createNotImplementedPanel): Use the same way to load resource
>     as createTopPanel to avoid null pointer exceptions.
>     * netx/net/sourceforge/jnlp/resources/Messages.properties: Add
>     CPMainDescriptionShort and CPMainDescriptionLong.
> 
> Cheers,
> Omair

> diff -r 9397074c2c39 netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java
> --- a/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java	Wed Dec 15 10:17:51 2010 -0500
> +++ b/netx/net/sourceforge/jnlp/controlpanel/ControlPanel.java	Fri Dec 17 15:18:26 2010 -0500
> @@ -18,10 +18,14 @@
>  
>  package net.sourceforge.jnlp.controlpanel;
>  
> +import static net.sourceforge.jnlp.runtime.Translator.R;
> +
>  import java.awt.BorderLayout;
>  import java.awt.CardLayout;
>  import java.awt.Dimension;
>  import java.awt.FlowLayout;
> +import java.awt.Font;
> +import java.awt.GridLayout;
>  import java.awt.Image;
>  import java.awt.event.ActionEvent;
>  import java.awt.event.ActionListener;
> @@ -41,6 +45,7 @@
>  import javax.swing.JScrollPane;
>  import javax.swing.SwingConstants;
>  import javax.swing.SwingUtilities;
> +import javax.swing.UIManager;
>  import javax.swing.WindowConstants;
>  import javax.swing.border.EmptyBorder;
>  import javax.swing.event.ListSelectionEvent;
> @@ -79,6 +84,7 @@
>              return panel;
>          }
>  
> +        @Override
>          public String toString() {
>              return value;
>          }
> @@ -104,17 +110,57 @@
>  
>          this.config = config;
>  
> +        JPanel topPanel = createTopPanel();
>          JPanel mainPanel = createMainSettingsPanel();
>          JPanel buttonPanel = createButtonPanel();
>  
> +        add(topPanel, BorderLayout.PAGE_START);
>          add(mainPanel, BorderLayout.CENTER);
> -        add(buttonPanel, BorderLayout.SOUTH);
> +        add(buttonPanel, BorderLayout.PAGE_END);
>          setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
>          pack();
>          setMinimumSize(getPreferredSize());
>          setResizable(false);
>      }
>  
> +    private JPanel createTopPanel() {
> +        Font currentFont = null;
> +        JLabel about = new JLabel(R("CPMainDescriptionShort"));
> +        currentFont = about.getFont();
> +        about.setFont(currentFont.deriveFont(currentFont.getSize2D() + 2));
> +        currentFont = about.getFont();
> +        about.setFont(currentFont.deriveFont(Font.BOLD));
> +
> +        JLabel description = new JLabel(R("CPMainDescriptionLong"));
> +        description.setBorder(new EmptyBorder(2, 0, 2, 0));
> +
> +        JPanel descriptionPanel = new JPanel(new GridLayout(0, 1));
> +        descriptionPanel.setBackground(UIManager.getColor("TextPane.background"));
> +        descriptionPanel.add(about);
> +        descriptionPanel.add(description);
> +
> +        JLabel image = new JLabel();
> +
> +        ClassLoader cl = getClass().getClassLoader();
> +        if (cl == null) {
> +            cl = ClassLoader.getSystemClassLoader();
> +        }
> +
> +        try {
> +            URL imgUrl = cl.getResource("net/sourceforge/jnlp/resources/netx-icon.png");
> +            image.setIcon(new ImageIcon(ImageIO.read(imgUrl)));
> +        } catch (IOException e) {
> +            e.printStackTrace();
> +        }
> +
> +        JPanel topPanel = new JPanel(new BorderLayout());
> +        topPanel.setBackground(UIManager.getColor("TextPane.background"));
> +        topPanel.add(descriptionPanel, BorderLayout.LINE_START);
> +        topPanel.add(image, BorderLayout.LINE_END);
> +        topPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
> +        return topPanel;
> +    }
> +
>      /**
>       * Creates the "ok" "apply" and "cancel" buttons.
>       * 
> @@ -273,7 +319,12 @@
>          JPanel notImplementedPanel = new NamedBorderPanel("Unimplemented");
>          notImplementedPanel.setLayout(new BorderLayout());
>  
> -        URL imgUrl = getClass().getClassLoader().getResource("net/sourceforge/jnlp/resources/warning.png");
> +        ClassLoader cl = getClass().getClassLoader();
> +        if (cl == null) {
> +            cl = ClassLoader.getSystemClassLoader();
> +        }
> +
> +        URL imgUrl = cl.getResource("net/sourceforge/jnlp/resources/warning.png");
>          Image img;
>          try {
>              img = ImageIO.read(imgUrl);
> diff -r 9397074c2c39 netx/net/sourceforge/jnlp/resources/Messages.properties
> --- a/netx/net/sourceforge/jnlp/resources/Messages.properties	Wed Dec 15 10:17:51 2010 -0500
> +++ b/netx/net/sourceforge/jnlp/resources/Messages.properties	Fri Dec 17 15:18:26 2010 -0500
> @@ -243,6 +243,10 @@
>  VVPossibleFileValues=include the absolute location of a file - it must begin with a /
>  VVPossibleRangedIntegerValues=are in range {0} to {1} (inclusive)
>  VVPossibleUrlValues=include any valid url (eg http://icedtea.classpath.org/hg/)
> +
> +# Control Panel - Main
> +CPMainDescriptionShort=Configure IcedTea-Web
> +CPMainDescriptionLong=Configure how the browser plugin (IcedTeaNPPlugin) and javaws (NetX) work
>  
>  # Control Panel - Tab Descriptions
>  CPAboutDescription=View version information about Icedtea Control Panel.





More information about the distro-pkg-dev mailing list