1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package org.openoffice.setup.PanelHelper; 29 30 import java.awt.ComponentOrientation; 31 import java.awt.FlowLayout; 32 import javax.swing.Box; 33 import javax.swing.BoxLayout; 34 import javax.swing.JLabel; 35 import javax.swing.JPanel; 36 import javax.swing.JSeparator; 37 import org.openoffice.setup.InstallData; 38 39 public class PanelTitle extends Box { 40 41 private JLabel TitleLabel; 42 43 public PanelTitle() { 44 super(BoxLayout.PAGE_AXIS); 45 } 46 47 public PanelTitle(String title, String subtitle, int rows, int columns) { 48 super(BoxLayout.PAGE_AXIS); 49 init(title, subtitle, rows, columns); 50 } 51 52 public PanelTitle(String title, String subtitle) { 53 super(BoxLayout.PAGE_AXIS); 54 init(title, subtitle, 0, 0); 55 } 56 57 public PanelTitle(String title) { 58 super (BoxLayout.PAGE_AXIS); 59 init(title, null, 0, 0); 60 } 61 62 public void addVerticalStrut(int strut) { 63 add(createVerticalStrut(strut)); 64 } 65 66 public void setTitle(String title) { 67 TitleLabel.setText(title); 68 } 69 70 // public void setSubtitle(String subtitle) { 71 // SubtitleLabel.setText(subtitle); 72 // } 73 74 private void init(String title, String subtitle, int rows, int columns) { 75 76 InstallData data = InstallData.getInstance(); 77 78 TitleLabel = new JLabel(title); 79 TitleLabel.setFocusable(false); 80 JPanel TitlePanel = new JPanel(); 81 if ( data.useRtl() ) { 82 TitlePanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); 83 TitleLabel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 84 } else { 85 TitlePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 86 } 87 TitlePanel.add(TitleLabel); 88 89 add(createVerticalStrut(10)); 90 add(TitlePanel); 91 add(createVerticalStrut(10)); 92 add(new JSeparator()); 93 add(createVerticalStrut(20)); 94 95 if (subtitle != null) { 96 PanelLabel SubtitleLabel = null; 97 if ( rows > 0 ) { 98 SubtitleLabel = new PanelLabel(subtitle, rows, columns ); 99 } else { 100 SubtitleLabel = new PanelLabel(subtitle); 101 } 102 SubtitleLabel.setFocusable(false); 103 // PanelLabel SubtitleLabel = new PanelLabel(subtitle, true); 104 JPanel SubtitlePanel = new JPanel(); 105 if ( data.useRtl() ) { 106 SubtitlePanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); 107 SubtitleLabel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 108 } else { 109 SubtitlePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 110 } 111 SubtitlePanel.add(SubtitleLabel); 112 113 add(SubtitlePanel); 114 } 115 } 116 }