1/* 2 * Copyright 2001-2008 Artima, Inc. 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16package org.scalatest.tools 17 18import org.scalatest._ 19import javax.swing.JDialog 20import javax.swing.JFrame 21import javax.swing.SwingConstants 22import javax.swing.JPanel 23import javax.swing.JLabel 24import javax.swing.border.EmptyBorder 25import java.util.ResourceBundle 26import java.awt.GridLayout 27import java.awt.FlowLayout 28import java.awt.BorderLayout 29import java.awt.Font 30import java.awt.Color 31 32/** 33 * The About dialog box. 34 * 35 * @author Bill Venners 36 */ 37private[scalatest] class AboutJDialog(owner: JFrame, title: String) extends JDialog(owner, title) { 38 39 val name = Resources("AppName") 40 val copyright = Resources("AppCopyright") 41 val moreInfo = Resources("MoreInfo") 42 val url = Resources("AppURL") 43 val version = Resources("AppVersion") 44 val reason = Resources("Reason") 45 val trademarks = Resources("Trademarks") 46 val company = Resources("ArtimaInc") 47 val nameLabel = new JLabel(name, SwingConstants.CENTER) 48 val copyrightLabel = new JLabel(copyright, SwingConstants.CENTER) 49 val urlLabel = new JLabel(url, SwingConstants.CENTER) 50 val moreInfoLabel = new JLabel(moreInfo, SwingConstants.CENTER) 51 val versionLabel = new JLabel(version, SwingConstants.CENTER) 52 val reasonLabel = new JLabel(reason, SwingConstants.CENTER) 53 val trademarksLabel = new JLabel(trademarks, SwingConstants.CENTER) 54 val companyLabel = new JLabel(company, SwingConstants.CENTER) 55 56 nameLabel.setFont(new Font("SansSerif", Font.BOLD, 20)) 57 urlLabel.setFont(new Font("SansSerif", Font.PLAIN, 13)) 58 reasonLabel.setFont(new Font("SansSerif", Font.ITALIC, 13)) 59 companyLabel.setFont(new Font("SansSerif", Font.BOLD, 14)) 60 trademarksLabel.setFont(new Font("SansSerif", Font.PLAIN, 11)) 61 copyrightLabel.setFont(new Font("SansSerif", Font.PLAIN, 11)) 62 nameLabel.setForeground(new Color(0x00, 0x00, 0x66)) 63 versionLabel.setForeground(new Color(0x00, 0x00, 0x66)) 64 companyLabel.setForeground(new Color(0x00, 0x00, 0x66)) 65 66 val northJPanel = new JPanel 67 northJPanel.setLayout(new BorderLayout()) 68 northJPanel.add(nameLabel, BorderLayout.NORTH) 69 northJPanel.add(versionLabel, BorderLayout.SOUTH) 70 71 val centerBottomJPanel = new JPanel 72 centerBottomJPanel.setLayout(new GridLayout(2, 1)) 73 centerBottomJPanel.add(moreInfoLabel) 74 centerBottomJPanel.add(urlLabel) 75 76 val centerJPanel = new JPanel 77 centerJPanel.setLayout(new GridLayout(2, 1, 5, 5)) 78 centerJPanel.add(reasonLabel) 79 centerJPanel.add(centerBottomJPanel) 80 81 val copyrightTrademarkJPanel = new JPanel 82 copyrightTrademarkJPanel.setLayout(new GridLayout(2, 1)) 83 copyrightTrademarkJPanel.add(copyrightLabel) 84 copyrightTrademarkJPanel.add(trademarksLabel) 85 86 val aboutJPanel = new JPanel 87 aboutJPanel.setLayout(new BorderLayout(15, 15)) 88 aboutJPanel.add(northJPanel, BorderLayout.NORTH) 89 aboutJPanel.add(centerJPanel, BorderLayout.CENTER) 90 aboutJPanel.add(copyrightTrademarkJPanel, BorderLayout.SOUTH) 91 aboutJPanel.setBorder(new EmptyBorder(5, 5, 5, 5)) 92 getContentPane().setLayout(new BorderLayout()) 93 getContentPane().add("Center", aboutJPanel) 94 pack() 95} 96