-2

This what shows up in Eclipse when testing: Eclipse applet runner

And this is what show up in Firefox/Chrome browser, when I launch it as applet: Running in Firefox/Chrome browser

HTML code:

<APPLET code='GUI.MainMenu.class' archive = 'Finance.jar'width="800" height="623"></APPLET>

In java, everything below main menu (Library, Scheduler and other buttons on top) is in ContentPane variable (JPanel). When applet loads, first loads Library (extends JPanel) class which shows those tables and etc.

So it looks like browser can't reach that Library.class, but in jar it is in its place. Have any ideas?

P.S. MainMenu.class (main class) is in GUI package, but Library.class is in GUI.Library package

SSCCE: Main class

public MainMenu() {
    super();
    initGUI();
}

private void initGUI() {
    try {
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setSize(windowWidth, windowHeight + menuHeight);
        this.setPreferredSize(new java.awt.Dimension(windowWidth, windowHeight + menuHeight));
        this.setMinimumSize(new java.awt.Dimension(800, 623));
        {
            MenuPane = new JPanel();
            AnchorLayout MenuPaneLayout = new AnchorLayout();
            MenuPane.setLayout(MenuPaneLayout);
            getContentPane().add(MenuPane, BorderLayout.NORTH);
            MenuPane.setPreferredSize(new java.awt.Dimension(windowWidth, menuHeight));
            MenuPane.setMinimumSize(new java.awt.Dimension(windowWidth, menuHeight));
            {
                MLibrary = new JButton();
                MenuPane.add(MLibrary, new AnchorConstraint(0, 0, 0, 0, AnchorConstraint.ANCHOR_ABS, AnchorConstraint.ANCHOR_NONE, AnchorConstraint.ANCHOR_ABS, AnchorConstraint.ANCHOR_ABS));
                MLibrary.setText("Library");
                MLibrary.setPreferredSize(buttonSize);
                MLibrary.addActionListener(this);
                MLibrary.getModel().setPressed(true);
            }
            {
            //adds other main menu buttons by anchor..
            }
        }
        {
            renewContentPane(new Library());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
private void renewContentPane(JPanel pane) {
    if (ContentPane != null) {
        getContentPane().remove(ContentPane);
    }
    ContentPane = pane;
    getContentPane().add(ContentPane, BorderLayout.SOUTH);
    getContentPane().validate();
}

Library class:

public Library() {
    super();
    initGUI();
}

private void initGUI() {
    try {
        GridBagLayout thisLayout = new GridBagLayout();
        setPreferredSize(new Dimension(800, 600));
        thisLayout.rowWeights = new double[] {0.0, 0.0, 0.1};
        thisLayout.rowHeights = new int[] {35, 529, 7};
        thisLayout.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.1};
        thisLayout.columnWidths = new int[] {85, 85, 85, 85, 85, 7};
        this.setLayout(thisLayout);
        {
        //adds account label and buttons
        }
        {//table of transactions
            tableTrans = new JTable(new LibraryTableModel());
            JScrollPane tableScroll = new JScrollPane(tableTrans);
            this.add(tableScroll, new GridBagConstraints(2, 0, 4, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            tableScroll.setPreferredSize(new Dimension(610, 545));//630x565
            //tableTrans.setDefaultRenderer(Class.forName( "java.lang.String" ), new LibraryTableCellRenderer());
            tableTrans.getColumnModel().getColumn(0).setMaxWidth(15);
            tableTrans.getColumnModel().getColumn(4).setCellRenderer(new NumberFormatRenderer());
            //tableTrans.getColumnModel().getColumn(0).setMaxWidth(15);
        }
        {//table of accounts
            tableAccounts = new JTable(new AccountsTableModel());
            JScrollPane accTableScroll = new JScrollPane(tableAccounts);
            this.add(accTableScroll, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            tableAccounts.setTableHeader(null);
            //tableAccounts.setShowGrid(false);
            tableAccounts.getColumnModel().getColumn(0).setMaxWidth(25);
            tableAccounts.setRowHeight(25);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Paulius Vindzigelskis
  • 2,121
  • 6
  • 29
  • 41
  • Are any error/exception messages produced? – Hovercraft Full Of Eels Dec 31 '11 at 13:21
  • Where can i look at them? Eclipse console doesn't show any, but in browser I don't know where to look at. I tried in Firefox look at Tools->Web Developer -> Web console and Error console, but they doesn't show any exceptions – Paulius Vindzigelskis Dec 31 '11 at 13:47
  • @HovercraftFullOfEels : How can i see browser console? I have firefox and chrome, so any of those browsers consoles would help. Thanks – Paulius Vindzigelskis Dec 31 '11 at 14:03
  • I don't do applets and so don't know from first hand the answer to this, but Google suggests that you check out [this post](http://www.google.com/support/forum/p/Chrome/thread?tid=606c4e788d6b4b08&hl=en) on the Chrome support site, especially david_dawkins' reply. – Hovercraft Full Of Eels Dec 31 '11 at 14:47
  • 1
    Does the applet use layouts? Does it call validate? Does it construct the GUI on the EDT? Does it call `setSize(int,int)`? For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson Dec 31 '11 at 15:45
  • @AndrewThompson I edited my main description of problem to see code I used. Maybe now you can help, but I think problem is in exporting as JAR, because as I said, everything looks launched except that Library class which is JPanel. – Paulius Vindzigelskis Jan 02 '12 at 19:10
  • *"SSCCE: Main class"* An SSCCE does not have a 'main class' so much as an 'only class'. There are lots of other things that make that code 'not an SSCCE'. Please read the document before posting more code that you claim is an SSCCE. As an aside, in what Jar(s) are classes like `AnchorLayout` & `Library` stored? – Andrew Thompson Jan 03 '12 at 00:54
  • @AndrewThompson all used classes are stored in same single Jar, but in different package. P.S. I meant project Main class, from which applet launches, not specially SSCCE, like it wasn't obvious. I wrote them separate, because they are in different package. Main class is in gui, and Library is in gui.library package – Paulius Vindzigelskis Jan 03 '12 at 12:38
  • *"not specially SSCCE, like it wasn't obvious."* The term SSCCE is a very specific term and *obviously not* 'bits and pieces of code'. – Andrew Thompson Jan 03 '12 at 12:56

1 Answers1

0
<APPLET code='GUI.MainMenu.class' archive = 'Finance.jar'width="800" height="623">
</APPLET>

There seems a space to be missing after jar' and width.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • I fixed it right after I saw it days ago, so there is no problem. Also, if there were a problem, then applet would not have been launched, but now it works, but not fully – Paulius Vindzigelskis Jan 02 '12 at 20:18
  • Maybe a lifecycle problem: `init/destroy` and `start/stop`, which in the applet viewer was no problem? Also "GUI" in code makes me wonder whether that is an unconventionally capitalized package name, or a class with an inner class MainMenu without package statement. By the way validate/repaint works slightly different in an Applet; you could experiment with that locally. – Joop Eggen Jan 02 '12 at 20:25
  • Forget my previous comment (rumblings); try to add your Library panel with BorderLayout.CENTER. My comment on validate/revalidate/repaint still holds. – Joop Eggen Jan 02 '12 at 20:42