001 package de.java2html;
002
003 import java.awt.BorderLayout;
004 import java.awt.FlowLayout;
005 import java.awt.event.ActionEvent;
006 import java.awt.event.ActionListener;
007
008 import javax.swing.Box;
009 import javax.swing.JButton;
010 import javax.swing.JFrame;
011 import javax.swing.JPanel;
012 import javax.swing.JTabbedPane;
013
014 import de.java2html.gui.DirectTextConversionPanel;
015 import de.java2html.gui.FileConversionPanel;
016 import de.java2html.gui.GuiTools;
017 import de.java2html.gui.IStatisticsView;
018 import de.java2html.gui.Java2HtmlOptionsPanel;
019 import de.java2html.javasource.JavaSourceStatistic;
020
021 /**
022 * Main application for the Java2Html converter.
023 *
024 * For questions, suggestions, bug-reports, enhancement-requests etc. I may be
025 * contacted at: <a href="mailto:markus@jave.de">markus@jave.de</a>
026 *
027 * The Java2html home page is located at: <a href="http://www.java2html.de">
028 * http://www.java2html.de</a>
029 *
030 * @author <a href="mailto:markus@jave.de">Markus Gebhard</a>
031 * @version 2.1, 06/30/02
032 *
033 * Copyright (C) Markus Gebhard 2000-2002
034 *
035 * This program is free software; you can redistribute it and/or modify it
036 * under the terms of the GNU General Public License as published by the Free
037 * Software Foundation; either version 2 of the License, or (at your option)
038 * any later version.
039 *
040 * This program is distributed in the hope that it will be useful, but WITHOUT
041 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
042 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
043 * more details.
044 *
045 * You should have received a copy of the GNU General Public License along with
046 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
047 * Place - Suite 330, Boston, MA 02111-1307, USA.
048 */
049 public class Java2HtmlApplication {
050
051 private final JFrame frame;
052
053 private final JButton bExit;
054 private final Java2HtmlOptionsPanel optionsPanel = new Java2HtmlOptionsPanel();
055
056 public Java2HtmlApplication() {
057 final JTabbedPane tabbedPane = new JTabbedPane();
058 tabbedPane.addTab("File Conversion", new FileConversionPanel(optionsPanel).getContent());
059 tabbedPane.addTab("Direct Text Conversion", new DirectTextConversionPanel(
060 optionsPanel,
061 new IStatisticsView() {
062 public void setStatistics(JavaSourceStatistic statistic) {
063 //nothing to do
064 }
065 }).getContent());
066
067 bExit = new JButton("Exit");
068 bExit.addActionListener(new ActionListener() {
069 public void actionPerformed(ActionEvent evt) {
070 System.exit(0);
071 }
072 });
073
074 final JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
075 southPanel.add(bExit);
076
077 final JPanel pOptions = GuiTools.createBorderedPanel("Options");
078 pOptions.setLayout(new BorderLayout());
079 pOptions.add(optionsPanel.getContent(), BorderLayout.CENTER);
080
081 final JPanel p = new JPanel(new BorderLayout());
082 p.add(pOptions, BorderLayout.NORTH);
083 p.add(Box.createVerticalGlue(), BorderLayout.CENTER);
084
085 frame = new JFrame(Version.getJava2HtmlConverterTitle());
086 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
087 frame.getContentPane().setLayout(new BorderLayout(4, 4));
088 frame.getContentPane().add(p, BorderLayout.EAST);
089 frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
090 frame.getContentPane().add(southPanel, BorderLayout.SOUTH);
091 }
092
093 private void show() {
094 frame.pack();
095 GuiTools.centerOnScreen(frame);
096 frame.setVisible(true);
097 }
098
099 public static void main(String args[]) {
100 if (args != null && args.length > 0) {
101 Java2Html.main(args);
102 return;
103 }
104 GuiTools.setNativeLookAndFeel();
105 final Java2HtmlApplication application = new Java2HtmlApplication();
106 application.show();
107 }
108 }
|