Coverage Report - com.timjohnstondev.unitconverter.view.AboutPanel
 
Classes in this File Line Coverage Branch Coverage Complexity
AboutPanel
0%
0/52
0%
0/12
2
 
 1  
 /**
 2  
  * Copyright 2009 Timothy Johnston Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 3  
  * file except in compliance with the License. You may obtain a copy of the License at
 4  
  * 
 5  
  * http://www.apache.org/licenses/LICENSE-2.0
 6  
  * 
 7  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 8  
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 9  
  * specific language governing permissions and limitations under the License.
 10  
  */
 11  
 package com.timjohnstondev.unitconverter.view;
 12  
 
 13  
 import java.awt.Color;
 14  
 import java.awt.Component;
 15  
 import java.awt.FlowLayout;
 16  
 import java.awt.Font;
 17  
 import java.util.ResourceBundle;
 18  
 import javax.swing.BoxLayout;
 19  
 import javax.swing.JLabel;
 20  
 import javax.swing.JPanel;
 21  
 import javax.swing.JTextField;
 22  
 
 23  
 /**
 24  
  * This panel displays all of the information about this application including version, author and contact information.
 25  
  */
 26  
 public class AboutPanel extends JPanel implements Configuration
 27  
 {
 28  0
   private final ResourceBundle resources = ResourceBundle.getBundle("com.timjohnstondev.unitconverter.view.View");
 29  
 
 30  
   /**
 31  
    * Constructs an {@code AboutPanel}
 32  
    */
 33  
   AboutPanel()
 34  0
   {
 35  0
     setLayout(new FlowLayout(FlowLayout.LEFT, 12, 10));
 36  
 
 37  0
     final JPanel labels = createLabels();
 38  0
     final JPanel fields = createFields();
 39  
 
 40  0
     add(labels);
 41  0
     add(fields);
 42  0
   }
 43  
 
 44  
   private JPanel createLabels()
 45  
   {
 46  0
     final JPanel labels = new JPanel();
 47  0
     final JLabel programNameLabel = new JLabel(resources.getString("AboutPanel.programNameLabel"));
 48  0
     final JLabel authorLabel = new JLabel(resources.getString("AboutPanel.authorLabel"));
 49  0
     final JLabel emailLabel = new JLabel(resources.getString("AboutPanel.emailLabel"));
 50  0
     labels.setLayout(new BoxLayout(labels, BoxLayout.PAGE_AXIS));
 51  0
     labels.add(programNameLabel);
 52  0
     labels.add(authorLabel);
 53  0
     labels.add(emailLabel);
 54  0
     return labels;
 55  
   }
 56  
 
 57  
   private JPanel createFields()
 58  
   {
 59  0
     final JPanel fields = new JPanel();
 60  0
     final JLabel releasedField = new JLabel(resources.getString("AboutPanel.releasedField"));
 61  0
     releasedField.setFont(releasedField.getFont().deriveFont(Font.PLAIN));
 62  0
     final JLabel authorField = new JLabel(resources.getString("AboutPanel.authorField"));
 63  0
     authorField.setFont(releasedField.getFont().deriveFont(Font.PLAIN));
 64  0
     final JTextField emailField = new JTextField(resources.getString("AboutPanel.emailField"));
 65  0
     emailField.setEditable(false);
 66  0
     emailField.setBorder(null);
 67  0
     fields.setLayout(new BoxLayout(fields, BoxLayout.PAGE_AXIS));
 68  0
     fields.add(releasedField);
 69  0
     fields.add(authorField);
 70  0
     fields.add(emailField);
 71  
 
 72  0
     return fields;
 73  
   }
 74  
 
 75  
   @Override
 76  
   public final void setBackgroundColor(final Color color)
 77  
   {
 78  0
     setBackground(color);
 79  0
     final Component[] panels = getComponents();
 80  
 
 81  0
     for (Component panel : panels)
 82  
     {
 83  0
       panel.setBackground(color);
 84  0
       final Component[] children = ((JPanel) panel).getComponents();
 85  0
       for (Component child : children)
 86  
       {
 87  0
         child.setBackground(color);
 88  
       }
 89  
     }
 90  0
   }
 91  
 
 92  
   @Override
 93  
   public final void setFontSize(final float fontSize)
 94  
   {
 95  0
     final Component[] panels = getComponents();
 96  0
     for (Component panel : panels)
 97  
     {
 98  0
       final Component[] children = ((JPanel) panel).getComponents();
 99  0
       for (Component child : children)
 100  
       {
 101  0
         child.setFont(child.getFont().deriveFont(fontSize));
 102  
       }
 103  
     }
 104  0
   }
 105  
 
 106  
   @Override
 107  
   public final void setForegroundColor(final Color color)
 108  
   {
 109  0
     setForeground(color);
 110  0
     final Component[] panels = getComponents();
 111  
 
 112  0
     for (Component panel : panels)
 113  
     {
 114  0
       panel.setForeground(color);
 115  0
       final Component[] children = ((JPanel) panel).getComponents();
 116  0
       for (Component child : children)
 117  
       {
 118  0
         child.setForeground(color);
 119  
       }
 120  
     }
 121  0
   }
 122  
 }