1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.Scrollable;
import javax.swing.SwingConstants;
public abstract class ZScrollContainer implements ItemListener, Scrollable {
private JScrollPane scroll;
protected JPanel panel;
protected Font comicsB20 = new Font("Comics Sans MS", Font.BOLD, 20);
protected Font comicsB30 = new Font("Comics Sans MS", Font.BOLD, 30);
protected Font comicsB40 = new Font("Comics Sans MS", Font.BOLD, 40);
protected Font arialB10 = new Font("Arial", Font.BOLD, 10);
protected Font arialB15 = new Font("Arial", Font.BOLD, 15);
protected Font arialB20 = new Font("Arial", Font.BOLD, 20);
protected Font arialP10 = new Font("Arial", Font. PLAIN, 10);
protected Font arialP15 = new Font("Arial", Font. PLAIN, 15);
protected Font arialP20 = new Font("Arial", Font.PLAIN, 20);
protected Font arialI10 = new Font("Arial", Font.ITALIC, 15);
protected Font arialI15 = new Font("Arial", Font. ITALIC, 15);
protected Font arialI20 = new Font("Arial", Font. ITALIC, 15);
protected Dimension dimension;
public ZScrollContainer(Dimension dim){
this.panel = new JPanel();
this.scroll = new JScrollPane();
this.scroll.setBackground(Color.white);
this.scroll.getVerticalScrollBar().setUnitIncrement(10); // Défilement molette plus rapide
this.dimension = dim;
this.dimension.width -= this.scroll.getVerticalScrollBarPolicy() + 6 ;
}
protected JScrollPane getPanel(){
this.scroll.setViewportView(this.panel);
return this.scroll;
}
protected abstract void initPanel();
} |
Partager