001 /******************************************************************************
002 * Copyright (C) MActor Developers. All rights reserved. *
003 * ---------------------------------------------------------------------------*
004 * This file is part of MActor. *
005 * *
006 * MActor is free software; you can redistribute it and/or modify *
007 * it under the terms of the GNU General Public License as published by *
008 * the Free Software Foundation; either version 2 of the License, or *
009 * (at your option) any later version. *
010 * *
011 * MActor is distributed in the hope that it will be useful, *
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
014 * GNU General Public License for more details. *
015 * *
016 * You should have received a copy of the GNU General Public License *
017 * along with MActor; if not, write to the Free Software *
018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
019 ******************************************************************************/
020 /**
021 *
022 */
023 package org.mactor.ui.gui;
024
025 import java.awt.BorderLayout;
026 import java.awt.Font;
027
028 import javax.swing.JPanel;
029 import javax.swing.JTextArea;
030
031 import org.mactor.ui.gui.project.editors.TipListener;
032
033 public class TipPanel extends JPanel implements TipListener {
034 JTextArea tipText = new JTextArea(2, 40);
035 String tip1;
036 String tip2;
037 String tip3;
038 public TipPanel() {
039 super(new BorderLayout());
040 tipText.setBackground(getBackground());
041 tipText.setEditable(false);
042 tipText.setLineWrap(true);
043 tipText.setFont(tipText.getFont().deriveFont(Font.ITALIC));
044 add(tipText, BorderLayout.NORTH);
045 }
046 public void onTip(int tipLevel, String tip) {
047 String text = "";
048 if (tip == null)
049 tip = "";
050 if (tipLevel == 1) {
051 tip2 = null;
052 tip3 = null;
053 tip1 = tip;
054 text = tip;
055 } else if (tipLevel == 2) {
056 tip3 = null;
057 tip2 = tip;
058 if (tip1 != null && tip1.length() > 0)
059 text = tip1 + "\n\n";
060 text = text + tip;
061 } else if (tipLevel == 3) {
062 tip3 = tip;
063 if (tip1 != null && tip1.length() > 0)
064 text = tip1 + "\n\n";
065 if (tip2 != null && tip2.length() > 0)
066 text = text + tip2 + "\n\n";
067 text = text + tip;
068 }
069 tipText.setText("\n\n\n" + text);
070 }
071 }