Браузер не показывает полный JApplet - PullRequest
0 голосов
/ 31 декабря 2011

Это то, что появляется в Eclipse при тестировании: Eclipse applet runner

И это то, что появляется в браузере Firefox / Chrome, когда я запускаю его как апплет: Running in Firefox/Chrome browser

HTMLcode:

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

В java все, что находится под главным меню (библиотека, планировщик и другие кнопки сверху), находится в переменной ContentPane (JPanel).Когда апплет загружается, сначала загружается класс Library (расширяет JPanel), который показывает эти таблицы и т. Д.

Похоже, что браузер не может добраться до этого Library.class, но в jar он на своем месте.Есть идеи?

PS MainMenu.class (основной класс) находится в пакете GUI, но Library.class находится в пакете GUI.Library

SSCCE: Основной класс

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();
}

Библиотечный класс:

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();
    }
}

1 Ответ

0 голосов
/ 03 января 2012
<APPLET code='GUI.MainMenu.class' archive = 'Finance.jar'width="800" height="623">
</APPLET>

Кажется, что пробел пропущен после jar' и width.

...