1*9a1eeea9SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9a1eeea9SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9a1eeea9SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9a1eeea9SAndrew Rist * distributed with this work for additional information 6*9a1eeea9SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9a1eeea9SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9a1eeea9SAndrew Rist * "License"); you may not use this file except in compliance 9*9a1eeea9SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9a1eeea9SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9a1eeea9SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9a1eeea9SAndrew Rist * software distributed under the License is distributed on an 15*9a1eeea9SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9a1eeea9SAndrew Rist * KIND, either express or implied. See the License for the 17*9a1eeea9SAndrew Rist * specific language governing permissions and limitations 18*9a1eeea9SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9a1eeea9SAndrew Rist *************************************************************/ 21*9a1eeea9SAndrew Rist 22*9a1eeea9SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package org.openoffice.setup.PanelHelper; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import java.awt.ComponentOrientation; 27cdf0e10cSrcweir import java.awt.FlowLayout; 28cdf0e10cSrcweir import javax.swing.Box; 29cdf0e10cSrcweir import javax.swing.BoxLayout; 30cdf0e10cSrcweir import javax.swing.JLabel; 31cdf0e10cSrcweir import javax.swing.JPanel; 32cdf0e10cSrcweir import javax.swing.JSeparator; 33cdf0e10cSrcweir import org.openoffice.setup.InstallData; 34cdf0e10cSrcweir 35cdf0e10cSrcweir public class PanelTitle extends Box { 36cdf0e10cSrcweir 37cdf0e10cSrcweir private JLabel TitleLabel; 38cdf0e10cSrcweir PanelTitle()39cdf0e10cSrcweir public PanelTitle() { 40cdf0e10cSrcweir super(BoxLayout.PAGE_AXIS); 41cdf0e10cSrcweir } 42cdf0e10cSrcweir PanelTitle(String title, String subtitle, int rows, int columns)43cdf0e10cSrcweir public PanelTitle(String title, String subtitle, int rows, int columns) { 44cdf0e10cSrcweir super(BoxLayout.PAGE_AXIS); 45cdf0e10cSrcweir init(title, subtitle, rows, columns); 46cdf0e10cSrcweir } 47cdf0e10cSrcweir PanelTitle(String title, String subtitle)48cdf0e10cSrcweir public PanelTitle(String title, String subtitle) { 49cdf0e10cSrcweir super(BoxLayout.PAGE_AXIS); 50cdf0e10cSrcweir init(title, subtitle, 0, 0); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir PanelTitle(String title)53cdf0e10cSrcweir public PanelTitle(String title) { 54cdf0e10cSrcweir super (BoxLayout.PAGE_AXIS); 55cdf0e10cSrcweir init(title, null, 0, 0); 56cdf0e10cSrcweir } 57cdf0e10cSrcweir addVerticalStrut(int strut)58cdf0e10cSrcweir public void addVerticalStrut(int strut) { 59cdf0e10cSrcweir add(createVerticalStrut(strut)); 60cdf0e10cSrcweir } 61cdf0e10cSrcweir setTitle(String title)62cdf0e10cSrcweir public void setTitle(String title) { 63cdf0e10cSrcweir TitleLabel.setText(title); 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir // public void setSubtitle(String subtitle) { 67cdf0e10cSrcweir // SubtitleLabel.setText(subtitle); 68cdf0e10cSrcweir // } 69cdf0e10cSrcweir init(String title, String subtitle, int rows, int columns)70cdf0e10cSrcweir private void init(String title, String subtitle, int rows, int columns) { 71cdf0e10cSrcweir 72cdf0e10cSrcweir InstallData data = InstallData.getInstance(); 73cdf0e10cSrcweir 74cdf0e10cSrcweir TitleLabel = new JLabel(title); 75cdf0e10cSrcweir TitleLabel.setFocusable(false); 76cdf0e10cSrcweir JPanel TitlePanel = new JPanel(); 77cdf0e10cSrcweir if ( data.useRtl() ) { 78cdf0e10cSrcweir TitlePanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); 79cdf0e10cSrcweir TitleLabel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 80cdf0e10cSrcweir } else { 81cdf0e10cSrcweir TitlePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir TitlePanel.add(TitleLabel); 84cdf0e10cSrcweir 85cdf0e10cSrcweir add(createVerticalStrut(10)); 86cdf0e10cSrcweir add(TitlePanel); 87cdf0e10cSrcweir add(createVerticalStrut(10)); 88cdf0e10cSrcweir add(new JSeparator()); 89cdf0e10cSrcweir add(createVerticalStrut(20)); 90cdf0e10cSrcweir 91cdf0e10cSrcweir if (subtitle != null) { 92cdf0e10cSrcweir PanelLabel SubtitleLabel = null; 93cdf0e10cSrcweir if ( rows > 0 ) { 94cdf0e10cSrcweir SubtitleLabel = new PanelLabel(subtitle, rows, columns ); 95cdf0e10cSrcweir } else { 96cdf0e10cSrcweir SubtitleLabel = new PanelLabel(subtitle); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir SubtitleLabel.setFocusable(false); 99cdf0e10cSrcweir // PanelLabel SubtitleLabel = new PanelLabel(subtitle, true); 100cdf0e10cSrcweir JPanel SubtitlePanel = new JPanel(); 101cdf0e10cSrcweir if ( data.useRtl() ) { 102cdf0e10cSrcweir SubtitlePanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); 103cdf0e10cSrcweir SubtitleLabel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); 104cdf0e10cSrcweir } else { 105cdf0e10cSrcweir SubtitlePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir SubtitlePanel.add(SubtitleLabel); 108cdf0e10cSrcweir 109cdf0e10cSrcweir add(SubtitlePanel); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir } 112cdf0e10cSrcweir }