Scroll Panel wird nicht hinzugefügt

hans-sonny

Bekanntes Mitglied
Hi Leute,

ich lade eine html Datei ein und geb sie aus, da die aber ewig lang ist möchte ich eine ScrollPane hizufügen ...

das funzt aber nicht keine exception nichts wird einfach nicht angezeigt

Java:
 private JFrame rulesFrame = new JFrame();
    private JEditorPane html;  
    
    /**
     * Displays the Uno Rules in a new JFrame
     * @throws IOException
     */
    public GuiRules() throws IOException{
        displayRules();
    }
    
    private void displayRules() throws IOException{
        loadRulesPanel();
        
        URL url = rules.ReturnRules.loadRules();
        this.html.setPage(url);  
    }
    
    private void loadRulesPanel(){
        this.rulesFrame.setTitle("UNO Help Screen");
        this.rulesFrame.setResizable(false);
        JPanel rulesPanel = new JPanel();
        rulesPanel.setPreferredSize(new Dimension(GuiStaticVars.getUnoWidth(),GuiStaticVars.getUnoHeight()));
        rulesFrame.add(rulesPanel);
        //Edior Panel
        this.html = new JEditorPane();
        this.html.setPreferredSize(new Dimension(GuiStaticVars.getUnoWidth(),GuiStaticVars.getUnoHeight()));
        this.html.setEditable(false);
        //Only body tag will be displayed
        this.html.setDoubleBuffered(true);
        this.html.addHyperlinkListener(this);
        //Scrollbar
        JScrollPane scroll = new JScrollPane();
        scroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        scroll.setPreferredSize(new Dimension(GuiStaticVars.getUnoHeight(),24));
        scroll.setViewportView(html);       
        rulesPanel.add(html);
        rulesPanel.add(scroll);
        //Publish
        this.rulesFrame.pack();
        Center.centerOnScreen(rulesFrame);
        this.rulesFrame.setVisible(true);
    }
 
fehlt da nicht iwo ein
Java:
add(rulesPanel);
bzw.
Java:
this.rulesFrame.add(rulesPanel);
??
 
Zuletzt bearbeitet:
Zeile 24 löschen und dann

[JAVA=38]rulesPanel.add(html);
scroll.add(rulesPanel); //anstelle von rulesPanel.add(scroll);
rulesFrame.add(scroll);
[/code]
 
Java:
private JFrame rulesFrame = new JFrame();
    private JEditorPane html;  
 private void displayRules() throws IOException{
        loadRulesPanel();
        
        URL url = rules.ReturnRules.loadRules();
        this.html.setPage(url);  
    }
    
    private void loadRulesPanel(){
        this.rulesFrame.setTitle("UNO Help Screen");
        this.rulesFrame.setResizable(false);
        JPanel rulesPanel = new JPanel();
        rulesPanel.setPreferredSize(new Dimension(GuiStaticVars.getUnoWidth(),GuiStaticVars.getUnoHeight()));
        //Edior Panel
        this.html = new JEditorPane();
        this.html.setPreferredSize(new Dimension(GuiStaticVars.getUnoWidth(),GuiStaticVars.getUnoHeight()));
        this.html.setEditable(false);
        //Only body tag will be displayed
        this.html.setDoubleBuffered(true);
        this.html.addHyperlinkListener(this);
        //Scrollbar
        JScrollPane scroll = new JScrollPane();
        scroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        scroll.setPreferredSize(new Dimension(GuiStaticVars.getScrollWidth(),GuiStaticVars.getUnoHeight()));
        scroll.setViewportView(html);       
        rulesPanel.add(html);
        scroll.add(rulesPanel);
        this.rulesFrame.add(scroll);
        //Publish
        this.rulesFrame.pack();
        Center.centerOnScreen(rulesFrame);
        this.rulesFrame.setVisible(true);
    }


so hab ichs jetzt ... aber jetzt wird mein html inhalt nicht mehr angezeigt
 

Zurück
Oben