Alguém pode me dizer o que já de errado com o meu JScrollBar?

0 respostas
netbeansjava
R

Ele já aparece na tela, mas ele não rola a tela como deveria, aqui está meu código:

import javax.swing.; //pacote do JFrame
import java.awt.
; //pacote do container

public class Qt1View extends JFrame{

//declarações
    public static Container ctnQt1;
    public static Container ctnPainel;
    
    //imagens
    public static ImageIcon imgQt1;
    public static JLabel qd1;
    public static JLabel descQt1;
    
    //texto
    
    public static JLabel desc1;
    
    //scroll
    
    public static JScrollBar scroll;
    public static JPanel painel;
    public static JButton btnScroll;
    public static Container ctnScroll;
    
    public static JLabel imgRandom;
    

//construtor
    
   
    
    public Qt1View(){
        
        
        
    //container    
    ctnQt1= new Container();
    ctnQt1.setLayout(null);
    this.add(ctnQt1);
    
    ctnPainel= new Container();
    ctnPainel.setLayout(new GridLayout(1,1));
    ctnQt1.add(ctnPainel,BorderLayout.EAST);
    //ctnQt1.add(ctnPainel);
    
    
    
    //imagem
    
    qd1= new JLabel();
    imgQt1= new ImageIcon("imagens/qt1.jpg");
    qd1.setBounds(340,60,1280,720);
    qd1.setIcon(imgQt1);
    ctnQt1.add(qd1);    
        
        
     //texto   
        
     desc1= new JLabel ("Quarto 1"); //aqui mais tarde editaremos com a descrição do quarto
     desc1.setBounds(340,800,100,100);
     desc1.setForeground(Color.white);
     desc1.setFont(new Font("Arial",1, 24));
     ctnQt1.add(desc1);
     
     //Painel
     
     painel= new JPanel();
     // painel.setSize(600,600);
    
     painel.setPreferredSize(new Dimension(15,600));
     painel.setVisible(true);
     ctnPainel.add(painel);
     
     
     
     
    
     
     //scroll
    
     scroll= new JScrollBar ();
     //scroll.setPreferredSize(new Dimension(45,600));
     
     
     ctnQt1.add(scroll);
     
     //button
     
     //btnScroll= new JButton("scroll");
     //btnScroll.setBounds(50,50,100,100);
     //painel.add(btnScroll);
     
     
     
    
     
     
     
     
     
        
        
        
        
        
        
   
    
    this.show();
    //this.getContentPane().add(painel,BorderLayout.EAST);
    this.getContentPane().add(scroll,BorderLayout.EAST);
    //this.getContentPane().add(ctnPainel,BorderLayout.EAST);
    
    this.getContentPane().setBackground(Color.black);
    this.setSize(600,600);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
    
        
        
    }

}

Criado 5 de outubro de 2018
Respostas 0
Participantes 1