Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    problema swing

    Ciao sn1novellino d java e mi servirebbe il vostro aiuto.
    Vi espongo il mio problema.Sto creando una Swing Java per studenti
    Ho creato una JFrame,1pannello contenitore in modalità CardLayout e vari pannelli da scorrere tramite bottoni.
    Nel primo pannello ho una form d login..lancio la query e tutto va per il meglio facendomi passare al secondo pannello.
    Il problema sta nel fatto ke nel secondo pannello voglio settare un'area logout e per farlo voglio impostare una Jlabel che scriva il nome dello studente ke è entrato.
    La query del login mi restituisce uno Studente ma nn so cm settare la JLabel...
    e cm pescare il mio studente negli altri pannelli.



    grazie
    ciao

  2. #2
    Utente di HTML.it L'avatar di Alex'87
    Registrato dal
    Aug 2001
    residenza
    Verona
    Messaggi
    5,802

    Re: problema swing

    Originariamente inviato da toninosanchez
    Ciao sn1novellino d java e mi servirebbe il vostro aiuto.
    Vi espongo il mio problema.Sto creando una Swing Java per studenti
    Ho creato una JFrame,1pannello contenitore in modalità CardLayout e vari pannelli da scorrere tramite bottoni.
    Nel primo pannello ho una form d login..lancio la query e tutto va per il meglio facendomi passare al secondo pannello.
    Il problema sta nel fatto ke nel secondo pannello voglio settare un'area logout e per farlo voglio impostare una Jlabel che scriva il nome dello studente ke è entrato.
    La query del login mi restituisce uno Studente ma nn so cm settare la JLabel...
    e cm pescare il mio studente negli altri pannelli.



    grazie
    ciao
    A parte il fatto che non si capisce un tubo (cosa significa "Sto creando una Swing Java per studenti"??), hai sbagliato sezione
    SpringSource Certified Spring Professional | Pivotal Certified Enterprise Integration Specialist
    Di questo libro e degli altri (blog personale di recensioni libri) | ​NO M.P. TECNICI

  3. #3
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,480

    Moderazione

    C'è un'area specifica dedicata a Java. Ho spostato la discussione.
    Ho inoltre attribuito un titolo significativo, cosa che è responsabilità dell'autore fare (in futuro).
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  4. #4
    Utente di HTML.it L'avatar di morphy79
    Registrato dal
    Jun 2004
    Messaggi
    1,568

    Re: problema swing

    Originariamente inviato da toninosanchez
    Ciao sn1novellino d java e mi servirebbe il vostro aiuto.
    Vi espongo il mio problema.Sto creando una Swing Java per studenti
    Ho creato una JFrame,1pannello contenitore in modalità CardLayout e vari pannelli da scorrere tramite bottoni.
    Nel primo pannello ho una form d login..lancio la query e tutto va per il meglio facendomi passare al secondo pannello.
    Il problema sta nel fatto ke nel secondo pannello voglio settare un'area logout e per farlo voglio impostare una Jlabel che scriva il nome dello studente ke è entrato.
    La query del login mi restituisce uno Studente ma nn so cm settare la JLabel...
    e cm pescare il mio studente negli altri pannelli.



    grazie
    ciao
    se scrivi senza k e abbreviazioni magari ti possiamo dare una mano..
    odio chi parla di politica..
    anzi vorrei fondare un partito contro tutto ciò

  5. #5
    OK...vi spiego meglio..
    Nel primo pannello ho un'area di login con una JTextField per l'username,una per la pasword ed1bottone.
    Nel bottone ho implementato una funzione ke si collega al database,controlla le credenziali e,se sn corrette,mi manda al secondo pannello.La query mi restituisce un intero studente.
    Il mio problema consiste nel fatto ke nn so cm pescare in futuro i dati dello studente ke ha effettuato l'accesso.

  6. #6
    Utente di HTML.it
    Registrato dal
    Feb 2009
    Messaggi
    502
    Originariamente inviato da toninosanchez
    OK...vi spiego meglio..
    Nel primo pannello ho un'area di login con una JTextField per l'username,una per la pasword ed1bottone.
    Nel bottone ho implementato una funzione ke si collega al database,controlla le credenziali e,se sn corrette,mi manda al secondo pannello.La query mi restituisce un intero studente.
    Il mio problema consiste nel fatto ke nn so cm pescare in futuro i dati dello studente ke ha effettuato l'accesso.
    Se il pulsante sta nel primo pannello e il secondo lo crei dalla classe del primo pannello, gli passi al costruttore del secondo un oggetto Studente, o quello che hai implementato tu, così hai tutti i dati relativi.
    al volante son nervoso

  7. #7
    nn ho capito...vi allego il codice xkè la cosa è alquanto urgente
    grazie

    public class CopyOfHomepageLogin extends JFrame {

    /**
    *
    */
    private static final long serialVersionUID = 1L;

    private JFrame jFrame = null;
    private JPanel jContentPane = null;
    private JPanel jPanel = null;
    private JLabel jLabel = null;
    private JLabel jLabel1 = null;
    private JLabel jLabel2 = null;
    private JPanel jPanel1 = null;
    private JTextField jTextField = null;
    private JPasswordField jPasswordField = null;
    private JLabel jLabel4 = null;
    private JLabel jLabel22 = null;
    private JLabel jLabel21 = null;
    private JComboBox jComboBox = null;
    private JButton jButton = null;
    private JPanel jPanel2 = null;
    private JPanel jPanel3 = null;
    private JLabel jLabel3 = null;
    private JLabel jLabel5 = null;
    private JLabel jLabel6 = null;
    private JLabel jLabel7 = null;



    public CopyOfHomepageLogin() {
    setSize(900,750);
    getJFrame();
    getJContentPane();
    getJTextField();
    getJPasswordField();
    getJComboBox();
    getJButton();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }


    /**
    * This method initializes jFrame
    *
    * @return javax.swing.JFrame
    */

    private JFrame getJFrame() {
    if (jFrame == null) {
    jFrame = new JFrame();
    jFrame.setSize(new Dimension(900, 750));
    jFrame.setLocation(new Point(165, 15));
    jFrame.setContentPane(getJContentPane());
    jFrame.setTitle("Scuola_Guida");
    jFrame.setVisible(true);
    }
    return jFrame;
    }

    /**
    * This method initializes jContentPane
    *
    * @return javax.swing.JPanel
    */

    private JPanel getJContentPane() {
    if (jContentPane == null) {
    jContentPane = new JPanel();
    jContentPane.setLayout(new CardLayout());
    jContentPane.add(getJPanel(), getJPanel().getName());
    jContentPane.add(getJPanel2(), getJPanel2().getName());
    jContentPane.add(getJPanel3(), getJPanel3().getName());
    }
    return jContentPane;
    }

    /**
    * This method initializes jPanel
    *
    * @return javax.swing.JPanel
    */

    private JPanel getJPanel() {
    if (jPanel == null) {
    jLabel2 = new JLabel();
    jLabel2.setBounds(new Rectangle(1, 146, 882, 83));
    jLabel2.setHorizontalAlignment(SwingConstants.CENT ER);
    jLabel2.setFont(new Font("Eras Medium ITC", Font.BOLD, 20));
    jLabel2.setText("Il software semplice e intuitivo ideale per la gestione dell'Autoscuola.");
    jLabel1 = new JLabel();
    jLabel1.setBounds(new Rectangle(1, 688, 882, 25));
    jLabel1.setIcon(new ImageIcon("C:/Users/ga/workspace/immagini swing patente/Senza titolo-3.jpg"));
    jLabel1.setText("");
    jLabel = new JLabel();
    jLabel.setBounds(new Rectangle(1, 1, 882, 145));
    jLabel.setIcon(new ImageIcon("C:/Users/ga/workspace/immagini swing patente/Senza titolo-2.jpg"));
    jLabel.setText("");
    jPanel = new JPanel();
    jPanel.setLayout(null);
    jPanel.setName("Homepage");
    jPanel.setBackground(Color.white);
    jPanel.add(jLabel, null);
    jPanel.add(jLabel1, null);
    jPanel.add(jLabel2, null);
    jPanel.add(getJPanel1(), null);
    }
    return jPanel;
    }


    /**
    * This method initializes jPanel1
    *
    * @return javax.swing.JPanel
    */

    private JPanel getJPanel1() {
    if (jPanel1 == null) {
    jLabel4 = new JLabel();
    jLabel4.setBounds(new Rectangle(133, 8, 92, 31));
    jLabel4.setFont(new Font("Eras Medium ITC", Font.BOLD, 20));
    jLabel4.setHorizontalAlignment(SwingConstants.CENT ER);
    jLabel4.setText("Login");
    jLabel22 = new JLabel();
    jLabel22.setText("Ruolo:");
    jLabel22.setSize(new Dimension(70, 45));
    jLabel22.setHorizontalAlignment(SwingConstants.CEN TER);
    jLabel22.setFont(new Font("Eras Medium ITC", Font.BOLD, 12));
    jLabel22.setLocation(new Point(30, 165));
    jLabel21 = new JLabel();
    jLabel21.setText("Password:");
    jLabel21.setSize(new Dimension(70, 45));
    jLabel21.setHorizontalAlignment(SwingConstants.CEN TER);
    jLabel21.setFont(new Font("Eras Medium ITC", Font.BOLD, 12));
    jLabel21.setLocation(new Point(30, 105));
    jLabel2 = new JLabel();
    jLabel2.setText("Username:");
    jLabel2.setSize(new Dimension(70, 45));
    jLabel2.setFont(new Font("Eras Medium ITC", Font.BOLD, 12));
    jLabel2.setHorizontalAlignment(SwingConstants.CENT ER);
    jLabel2.setLocation(new Point(30, 45));
    jPanel1 = new JPanel();
    jPanel1.setLayout(null);
    jPanel1.setBounds(new Rectangle(260, 286, 364, 286));
    jPanel1.setBackground(Color.white);
    jPanel1.add(jLabel2, null);
    jPanel1.add(jLabel21, null);
    jPanel1.add(jLabel22, null);
    jPanel1.add(getJTextField(), null);
    jPanel1.add(getJPasswordField(), null);
    jPanel1.add(getJComboBox(), null);
    jPanel1.add(jLabel4, null);
    jPanel1.setVisible(true);
    jPanel1.add(getJButton(), null);
    }
    return jPanel1;
    }

    /**
    * This method initializes jTextField
    *
    * @return javax.swing.JTextField
    */

    JTextField getJTextField() {
    if (jTextField == null) {
    jTextField = new JTextField();
    jTextField.setLocation(new Point(110, 45));
    jTextField.setText("");
    jTextField.setHorizontalAlignment(JTextField.CENTE R);
    jTextField.setSize(new Dimension(200, 45));
    jTextField.setVisible(true);
    jTextField.setDocument(new PersonalizzaJtextField(10));
    }
    return jTextField;
    }

    /**
    * This method initializes jPasswordField
    *
    * @return javax.swing.JPasswordField
    */

    JPasswordField getJPasswordField() {
    if (jPasswordField == null) {
    jPasswordField = new JPasswordField();
    jPasswordField.setLocation(new Point(110, 105));
    jPasswordField.setText("");
    jPasswordField.setHorizontalAlignment(JTextField.C ENTER);
    jPasswordField.setSize(new Dimension(200, 45));
    jPasswordField.setDocument(new PersonalizzaJtextField(8));
    }
    return jPasswordField;
    }

    /**
    * This method initializes jComboBox
    *
    * @return javax.swing.JComboBox
    */

    private JComboBox getJComboBox() {
    if (jComboBox == null) {
    jComboBox = new JComboBox();
    jComboBox.setLocation(new Point(110, 165));
    jComboBox.setComponentOrientation(ComponentOrienta tion.UNKNOWN);
    jComboBox.setBackground(Color.white);
    jComboBox.setSize(new Dimension(200, 45));
    jComboBox.addItem("Docente");
    jComboBox.addItem("Studente");
    }
    return jComboBox;
    }

    /**
    * This method initializes jButton
    *
    * @return javax.swing.JButton
    */

    private JButton getJButton() {
    if (jButton == null) {
    jButton = new JButton();
    jButton.setBounds(new Rectangle(143, 234, 75, 34));
    jButton.setHorizontalTextPosition(SwingConstants.C ENTER);
    jButton.setBackground(Color.white);
    jButton.setText("Accedi");
    jButton.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent e) {
    String US= jTextField.getText();
    String PW= String.valueOf(jPasswordField.getPassword());
    String RU= (String)jComboBox.getSelectedItem();
    Login l= new Login ();
    Studente s= new Studente();
    Docente d= new Docente();

    if(RU=="Docente")
    {
    try {
    d=l.LogDoc(US, PW);
    } catch (SQLException e1) {
    e1.printStackTrace();
    }

    if(d.getUsername()!=null)
    {
    jPanel3.setVisible(true);
    jPanel.setVisible(false);
    }
    else
    {
    JOptionPane.showMessageDialog(null, "Utente non trovato!!!");
    }
    }

    else
    {
    try {
    s=l.LogStud(US, PW);
    } catch (SQLException e1) {
    e1.printStackTrace();
    }
    if(s.getUsername()!=null)
    {
    jPanel2.setVisible(true);
    jPanel.setVisible(false);
    }
    else
    {
    JOptionPane.showMessageDialog(null, "Utente non trovato!!!");
    }
    }
    }
    });

    }
    return jButton;
    }









    /**
    * This method initializes jPanel2
    *
    * @return javax.swing.JPanel
    */
    private JPanel getJPanel2() { \\qui mi servono i dati dello studente
    if (jPanel2 == null) {
    jPanel2 = new JPanel();
    jPanel2.setLayout(null);
    jPanel2.setName("HomeStud");
    jPanel2.setBounds(new Rectangle(54, 22, 10, 10));
    jPanel2.setBackground(Color.white);
    jLabel6 = new JLabel();
    jLabel6.setBounds(new Rectangle(1, 1, 882, 145));
    jLabel6.setIcon(new ImageIcon("C:/Users/ga/workspace/immagini swing patente/Senza titolo-2.jpg"));
    jLabel6.setText("");
    jPanel2.add(jLabel6, null);
    jLabel7 = new JLabel();
    jLabel7.setBounds(new Rectangle(1, 688, 882, 25));
    jLabel7.setIcon(new ImageIcon("C:/Users/ga/workspace/immagini swing patente/Senza titolo-3.jpg"));
    jLabel7.setText("");
    jPanel2.add(jLabel7, null);
    }
    return jPanel2;
    }


    /**
    * This method initializes jPanel3
    *
    * @return javax.swing.JPanel
    */
    private JPanel getJPanel3() { \\qui mi servono i dati del docente
    if (jPanel3 == null) {
    jPanel3 = new JPanel();
    jPanel3.setLayout(null);
    jPanel3.setName("HomeDoc");
    jPanel3.setBounds(new Rectangle(54, 22, 10, 10));
    jPanel3.setBackground(Color.white);
    jLabel3 = new JLabel();
    jLabel3.setBounds(new Rectangle(1, 1, 882, 145));
    jLabel3.setIcon(new ImageIcon("C:/Users/ga/workspace/immagini swing patente/Senza titolo-2.jpg"));
    jLabel3.setText("");
    jPanel3.add(jLabel3, null);
    jLabel5 = new JLabel();
    jLabel5.setBounds(new Rectangle(1, 688, 882, 25));
    jLabel5.setIcon(new ImageIcon("C:/Users/ga/workspace/immagini swing patente/Senza titolo-3.jpg"));
    jLabel5.setText("");
    jPanel3.add(jLabel5, null);
    }
    return jPanel3;
    }







    public static void main(String[] args) {
    new CopyOfHomepageLogin();
    }


    }

  8. #8
    Utente di HTML.it
    Registrato dal
    Feb 2009
    Messaggi
    502
    Alcune cose:

    1) nulla è urgente, nel senso che il forum non è una "hotline" di assistenza all'ultimo minuto
    2) il codice va messo negli appositi tag, come da regolamento.

    Comunque ripeto: quando costruisci un oggetto, e vuoi poter avere accesso a metodi, proprietà e valori di un altro, gli passi in fase di costruzione, o dopo con un setter, un "reference" all'oggetto stesso.
    al volante son nervoso

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.