1 package de.java2html; 2 3 import java.awt.BorderLayout ; 4 import java.awt.Container ; 5 import java.awt.GridBagConstraints ; 6 import java.awt.GridBagLayout ; 7 import java.awt.GridLayout ; 8 9 import javax.swing.Box ; 10 import javax.swing.JApplet ; 11 import javax.swing.JFrame ; 12 import javax.swing.JLabel ; 13 import javax.swing.JPanel ; 14 15 import de.java2html.gui.DirectTextConversionPanel; 16 import de.java2html.gui.GuiTools; 17 import de.java2html.gui.IStatisticsView; 18 import de.java2html.gui.Java2HtmlOptionsPanel; 19 import de.java2html.javasource.JavaSourceStatistic; 20 21 49 public class Java2HtmlApplet extends JApplet { 50 private static final String EMPTY_STATISTICS_TEXT = "<html>-<br>-<br>-</html>"; 51 52 private JLabel lStatistics; 53 private Java2HtmlOptionsPanel optionsPanel; 54 55 58 public String getAppletInfo() { 59 return Version.getJava2HtmlAppletTitle(); 60 } 61 62 public void init() { 63 try { 64 javax.swing.SwingUtilities.invokeAndWait(new Runnable () { 65 public void run() { 66 createGui(); 67 } 68 }); 69 } 70 catch (Exception e) { 71 System.err.println("createGui didn't successfully complete"); } 73 } 74 75 private void createGui() { 76 GuiTools.setNativeLookAndFeel(); 77 optionsPanel = new Java2HtmlOptionsPanel(); 78 lStatistics = new JLabel (EMPTY_STATISTICS_TEXT); 79 80 final DirectTextConversionPanel directTextConversionPanel = new DirectTextConversionPanel( 81 optionsPanel, 82 new IStatisticsView() { 83 public void setStatistics(JavaSourceStatistic statistic) { 84 lStatistics.setText(statistic == null ? EMPTY_STATISTICS_TEXT : "<html>" 85 + statistic.getScreenString("<br>") 86 + "</html>"); 87 } 88 }); 89 90 JPanel statisticsPanel = GuiTools.createBorderedPanel("Statistics"); 91 statisticsPanel.add(lStatistics); 92 JPanel optionsPanelComponent = GuiTools.createBorderedPanel("Options"); 93 optionsPanelComponent.add(optionsPanel.getContent()); 94 95 JPanel eastPanel = new JPanel (new GridBagLayout ()); 96 final GridBagConstraints c1 = new GridBagConstraints (); 97 c1.fill = GridBagConstraints.HORIZONTAL; 98 c1.gridx = 0; 99 c1.anchor = GridBagConstraints.NORTHWEST; 100 eastPanel.add(optionsPanelComponent, c1); 101 eastPanel.add(statisticsPanel, c1); 102 c1.fill = GridBagConstraints.BOTH; 103 c1.weighty = 1.0; 104 eastPanel.add(Box.createVerticalGlue(), c1); 105 106 Container container = getContentPane(); 107 container.setLayout(new BorderLayout (4, 4)); 108 container.add(directTextConversionPanel.getContent(), BorderLayout.CENTER); 109 container.add(eastPanel, BorderLayout.EAST); 110 directTextConversionPanel.requestFocus(); 111 } 112 113 public void start() { 114 } 116 117 public void stop() { 118 } 120 121 public static void main(String [] args) { 122 JFrame appletFrame = new JFrame ("Applet viewer frame"); 124 125 appletFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 126 127 appletFrame.setLayout(new GridLayout ()); 129 130 Java2HtmlApplet myApplet = new Java2HtmlApplet(); 132 133 appletFrame.getContentPane().add(myApplet, BorderLayout.CENTER); 135 136 appletFrame.setSize(700, 420); 138 139 myApplet.init(); 141 142 myApplet.start(); 144 145 appletFrame.setVisible(true); 147 148 appletFrame.setResizable(false); 149 } 150 } | Popular Tags |