IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Agents de placement/Fenêtres Java Discussion :

JScrollBar avec un bouton de plus


Sujet :

Agents de placement/Fenêtres Java

  1. #1
    Membre expérimenté
    Profil pro
    Inscrit en
    Février 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 197
    Par défaut JScrollBar avec un bouton de plus
    Bonjour,

    J'aimerai savoir comment rajouter un bouton en dessous et en dessus d'une JScrollBar.

    J'ai essayé d'étendre la JScrollBar et d'y rajouter un composant et j'ai fait pas mal de tests et de recherches mais je n'ai rien trouvé.

    le but serait d'y rajouter un bouton soit avec un listener personnalisé en haut et en bas. (par exemple rajouter un bouton pour aller tout en bas ou tout en haut, mais directement intégré dans le composant)

    le but serait donc de pouvoir y définir un listener qu'on y ajouterais par la suite ou simplement le composant en question qui lui pourrait contenir un listener (mais je préfèrerais l'option du listener directement sur la JScrollBar).

    par exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    public class MyScrollBar extends JScrollBar {
     
    	ScrollBarListener sbl;
    	public MyScrollBar() {}
     
    	public void addButtonListener(ScrollBarListener sbl) {}
    }
    (pour le listener aucun problème c'est juste pour montrer comment j'aimerai faire ma class)

    Si quelqu'un peut m'aider je l'en remercie

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 483
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 483
    Par défaut
    Le plus simple serait d'étendre un JPanel, tu y mettrait alors la scrollbar et les composant additionnels

  3. #3
    Membre expérimenté
    Profil pro
    Inscrit en
    Février 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 197
    Par défaut
    C'est ce que j'avais fait temporairement, mais j'aimerais que ça soit vraiment intégré à mon composant.

    J'avais vu quelque chose de simillaire en java mais malheureusement j'ai eu beau chercher mais je ne le retrouve plus.

    J'ai mis un screen en attaché de ce que j'aimerai obtenir.
    Images attachées Images attachées  

  4. #4
    Membre très actif
    Avatar de william44290
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Juin 2009
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Responsable de service informatique

    Informations forums :
    Inscription : Juin 2009
    Messages : 400
    Par défaut
    faut faire comme dit plus haut (un panel+ta scroolbar+tes boutons), mais le bouton End n'existe pas il faut le recréer en s'inspirant du ButtonArrow issu du BasicButton, à voir dans les sources. Mais c'est là que cela se complique, chaque look&feel à sa propre façon de faire.

    Regarde mon projet et vérifie si cela peux te convenir.

  5. #5
    Membre expérimenté
    Profil pro
    Inscrit en
    Février 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 197
    Par défaut
    ça s'en raproche pas mal oui.
    La seule différence c'est que la bare centrale ne permet pas de monter/descendre comme une JMenuBar habituelle.

    pourrais-tu me donner un exemple de code pour le rajout d'un bouton comme tu as utilisé?

  6. #6
    Membre très actif
    Avatar de william44290
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Juin 2009
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Responsable de service informatique

    Informations forums :
    Inscription : Juin 2009
    Messages : 400
    Par défaut
    explique la barre centrale je comprends pas

  7. #7
    Membre très actif
    Avatar de william44290
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Juin 2009
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Responsable de service informatique

    Informations forums :
    Inscription : Juin 2009
    Messages : 400
    Par défaut
    Donne lui la taille maximale et traite la comme un bouton

  8. #8
    Membre expérimenté
    Profil pro
    Inscrit en
    Février 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 197
    Par défaut
    d'après ce que j'ai vu en testant le programme quand je clique sur la barre habituellement scrolable, ça passe à la ligne suivante plutot que de pouvoir laisser appuyé la souris et de monter/descendre.

  9. #9
    Membre très actif
    Avatar de william44290
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Juin 2009
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Responsable de service informatique

    Informations forums :
    Inscription : Juin 2009
    Messages : 400
    Par défaut
    Attention c'est des outils perso ils ne sont pas conçus pour être partagé, il faut adapter pour ton cas.

    Le button spécifique
    JButtonArrow
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    package wComposant;
     
    import java.awt.Color;
    import java.awt.Graphics;
     
    import wOutils.Gp;
     
    public class JButtonArrow extends JTextButton {
    	private static final long serialVersionUID = 1L;
    	private int type=0;
    	private int orientation;
    	public void setFleche(int orientation,int type){
    		this.setHideActionText(true);
     
    		this.orientation=orientation;
    		this.type=type;
    	}
    	public void paint(Graphics g){
    		super.paint(g);
    		int carre=Math.max(getWidth(), getHeight());
    		if (carre>17)
    			carre=carre-3;
    		else
    			carre=carre-2;
     
    		int x=(carre/2);
    		int size=(carre/3);
    		int y=(carre/3);
     
    		Color save=g.getColor();
    		if(isEnabled())
    			g.setColor(Gp.VERTFONCE_FG);
    		else
    			g.setColor(Color.GRAY);
    		Gp.paintTriangle(g, x,y,size,orientation,type);			
    		g.setColor(save);
    	}
    Le panel spécifique scrollbar à ma sauce
    JSb
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    public class JSb extends JPanel implements AdjustmentListener, MouseWheelListener, ActionListener {
    	private static final long serialVersionUID = 1L;
     
    	FichierIMoveListener fichierMoveListener=null;
     
    	public static final int MIN=0;
    	public static final int MAX=90;
    	public static final int MIL=45;
    	private static final int PAGE=10;
    	private static final int STEP=1;
    	public JPanel jptopbottom=null;
    	public JPanel jpprecedentsuivant=null;
    	public JPanel jpprecedentesuivante=null;
    	public JPanel jpscroll=null;
    	public JScrollBar scrollbar=null;
    	private int orientation=0;
    	private boolean userSetValue=false;
    	JButtonArrow jbtop=null;
    	String buttontop="top";
    	JButtonArrow jbbottom=null;
    	String buttonbottom="bottom";
    	JButtonArrow jbprecedent=null;
    	String buttonprecedent="precedent";
    	JButtonArrow jbsuivant=null;
    	String buttonsuivant="suivant";
    	JButtonArrow jbprecedente=null;
    	String buttonprecedente="precedente";
    	JButtonArrow jbsuivante=null;
    	String buttonsuivante="suivante";
    	JButtonArrow jbsuivantmil=null;
    	String buttonsuivantmil="suivantmil";
    	JLabel jlmil=null;
    	public JSb (int orientation) {
    		this.orientation=orientation;
    		//setVisible(false);
    		adapte();
    	}
    	public JSb (FichierIMoveListener tableMoveListener,int orientation) {
    		this.fichierMoveListener=tableMoveListener;
    		this.orientation=orientation;
    		adapte();
    	}
    	public void setEnabled(boolean enable){
    		super.setEnabled(enable);
    		scrollbar.setEnabled(enable);
    		if (jbtop!=null){
    			jbtop.setEnabled(enable);
    			jbbottom.setEnabled(enable);
    			jbsuivant.setEnabled(enable);
    			jbprecedent.setEnabled(enable);
    			jbsuivante.setEnabled(enable);
    			jbprecedente.setEnabled(enable);
    			jbsuivantmil.setEnabled(enable);
    		}
    	}
    	public void addTableMoveListener(FichierIMoveListener tableMoveListener){
    		this.fichierMoveListener=tableMoveListener;
    		setVisible(true);
    	}
    	public void adapte(){
    		setLayout(new BorderLayout());{
    			setBorder(BorderFactory.createEtchedBorder());
    			jptopbottom=new JPanel(new BorderLayout(0,0));{
    				jpprecedentesuivante=new JPanel(new BorderLayout(0,0));{
    					jpprecedentsuivant=new JPanel(new BorderLayout(0,0));{
    					}
    					jpscroll=new JPanel(new BorderLayout(0,0));{
    						scrollbar=new JScrollBar(orientation,MIL,PAGE,MIN,MAX+PAGE);{
    							scrollbar.setUnitIncrement(STEP);
    							scrollbar.addAdjustmentListener(this);
    							scrollbar.addMouseWheelListener(this);
    						}
    						jpscroll.add(scrollbar,BorderLayout.CENTER);
    					}
    					jpprecedentesuivante.add(jpscroll,BorderLayout.CENTER);
    				}
    				jptopbottom.add(jpprecedentesuivante,BorderLayout.CENTER);
    			}
    			add(jptopbottom,BorderLayout.CENTER);
    		}
    	}
    	public void setOrientation(int orientation){
    		scrollbar.setOrientation(orientation);
    	}
    	public void setPlayButton(){
    		jbtop=new JButtonArrow();{
    			jbtop.setActionCommand(buttontop);
    			jbtop.addActionListener(this);
    			jbtop.addMouseWheelListener(this);
    			jbtop.setFocusable(false);
    		}
    		jbbottom=new JButtonArrow();{
    			jbbottom.setActionCommand(buttonbottom);
    			jbbottom.addActionListener(this);
    			jbbottom.addMouseWheelListener(this);
    			jbbottom.setFocusable(false);
    		}
    		jbprecedente=new JButtonArrow();{
    			jbprecedente.setActionCommand(buttonprecedente);
    			jbprecedente.addActionListener(this);
    			jbprecedente.addMouseWheelListener(this);
    			jbprecedente.setFocusable(false);
    		}
    		jbsuivante=new JButtonArrow();{
    			jbsuivante.setActionCommand(buttonsuivante);
    			jbsuivante.addActionListener(this);
    			jbsuivante.addMouseWheelListener(this);
    			jbsuivante.setFocusable(false);
    		}
    		jbprecedent=new JButtonArrow();{
    			jbprecedent.setActionCommand(buttonprecedent);
    			jbprecedent.addActionListener(this);
    			jbprecedent.addMouseWheelListener(this);
    			jbprecedent.setFocusable(false);
    		}
    		jbsuivant=new JButtonArrow();{
    			jbsuivant.setActionCommand(buttonsuivant);
    			jbsuivant.addActionListener(this);
    			jbsuivant.addMouseWheelListener(this);
    			jbsuivant.setFocusable(false);
    		}
    		jbsuivantmil=new JButtonArrow();{
    			jbsuivantmil.setActionCommand(buttonsuivantmil);
    			jbsuivantmil.addActionListener(this);
    			jbsuivantmil.addMouseWheelListener(this);
    			jbsuivantmil.setFocusable(false);
    		}
    //		jlmil=new JLabel();{
    //			jlmil.addMouseWheelListener(this);
    //			jlmil.setFocusable(false);
    //		}
     
    		Dimension dim=null;
    		Dimension dimmil=null;
    		String debut=null;
    		String fin=null;
    		int idebut;
    		int ifin;
    		if (scrollbar.getOrientation()==Scrollbar.HORIZONTAL){
    			dim=new Dimension(scrollbar.getPreferredSize().height,scrollbar.getPreferredSize().height);
    			debut=BorderLayout.WEST;
    			fin=BorderLayout.EAST;
    			idebut=SwingConstants.WEST;
    			ifin=SwingConstants.EAST;
    		} else {
    			dim=new Dimension(scrollbar.getPreferredSize().width,scrollbar.getPreferredSize().width);
    			debut=BorderLayout.NORTH;
    			fin=BorderLayout.SOUTH;
    			idebut=SwingConstants.NORTH;
    			ifin=SwingConstants.SOUTH;
    		}
    		jptopbottom.add(jbtop,debut);
    		jptopbottom.add(jbbottom,fin);
    		jpprecedentesuivante.add(jbprecedente,debut);
    		jpprecedentesuivante.add(jbsuivante,fin);
    		jpprecedentsuivant.add(jbprecedent,debut);
    		jpprecedentsuivant.add(jbsuivant,fin);
     
     
    		jbtop.setPreferredSize(dim);
    		jbbottom.setPreferredSize(dim);
    		jbprecedente.setPreferredSize(dim);
    		jbsuivante.setPreferredSize(dim);
    		jbprecedent.setPreferredSize(dim);
    		jbsuivant.setPreferredSize(dim);
     
    		jbtop.setFleche(idebut,2);
    		jbbottom.setFleche(ifin,2);
    		jbprecedente.setFleche(idebut,1);
    		jbsuivante.setFleche(ifin,1);
    		jbprecedent.setFleche(idebut,0);
    		jbsuivant.setFleche(ifin,0);
     
    		dimmil=new Dimension(0,0);
    		jbsuivantmil.setPreferredSize(dimmil);
    		//jlmil.setPreferredSize(dimmil);
    		jpprecedentsuivant.add(jbsuivantmil,BorderLayout.CENTER);
    		jpscroll.add(jpprecedentsuivant,BorderLayout.CENTER);
     
    	}
    	public void setValue(int value){
    		userSetValue=true;
    		scrollbar.setValue(value);
    		userSetValue=false;
    	}
    	public void setWidth(int width){
    		Dimension dim=new Dimension(width,scrollbar.getPreferredSize().height);
    		setFixeSize(dim);
    	}
    	public void setHeight(int height){
    		Dimension dim=new Dimension(scrollbar.getPreferredSize().width,height);
    		setFixeSize(dim);
    	}
    	private void setFixeSize(Dimension dim){
    		if (jbtop!=null){
    			boolean milVisible=true;
    			if (scrollbar.getOrientation()==Scrollbar.HORIZONTAL){
    				dim.width=dim.width-(6*dim.height);
    				if (dim.width<dim.height)
    					milVisible=false;
    			} else {
    				dim.height=dim.height-(6*dim.width);
    				if (dim.height<dim.width)
    					milVisible=false;
    			}
    			Dimension dimmil=new Dimension(0,0);
    			jbsuivantmil.setPreferredSize(dimmil);
    			jbsuivantmil.setMaximumSize(dim);
    			jbsuivantmil.setMinimumSize(dim);
     
    			jbsuivantmil.setBorderPainted(milVisible);
    			jbsuivantmil.setFocusPainted(milVisible);
    			//jbsuivantmil.setVisible(milVisible);
     
     
    //			jlmil.setPreferredSize(dimmil);
    //			jlmil.setMaximumSize(dim);
    //			jlmil.setMinimumSize(dim);
    //			//jlmil.setVisible(!milVisible);
    //			if (milVisible)
    //				jpprecedentsuivant.add(jbsuivantmil,BorderLayout.CENTER);
    //			else
    //				jpprecedentsuivant.add(jlmil,BorderLayout.CENTER);
    //			jpprecedentsuivant.revalidate();
    		}
    		scrollbar.setPreferredSize(dim);
    		scrollbar.setMaximumSize(dim);
    		scrollbar.setMinimumSize(dim);
    		scrollbar.revalidate();
    		this.revalidate();
    	}
    	public void mouseWheelMoved(MouseWheelEvent arg0) {
    		if (fichierMoveListener!=null){
    			if (arg0.getWheelRotation()>0){
    				fichierMoveListener.suivant();
    			} else { 
    				fichierMoveListener.precedent(); }
    		}
    	}
    	public void adjustmentValueChanged(AdjustmentEvent arg0) {
    		if (!userSetValue && fichierMoveListener!=null){
    			switch (arg0.getValue()) {
    			// depuis MIN
    			case (STEP): fichierMoveListener.suivant() ; break;
    			case (PAGE): fichierMoveListener.pageSuivante(); break;
    			// depuis MIL
    			case (MIL - STEP): fichierMoveListener.precedent() ; break;
    			case (MIL + STEP): fichierMoveListener.suivant(); break;
    			case (MIL - PAGE): fichierMoveListener.pagePrecedente(); break;
    			case (MIL + PAGE): fichierMoveListener.pageSuivante(); break;
    			case MAX: fichierMoveListener.fin(); break;
    			case MIN: fichierMoveListener.debut(); break; 
    			// depuis MAX
    			case (MAX - STEP): fichierMoveListener.precedent() ; break;
    			case (MAX - PAGE): fichierMoveListener.pagePrecedente(); break;
    			}
    			if (scrollbar.getValue()!=MIN &&scrollbar.getValue()!=MAX){
    				setValue(MIL);
    			}
    		}
    		if (jbtop!=null){
    			if (scrollbar.getValue()==MIN){
    				jbtop.setEnabled(false);
    				jbprecedente.setEnabled(false);
    				jbprecedent.setEnabled(false);
    			} else {
    				jbtop.setEnabled(true);
    				jbprecedente.setEnabled(true);
    				jbprecedent.setEnabled(true);
    			}
    			if (scrollbar.getValue()==MAX){
    				jbbottom.setEnabled(false);
    				jbsuivante.setEnabled(false);
    				jbsuivant.setEnabled(false);
    				jbsuivantmil.setEnabled(false);
    			} else {
    				jbbottom.setEnabled(true);
    				jbsuivante.setEnabled(true);
    				jbsuivant.setEnabled(true);
    				jbsuivantmil.setEnabled(true);
    			}
    		}
    	}
    	public void actionPerformed(ActionEvent arg0) {
    		if (arg0.getActionCommand().equals(buttontop)){
    			scrollbar.setValue(MIN);
    		} else if ( arg0.getActionCommand().equals(buttonbottom)){
    			scrollbar.setValue(MAX);
    		} else if ( arg0.getActionCommand().equals(buttonprecedent)){
    			scrollbar.setValue(MIL - STEP);
    		} else if ( arg0.getActionCommand().equals(buttonsuivant)){
    			scrollbar.setValue(MIL + STEP);
    		} else if ( arg0.getActionCommand().equals(buttonprecedente)){
    			scrollbar.setValue(MIL - PAGE);
    		} else if ( arg0.getActionCommand().equals(buttonsuivante)){
    			scrollbar.setValue(MIL + PAGE);
    		} else if ( arg0.getActionCommand().equals(buttonsuivantmil)){
    			scrollbar.setValue(MIL + STEP);
    		}
     
    	}
    }
    L'interface qui relie les boutons
    FichierIMoveListener
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    package wFichier;
     
    public interface FichierIMoveListener {
    	public void precedent();
    	public void suivant();
    	public void pagePrecedente();
    	public void pageSuivante();
    	public void debut();
    	public void fin();
    }
    Méthode Dessin de triangle
    paintTriangle
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    	public static void paintTriangle(Graphics g, int x, int y, int size, int direction,int type) {
    		int page=1;
    		int end=2;
    		int mid, i, j;
    		j = 0;
    		size = Math.max(size, 2);
    		mid = (size / 2) - 1;
     
    		g.translate(x, y);
     
    		switch(direction)       {
    		case SwingConstants.NORTH:
    			if (type==page){
    				g.translate(0,3);
    			}
    			if (type==end){
    				g.translate(0,2);
    			}
    			for(i = 0; i < size; i++)      {
    				g.drawLine(mid-i, i, mid+i, i);
    			}
    			if (type==page){
    				g.translate(0,-4);
    				for(i = 0; i < size; i++)      {
    					g.drawLine(mid-i, i, mid+i, i);
    				}
    				g.translate(0,1);
    			}
    			if (type==end){
    				g.translate(0,-3);
    				g.translate(0,1);
    				i = size-1;
    				g.drawLine(mid-i, 0, mid+i, 0);
    				g.drawLine(mid-i, 0+1, mid+i, 0+1);
    				g.translate(0,-1);
    			}
    			break;
    		case SwingConstants.SOUTH:
    			if (type==page){
    				g.translate(0,-1);
    			}	
    			j = 0;
    			for(i = size-1; i >= 0; i--)   {
    				g.drawLine(mid-i, j, mid+i, j);
    				j++;
    			}
    			if (type==page){
    				g.translate(0,1);
    				g.translate(0,3);
    				j = 0;
    				for(i = size-1; i >= 0; i--)   {
    					g.drawLine(mid-i, j, mid+i, j);
    					j++;
    				}
    				g.translate(0,-3);
    			}
    			if (type==end){
    				i = size-1;
    				g.drawLine(mid-i, j, mid+i, j);
    				g.drawLine(mid-i, j+1, mid+i, j+1);
    			}
    			break;
    		case SwingConstants.WEST:
    			for(i = 0; i < size; i++)      {
    				g.drawLine(i, mid-i, i, mid+i);
    			}
    			break;
    		case SwingConstants.EAST:
    			j = 0;
    			for(i = size-1; i >= 0; i--)   {
    				g.drawLine(j, mid-i, j, mid+i);
    				j++;
    			}
    			break;
    		}
    		g.translate(-x, -y);	
    	}
    Pour finir
    l'instanciation de la scrollbar Spécifique
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    sb=new JSb(this,JScrollBar.VERTICAL);{
    		sb.setPlayButton();
    		sb.setHeight((sql.t_nbLigne)*Gp.HEIGHTCHAR*sql.t_height);
                    }
    Bon courage

  10. #10
    Membre très actif
    Avatar de william44290
    Homme Profil pro
    Responsable de service informatique
    Inscrit en
    Juin 2009
    Messages
    400
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Responsable de service informatique

    Informations forums :
    Inscription : Juin 2009
    Messages : 400
    Par défaut
    oui c'est volontaire, J'ai mis des boutons page précédente et suivante cela faisait doublon. Cette scrollbar n'est pas une scrollBar.
    tu fais comme tu veux.

  11. #11
    Membre expérimenté
    Profil pro
    Inscrit en
    Février 2006
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Février 2006
    Messages : 197
    Par défaut
    Merci.
    Je vais regarder ça ce soir à la maison

Discussions similaires

  1. Affichage tabulaire avec bouton "voir plus"
    Par laurentSc dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 08/11/2013, 17h14
  2. Tableau dynamique avec boutons en plus
    Par totonin dans le forum Struts 1
    Réponses: 10
    Dernier message: 03/07/2009, 11h05
  3. Réponses: 3
    Dernier message: 04/04/2007, 16h11
  4. [VB.NET] Pb avec le bouton Annuler d'1 barre de progression
    Par dada1982 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 30/06/2004, 09h56
  5. Réponses: 10
    Dernier message: 10/06/2004, 16h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo