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

Interfaces Graphiques en Java Discussion :

Un JLabel affiché verticalement


Sujet :

Interfaces Graphiques en Java

  1. #1
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 90
    Par défaut Un JLabel affiché verticalement
    Bonjour,

    je dispose d'un Jpanel qui contient un Jlabel!! je voudrais que ce Jlabel soit affiché à la verticale. comment faire ?!

  2. #2
    Membre Expert Avatar de rtg57
    Homme Profil pro
    Autodidacte
    Inscrit en
    Mars 2006
    Messages
    1 343
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Autodidacte
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 343
    Par défaut
    Bonsoir,

    peut être un début de réponse ici: http://www.developpez.net/forums/d55...abel-vertical/

    Peut être aussi là: http://tech.chitgoks.com/2009/11/13/...el-vertically/

    Ca dépend si vous voulez que les lettres soient horizontales ou verticales...

    @ bientôt...

  3. #3
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 90
    Par défaut
    Merci beaucoup! j'ai opté pour la solution HTML. Mais, étant donné que j'utilise Netbeans, il n'y a pas un moyen plus simple pour faire automatiquement la rotation d'un label ?!

  4. #4
    Membre Expert Avatar de rtg57
    Homme Profil pro
    Autodidacte
    Inscrit en
    Mars 2006
    Messages
    1 343
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Autodidacte
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 343
    Par défaut
    Bonjour,

    attention l'option HTML n'est par réellement une rotation d'un JLabel. En effet, il s'agit plutôt dans ce cas d'un composant qui est plus haut que large.
    Si vous voulez vraiment faire une rotation "graphique", il faut passer par la classe Graphics2D.

    Le 2nd lien vous en montre un exemple.
    Je ne vois pas d'autre solution. Mais elle n'est pas si compliquée que cela

    @ bientôt...

  5. #5
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 90
    Par défaut
    Merci bien, ca a marché avec le HTML! mais le label s'affiche tout à gauche du panel ! Serait ce possible de le centrer ?!

  6. #6
    Membre Expert Avatar de rtg57
    Homme Profil pro
    Autodidacte
    Inscrit en
    Mars 2006
    Messages
    1 343
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Autodidacte
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 343
    Par défaut
    Bonjour,

    là je pense qu'il s'agit plutôt d'un problème de Layout.

    Pouvez-vous nous donner le code qui s'occupe de la construction de ce JLabel, et notamment la ligne où il est intégré à l'application (genre this.add( monLabel ); )

    @ bientôt...

  7. #7
    Membre confirmé
    Inscrit en
    Février 2011
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 90
    Par défaut
    Citation Envoyé par rtg57 Voir le message
    Bonjour,

    là je pense qu'il s'agit plutôt d'un problème de Layout.

    Pouvez-vous nous donner le code qui s'occupe de la construction de ce JLabel, et notamment la ligne où il est intégré à l'application (genre this.add( monLabel ); )

    @ bientôt...
    Bonjour,

    d'accord, voici mon code (je travaille avec netbeans)

    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    /*
     * Slot.java
     *
     * Created on 13 mai 2011, 12:24:08
     */
     
    package GuiPhysique;
     
    import com.mysql.jdbc.Connection;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.sql.SQLException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.ProgressMonitor;
     
     
    public class Slot extends javax.swing.JPanel {
        Connection conn  = (Connection) ConnectDatabaseDAO.getInstance("root", "azerty" , "project_v2.1");
        public Boolean TestB = false;
        /** Creates new form Slot */
        public Slot() {
            initComponents();
        }
     
        public Slot(String SlotNum, String MASGName) {
            initComponents();
            this.SlotNum = SlotNum;
            this.MASGName = MASGName;
        }
            public Slot(String SlotNum, String MASGName, String PTN_type)  {
     
                initComponents();
                this.SlotNum = SlotNum;
                this.MASGName = MASGName;
                this.PTN_type = PTN_type;
     
     
     
     
        }
     
            public final void setBusySlot (){
     
            StandardWorker worker = new StandardWorker<Void>(new ProgressMonitor(this,"Operation in progress...","", 0, 100)){
            @Override
            public Void doInBackground() {
            lockItems();
            publish("Starting Task.");
            setProgress(0);
                         try {
                            BoardDao b_dao = new BoardDao();
                            Masg_csgDao m_dao = new Masg_csgDao();
                            if (b_dao.getObject(conn, m_dao.getObject(conn, MASGName), Integer.parseInt(SlotNum)) != null) {
                                setBackground(Color.red);
                            }
                        } catch (NotFoundException ex) {
                            Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (SQLException ex) {
                            Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
                        }
            publish("Task Finished.");
            setProgress(100);
            return null;
                    }
                 };
            worker.execute();
    }
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
     
            internalText = new javax.swing.JLabel();
     
            setBackground(new java.awt.Color(255, 255, 255));
            setMaximumSize(new java.awt.Dimension(19, 217));
            setMinimumSize(new java.awt.Dimension(19, 217));
            setPreferredSize(new java.awt.Dimension(19, 217));
            addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    formMouseClicked(evt);
                }
            });
            setLayout(new java.awt.CardLayout());
     
            internalText.setText("<html>S<br> L<br>O<br>T<br> <br>N</html>");
            internalText.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
            add(internalText, "card2");
        }// </editor-fold>                        
     
        private void formMouseClicked(java.awt.event.MouseEvent evt) {                                  
     
            TestDialog tf = new TestDialog(null,true);
            if( this.getBackground() != Color.red){
             BoardAddGui bf = new BoardAddGui(SlotNum, MASGName, PTN_type, this);
     
             tf.jTabbedPane1.add(bf);
             bf.setBackground(Color.white);
             tf.jTabbedPane1.setTitleAt(0, "Board : Add");
     
             tf.setSize(new Dimension(700,500));
             tf.setVisible(true);
            } else{
                try {
                    BoardDao b_dao = new BoardDao();
                    Masg_csgDao m_dao = new Masg_csgDao();
                    PortAddGui bf = new PortAddGui(b_dao.getObject(conn, m_dao.getObject(conn, MASGName), Integer.parseInt(SlotNum)).getBoard_Name());
                    tf.jTabbedPane1.add(bf);
                    bf.setBackground(Color.white);
                    tf.jTabbedPane1.setTitleAt(0, "Port : Add");
                    tf.setSize(new Dimension(700, 500));
                    tf.setVisible(true);
                } catch (NotFoundException ex) {
                    Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
                } catch (SQLException ex) {
                    Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }                                 
     
        public String getInternalText() {
            return internalText.getText();
        }
     
        public void setInternalText(String internalText) {
            this.internalText.setText(internalText);
        }
     
        public String getMASGName() {
            return MASGName;
        }
     
        public void setMASGName(String MASGName) {
            this.MASGName = MASGName;
        }
     
        public String getSlotNum() {
            return SlotNum;
        }
     
        public void setSlotNum(String SlotNum) {
            this.SlotNum = SlotNum;
        }
     
     
        private String SlotNum;// à changer en int
        private String MASGName;// à changer soit en ID soit en MASG_CSG
        private String PTN_type;
        // Variables declaration - do not modify                     
        public javax.swing.JLabel internalText;
        // End of variables declaration                   
     
    }

  8. #8
    Membre Expert Avatar de rtg57
    Homme Profil pro
    Autodidacte
    Inscrit en
    Mars 2006
    Messages
    1 343
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Autodidacte
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2006
    Messages : 1 343
    Par défaut
    Bonjour,

    ne serait-il pas mieux d'utiliser un BorderLayout au lieu du CardLayout ?

    @ bientôt...

Discussions similaires

  1. Réponses: 7
    Dernier message: 18/07/2007, 12h01
  2. JLabel - afficher des caractères Unicode asiatiques
    Par Nicolas_75 dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 25/02/2007, 12h38
  3. [JLabel] Ecriture verticale
    Par jproto dans le forum AWT/Swing
    Réponses: 17
    Dernier message: 29/07/2006, 00h17
  4. [JLabel] Afficher un JLabel vertical
    Par GENERYS dans le forum Composants
    Réponses: 4
    Dernier message: 03/10/2005, 11h36
  5. [JLabel] Afficher des images
    Par Bouki dans le forum Composants
    Réponses: 8
    Dernier message: 25/03/2005, 10h38

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