当前位置: 代码迷 >> Java相关 >> 怎么显示不出来?
  详细解决方案

怎么显示不出来?

热度:158   发布时间:2008-03-16 21:54:27.0
怎么显示不出来?
public void init(){
        this.setSize(new Dimension(300, 379));
        this.setLocation(500,100);
        cp = getContentPane();
        cp.setLayout(null);
        panel = new JPanel();
        cp.add(panel);
        lyricsPanel = new JTextPane();
        lyricsPanel.setSize(new Dimension(300,379));
        lyricsPanel.setBackground(Color.WHITE);
        panel.add(lyricsPanel);
    
        
        lyricsPanel.setText("dsdsadasdas");
        this.setResizable(false);
        this.setVisible(true);
    }
搜索更多相关的解决方案: lyricsPanel  panel  new  Dimension  WHITE  

----------------解决方案--------------------------------------------------------
public void init(){
        this.setSize(new Dimension(300, 379));
        this.setLocation(500,100);
        cp = getContentPane();
        cp.setLayout(null);
        //panel = new JPanel();
        //cp.add(panel);
        lyricsPanel = new JTextPane();
        lyricsPanel.setSize(new Dimension(300,379));
        lyricsPanel.setBackground(Color.WHITE);
        cp.add(lyricsPanel);
        scrollPanel = new JScrollPane(lyricsPanel);
        cp.add(scrollPanel);
    
        
        lyricsPanel.setText("dsdsadasdas");
        this.setResizable(false);
        this.setVisible(true);
    }

还有这样的话就什么都显示不出来了!
----------------解决方案--------------------------------------------------------
你把你程序写完整可以帮你看看啊..
----------------解决方案--------------------------------------------------------
public class LyricsUI extends JFrame {
    private Container cp;

    
    private JTextPane lyricsPanel = new JTextPane();
    
    private JPanel panel;
    
    private JScrollPane scrollPanel;
    
    
    public LyricsUI(){
        super();
        init();
    }
    
    
    public void init(){
        this.setSize(new Dimension(300, 379));
        this.setLocation(500,100);
        cp = getContentPane();
        cp.setLayout(null);
        panel = new JPanel();
        cp.add(panel,BorderLayout.NORTH);
        lyricsPanel = new JTextPane();
        lyricsPanel.setSize(new Dimension(300,379));
        lyricsPanel.setBackground(Color.WHITE);
        //cp.add(lyricsPanel);
        //scrollPanel = new JScrollPane(lyricsPanel);
        //cp.add(scrollPanel);
        panel.add(lyricsPanel);
        
        //scrollPanel = new JScrollPane();
        //scrollPanel.getViewport().add(lyricsPanel, null);
        //scrollPanel.insertComponent(lyricsPanel);
    
        
        lyricsPanel.setText("dsdsadasdas");
        //lyricsPanel.setText(this.test().getText());
        this.setResizable(false);
        this.setVisible(true);
    }
    
    
    public Lyrics test(){
        Lyrics l = new Lyrics();
        File f = new File("C:\\KuGoo\\Lyrics\\李圣杰 - Angel.lrc");
        Lyrics ll = l.read(f);
        return ll;
    }
    
    public static void main(String[] args) {
        
        new LyricsUI();

    }

}
----------------解决方案--------------------------------------------------------
怎么才能把歌词完整的读出来
----------------解决方案--------------------------------------------------------
加入scrollPanel
----------------解决方案--------------------------------------------------------
怎么加都加不进去啊!
----------------解决方案--------------------------------------------------------
你加的顺序有问题。。从小到大加。。
----------------解决方案--------------------------------------------------------
public void init(){
        this.setSize(new Dimension(300, 379));
        this.setLocation(500,100);
        cp = getContentPane();
        //cp.setLayout(null);
        
        lyricsPanel = new JTextPane();
        lyricsPanel.setSize(new Dimension(300,379));
        lyricsPanel.setBackground(Color.WHITE);
        lyricsPanel.setText("dsdsadasdas");
       // cp.add(lyricsPanel,BorderLayout.NORTH);
        //scrollPanel = new JScrollPane(lyricsPanel);
        //cp.add(scrollPanel);
        panel = new JPanel();
        panel.add(lyricsPanel);
        
        //scrollPanel = new JScrollPane();
        //scrollPanel.getViewport().add(lyricsPanel, null);
        //scrollPanel.insertComponent(lyricsPanel);
   
        
        
        //lyricsPanel.setText(this.test().getText());
        
        cp.add(panel,BorderLayout.NORTH);
        this.setResizable(false);
        this.setVisible(true);
    }
----------------解决方案--------------------------------------------------------
为什么不要布局管理器!
----------------解决方案--------------------------------------------------------
  相关解决方案