Results 1 to 7 of 7
  1. #1
    pbaudru is offline Member
    Join Date
    Jan 2010
    Location
    Athus - Belgium
    Posts
    23
    Rep Power
    0

    Default How to avoid this problem...

    Hi All,

    I have this JFrame. I'm using Eclipse.


    When I select something on the second JComboBox the 'spécification' JComboBox is refreshed.....but something weird happens at the same time.....the JButton NEXT (>) turns 'invisible'......


    Then when I move the mouse or click in some object on the JFrame this 'NEXT' JButton (>) becames very big and we only can see it on the JFrame.....


    How can I avoid this problem please ?

    Best regards, Pierre.
    Last edited by pbaudru; 01-20-2010 at 03:33 PM.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Hard to tell without seeing your code. Did you accidentally mix AWT and Swing?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    pbaudru is offline Member
    Join Date
    Jan 2010
    Location
    Athus - Belgium
    Posts
    23
    Rep Power
    0

    Default

    Quote Originally Posted by PhHein View Post
    Hard to tell without seeing your code. Did you accidentally mix AWT and Swing?
    Hello,

    Thanks for your message !

    Yes I have both AWT and Swing.....I didn't know that would be a problem to mix these two.....
    I have this on the code:
    import javax.swing.*
    import java.awt.*


    So, in this case....with one should I have to delete ?

    Regards. Pierre.

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    You cannot really delete any of them as you still need events from AWT. I'm only guessing here, so post your code or an Short, Self Contained, Compilable and Executable, Example Program
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    pbaudru is offline Member
    Join Date
    Jan 2010
    Location
    Athus - Belgium
    Posts
    23
    Rep Power
    0

    Default

    Hi,

    My code is here bellow......you will see that I'm really new on JAVA development....I started with this on 4 january 2010....I know that I still have to learn a lot of things, before I was a CoolGen/Cobol developer....anyway thanks a lot for your help....if you have any suggestions to change my code please let me know, I will appreciate that !

    Pierre.

    // importar bibliotecas
    //Evitar misturar AWT e Swing----
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.EventListener;

    import javax.swing.*;
    import javax.swing.border.Border;
    import javax.swing.border.EtchedBorder;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import java.io.*;
    import javax.swing.*;

    /**
    * @author Pierre - 04-01-2010
    */

    public class recheureka2 implements MouseListener, WindowListener, ActionListener, ListSelectionListener {


    static JList list;
    /*String [] testlist = {"NASCIMENTO CLAUDIO",
    "TSUNEJI ROBERTO",
    "PEIXOTO ISMAEL",
    "LIMA EDUARDO",
    "LOPES MARCILIO",
    "GIORDANO AFONSO",
    "MAYA YRAN",
    "BAUDRU PIERRE",
    "BAVAY DAVID",
    "BOITTE JEAN-PAUL",
    "DE SOUZA PATRICIA",
    "MACEDO RAFAEL",
    "SILVA ROBERTO",
    "NUNES ISABELA",
    "NUNES ISABELA",
    "NUNES ISABELA",
    "NUNES ISABELA",
    "CUNHA RAONI"};*/

    static JButton PBtest;
    static JButton PBfermer;
    static JButton PBeffacer;
    static JButton PBdetailcv;
    static JButton PBnext;
    static JButton PBprev;
    static JButton PBfiltrer;
    static JButton PBdetfermer;

    Font font = new Font("ARIAL", Font.PLAIN, 10);

    //ComboBoxModel combspeclist;
    //combspeclist = spec.getModel();

    JComboBox mob;
    JComboBox fonc;
    JComboBox spec;

    String [] combomob = {"AL",
    "BE",
    "FR",
    "LU",
    "TOUS"};

    String [] combofonc = {"DEV",
    "MAN",
    "P.MAN",
    "ADM",
    "TOUS"};

    String [] combospec = {"COOLGEN",
    "COBOL",
    "JAVA",
    ".NET",
    "TOUS"};

    static JTextField EFfiltre1;
    JTextField EFfiltre2;
    JTextField EFfiltre3;
    JTextField EFfiltre4;
    JTextField EFfiltre5;
    JTextField EFfiltre6;
    JTextField EFfiltre7;

    public static void main(String[] args) {

    //listener
    recheureka2 gui = new recheureka2();
    gui.go();

    }

    public void go() {

    //definicao das variaveis

    //moldura da janela
    JFrame filtre = new JFrame();

    //Lista de teste
    //JList list = new JList(testlist);
    //list = new JList(testlist);
    list = new JList();
    list.setVisibleRowCount (15);
    list.setSelectionMode(ListSelectionModel.SINGLE_SE LECTION);

    //Scroll da lista de teste
    JScrollPane scrollist = new JScrollPane(list);
    scrollist.setVerticalScrollBarPolicy(ScrollPaneCon stants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollist.setHorizontalScrollBarPolicy(ScrollPaneC onstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollist.add(list); //verificar
    scrollist.getVerticalScrollBar().setUnitIncrement( 10);

    //definicao de FONT
    //Font font = new Font("ARIAL", Font.PLAIN, 10);

    //criacao dos PBs
    //JButton PBfiltrer = new JButton("Chercher");
    PBfiltrer = new JButton("Chercher");
    PBfiltrer.setToolTipText("Lancer la recherche des candidats");
    //JButton PBfermer = new JButton("Fermer"); dec global da classe
    PBfermer = new JButton("Fermer");
    PBfermer.setToolTipText("Sortir de l'application");
    //JButton PBeffacer = new JButton("Nouvelle recherche");
    PBeffacer = new JButton("Nouvelle recherche");
    PBeffacer.setToolTipText("Vide 100% des champs");
    //JButton PBdetailcv = new JButton("Voir CV candidat");
    PBdetailcv = new JButton("Voir CV candidat");
    PBdetailcv.setToolTipText("Ouvre le CV en format WORD");
    //JButton PBprev = new JButton("<");
    PBprev = new JButton("<");
    PBprev.setToolTipText("Pagination");
    PBprev.setFont(font);
    //JButton PBnext = new JButton(">");
    PBnext = new JButton(">");
    PBnext.setToolTipText("Pagination");
    PBnext.setFont(font);

    //criacao dos Labels e entry fields
    JLabel LBfiltre1 = new JLabel("Mots clés");
    EFfiltre1 = new JTextField(20);
    JLabel LBfiltre2 = new JLabel("");
    EFfiltre2 = new JTextField(20);
    JLabel LBfiltre3 = new JLabel("");
    EFfiltre3 = new JTextField(20);
    JLabel LBfiltre4 = new JLabel("");
    EFfiltre4 = new JTextField(20);
    JLabel LBfiltre5 = new JLabel("");
    EFfiltre5 = new JTextField(20);
    JLabel LBfiltre6 = new JLabel("Date début CV");
    EFfiltre6 = new JTextField(20);
    JLabel LBfiltre7 = new JLabel("Date fin CV");
    EFfiltre7 = new JTextField(20);

    //criacao das comboboxes e seus labels
    //JComboBox mob = new JComboBox(combomob);
    //JComboBox fonc = new JComboBox(combofonc);
    //JComboBox spec = new JComboBox(combospec);
    mob = new JComboBox(combomob);
    fonc = new JComboBox(combofonc);
    spec = new JComboBox(combospec);
    JLabel LBmob = new JLabel("Mobilité");
    JLabel LBfonc = new JLabel("Fonction");
    JLabel LBspec = new JLabel("Spécialisation");

    //definir valores default das combo boxes, primeiro é 0
    mob.setSelectedIndex(4);
    fonc.setSelectedIndex(4);
    spec.setSelectedIndex(4);

    //foco no primeiro campo
    mob.requestFocus();

    //propriedades do frame
    filtre.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
    filtre.setTitle("Recherche candidat - EUREKA ITS SA");
    filtre.setSize(850,550);
    filtre.setVisible(true);

    //activer les objets sur le frame
    filtre.getContentPane().add(PBfiltrer);
    filtre.getContentPane().add(PBfermer);
    filtre.getContentPane().add(PBeffacer);
    filtre.getContentPane().add(PBdetailcv);

    filtre.getContentPane().add(LBfiltre1);
    filtre.getContentPane().add(EFfiltre1);

    filtre.getContentPane().add(LBfiltre2);
    filtre.getContentPane().add(EFfiltre2);

    filtre.getContentPane().add(LBfiltre3);
    filtre.getContentPane().add(EFfiltre3);

    filtre.getContentPane().add(LBfiltre4);
    filtre.getContentPane().add(EFfiltre4);

    filtre.getContentPane().add(LBfiltre5);
    filtre.getContentPane().add(EFfiltre5);

    filtre.getContentPane().add(LBfiltre6);
    filtre.getContentPane().add(EFfiltre6);

    filtre.getContentPane().add(LBfiltre7);
    filtre.getContentPane().add(EFfiltre7);

    filtre.getContentPane().add(list);

    filtre.getContentPane().add(mob);
    filtre.getContentPane().add(fonc);
    filtre.getContentPane().add(spec);
    filtre.getContentPane().add(LBmob);
    filtre.getContentPane().add(LBfonc);
    filtre.getContentPane().add(LBspec);

    filtre.getContentPane().add(PBprev);
    filtre.getContentPane().add(PBnext);

    //placement des comboboxes
    mob.setSize(120, 20);
    mob.setLocation(80, 60);
    mob.setBackground(Color.white);
    LBmob.setSize(120, 20);
    LBmob.setLocation(80, 40);

    fonc.setSize(120, 20);
    fonc.setLocation(220, 60);
    fonc.setBackground(Color.white);
    LBfonc.setSize(120, 20);
    LBfonc.setLocation(220, 40);

    spec.setSize(120, 20);
    spec.setLocation(360, 60);
    spec.setBackground(Color.white);
    LBspec.setSize(120, 20);
    LBspec.setLocation(360, 40);

    //placement de la liste
    list.setSize(450, 250);
    list.setLocation(100, 200);

    //placement et taille des PB
    PBfiltrer.setSize(120, 20);
    PBfiltrer.setLocation(430, 480);

    PBfermer.setSize(120, 20);
    PBfermer.setLocation(100, 480);

    PBeffacer.setSize(150, 20);
    PBeffacer.setLocation(250, 480);

    PBdetailcv.setSize(150, 20);
    PBdetailcv.setLocation(630, 310);

    PBprev.setSize(45, 20);
    PBprev.setLocation(555, 200);

    PBnext.setSize(45, 20);
    PBnext.setLocation(555, 430);

    //placement et taille des labels et entry fields
    LBfiltre1.setSize(120, 20);
    LBfiltre1.setLocation(80, 130);
    EFfiltre1.setSize(120, 20);
    EFfiltre1.setLocation(80, 150);

    LBfiltre2.setSize(120, 20);
    LBfiltre2.setLocation(220, 130);
    EFfiltre2.setSize(120, 20);
    EFfiltre2.setLocation(220, 150);

    LBfiltre3.setSize(120, 20);
    LBfiltre3.setLocation(360, 130);
    EFfiltre3.setSize(120, 20);
    EFfiltre3.setLocation(360, 150);

    LBfiltre4.setSize(120, 20);
    LBfiltre4.setLocation(500, 130);
    EFfiltre4.setSize(120, 20);
    EFfiltre4.setLocation(500, 150);

    LBfiltre5.setSize(120, 20);
    LBfiltre5.setLocation(640, 130);
    EFfiltre5.setSize(120, 20);
    EFfiltre5.setLocation(640, 150);

    LBfiltre6.setSize(120, 20);
    LBfiltre6.setLocation(500, 40);
    EFfiltre6.setSize(120, 20);
    EFfiltre6.setLocation(500, 60);

    LBfiltre7.setSize(120, 20);
    LBfiltre7.setLocation(640, 40);
    EFfiltre7.setSize(120, 20);
    EFfiltre7.setLocation(640, 60);

    //listener
    PBdetailcv.addActionListener(this);
    PBfermer.addActionListener(this);
    PBeffacer.addActionListener(this);
    PBprev.addActionListener(this);
    PBnext.addActionListener(this);
    PBfiltrer.addActionListener(this);

    mob.addActionListener(this);
    fonc.addActionListener(this);
    spec.addActionListener(this);

    list.addListSelectionListener(this);
    //list.setLayoutOrientation(JList.VERTICAL);
    //JScrollPane listS = new JScrollPane (list);
    //Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWE RED);
    //list.setBorder(BorderFactory.createTitledBorder(lo weredetched, "Candidats"));
    //JPanel listcand = new JPanel();
    //listcand.add(list);

    EFfiltre1.addActionListener(this);
    EFfiltre2.addActionListener(this);
    EFfiltre3.addActionListener(this);
    EFfiltre4.addActionListener(this);
    EFfiltre5.addActionListener(this);
    EFfiltre6.addActionListener(this);
    EFfiltre7.addActionListener(this);

    }


    public void actionPerformed(ActionEvent event) {
    // TODO Auto-generated method stub

    //gestion PBeffacer - Nouvelle recherche
    if (event.getSource() == PBeffacer) {
    EFfiltre1.setText("");
    EFfiltre2.setText("");
    EFfiltre3.setText("");
    EFfiltre4.setText("");
    EFfiltre5.setText("");
    EFfiltre6.setText("");
    EFfiltre7.setText("");
    mob.setSelectedIndex(4);
    fonc.setSelectedIndex(4);
    spec.setSelectedIndex(4); }
    //this.list.clear();

    //gestion PBprev
    if (event.getSource() == PBprev) {
    String [] testlistprev = {"NASCIMENTO CLAUDIO-1",
    "TSUNEJI ROBERTO-1",
    "PEIXOTO ISMAEL-1",
    "LIMA EDUARDO-1",
    "LOPES MARCILIO-1",
    "GIORDANO AFONSO-1",
    "MAYA YRAN-1",
    "BAUDRU PIERRE-1",
    "BAVAY DAVID-1",
    "CUNHA RAONI-1"};
    list = new JList(testlistprev);
    list.setSelectedIndex(0);
    }

    //gestion PBnext
    if (event.getSource() == PBnext) {
    list.setSelectedIndex(13);
    String [] testlistnext = {"NASCIMENTO CLAUDIO2",
    "TSUNEJI ROBERTO2",
    "PEIXOTO ISMAEL2",
    "LIMA EDUARDO2",
    "LOPES MARCILIO2",
    "GIORDANO AFONSO2",
    "MAYA YRAN2",
    "BAUDRU PIERRE2",
    "BAVAY DAVID2",
    "BOITTE JEAN-PAUL2",
    "DE SOUZA PATRICIA2",
    "MACEDO RAFAEL2",
    "SILVA ROBERTO2",
    "NUNES ISABELA2",
    "CUNHA RAONI2"};

    list = new JList(testlistnext); }

    //gestion PBfiltrer
    if (event.getSource() == PBfiltrer) {

    /*
    //DATABASE
    //String dbUrl = "jdbc.odbc.eureka";
    //String dbUrl = "sqljdbc.eureka";
    //String dbUrl = "PC346519167106\SQLEXPRESS";
    //String user = "PC346519167106\Patricia e Pierre";
    String password = "";
    //Class.forName = ("sun.jdbc.odbc.JdbcOdbcDriver");
    try {
    //Connection sur une autre machine
    //jdbc:rmi://192.xxx.xxx.xxx:1099/jdbc.cloudspace:db
    @SuppressWarnings("unused")
    Connection con = DriverManager.getConnection(dbUrl, user, password);
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT NOM, PRENOM FROM CANDIDAT WHERE MOT_CLES_1 = 'COOLGEN'; ");
    while (rs.next()) {
    String nom = rs.getString("nom");
    String prenom = rs.getString("prenom"); }
    EFfiltre4.setText( rs.getString("nom"));
    EFfiltre5.setText( rs.getString("prenom"));
    }
    catch (SQLException e)
    {
    // TODO Auto-generated catch block
    EFfiltre4.setText("erreur");
    EFfiltre5.setText("error");
    e.printStackTrace();
    }
    */
    }
    //gestion PBfermer
    if (event.getSource() == PBfermer) {
    System.exit(0); }

    //gestion PBdetailcv - ouvrir CV word.
    if (event.getSource() == PBdetailcv) {
    //Open word document from java
    try {
    Desktop.getDesktop().open( new File("c:/CV_BAUDRU_Pierre.doc"));
    }
    catch (IOException e)
    {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    //fonc = (JComboBox)event.getSource();
    //String foncselect = (String)fonc.getSelectedItem();

    //gestion DDL fonction
    if (event.getSource() == fonc) {
    if (fonc.getSelectedIndex() == 0){
    spec.removeAllItems();
    spec.insertItemAt("CoolGen", 0);
    spec.insertItemAt("Cobol", 1);
    spec.insertItemAt("Java", 2);
    spec.insertItemAt(".NET", 3);
    spec.setSelectedIndex(0);
    }
    if (fonc.getSelectedIndex() == 1){
    spec.removeAllItems();
    spec.insertItemAt("Account", 0);
    spec.insertItemAt("Production", 1);
    spec.insertItemAt("Reseaux", 2);
    spec.setSelectedIndex(0);
    }
    if (fonc.getSelectedIndex() == 2){
    spec.removeAllItems();
    spec.insertItemAt("Prod", 0);
    spec.insertItemAt("Test", 1);
    spec.insertItemAt("Out", 2);
    spec.insertItemAt("Int", 3);
    spec.setSelectedIndex(0);
    }
    if (fonc.getSelectedIndex() == 3){
    spec.removeAllItems();
    spec.insertItemAt("MAINFRAME", 0);
    spec.insertItemAt("SOLARIS", 1);
    spec.insertItemAt("AIX", 2);
    spec.setSelectedIndex(0);
    }
    if (fonc.getSelectedIndex() == 4){
    spec.removeAllItems();
    spec.insertItemAt("CoolGen", 0);
    spec.insertItemAt("Cobol", 1);
    spec.insertItemAt("Java", 2);
    spec.insertItemAt(".NET", 3);
    spec.insertItemAt("Account", 4);
    spec.insertItemAt("Production", 5);
    spec.insertItemAt("Reseaux", 6);
    spec.insertItemAt("Prod", 7);
    spec.insertItemAt("Test", 8);
    spec.insertItemAt("Int", 9);
    spec.insertItemAt("MAINFRAME", 10);
    spec.insertItemAt("SOLARIS", 11);
    spec.insertItemAt("AIX", 12);
    spec.setSelectedIndex(0);
    }
    }

    //gestion click / doubleclick on list
    if (event.getSource() == list) {
    //usando classe detcand
    //detcand detail = new detcand();
    //detcand.call();
    }
    }

    private void refresh(JList list2) {
    // TODO Auto-generated method stub

    }

    @Override
    public void windowActivated(WindowEvent arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void windowClosed(WindowEvent arg0) {
    // TODO Auto-generated method stub
    }

    private void dispose() {
    // TODO Auto-generated method stub

    }

    @Override
    public void windowClosing(WindowEvent arg0) {
    // TODO Auto-generated method stub
    dispose();
    System.exit(0);
    }

    @Override
    public void windowDeactivated(WindowEvent arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void windowDeiconified(WindowEvent arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void windowIconified(WindowEvent arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void windowOpened(WindowEvent arg0) {
    // TODO Auto-generated method stub

    }

    @Override
    public void mouseClicked(MouseEvent e) {
    // TODO Auto-generated method stub

    }

    @Override
    public void mouseEntered(MouseEvent e) {
    // TODO Auto-generated method stub

    }

    @Override
    public void mouseExited(MouseEvent e) {
    // TODO Auto-generated method stub

    }

    @Override
    public void mousePressed(MouseEvent e) {
    // TODO Auto-generated method stub

    }

    @Override
    public void mouseReleased(MouseEvent e) {
    // TODO Auto-generated method stub

    }

    @Override
    public void valueChanged(ListSelectionEvent arg0) {
    // TODO Auto-generated method stub

    }
    }

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Ouch! Stop right there and go back to the basic tutorials.
    Code Conventions for the Java Programming Language
    Sun's basic Java tutorial
    Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    Your code violates the code conventions.
    You produce procedural code instead of classes and objects.
    You don't use models (see the Swing tutorial)
    You use eclipse without knowing the basics. Stay with an editor and the command line until you can create GUIs, mastered classpaths and packaging.
    Last edited by PhHein; 01-21-2010 at 12:38 PM.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  7. #7
    pbaudru is offline Member
    Join Date
    Jan 2010
    Location
    Athus - Belgium
    Posts
    23
    Rep Power
    0

    Default

    Thanks man for the links, i will read them.....

    Regards, Pierre.

Similar Threads

  1. How to avoid focus()..?
    By ehochedez in forum NetBeans
    Replies: 9
    Last Post: 08-27-2009, 12:32 PM
  2. Avoid using systems DPI settings ?
    By rolfius in forum AWT / Swing
    Replies: 5
    Last Post: 08-03-2009, 04:12 AM
  3. Replies: 0
    Last Post: 07-02-2009, 11:42 AM
  4. how to avoid input errors?
    By Sinnergy in forum New To Java
    Replies: 5
    Last Post: 02-03-2009, 12:25 AM
  5. avoid legitimate spamming
    By hervey in forum Suggestions & Feedback
    Replies: 1
    Last Post: 10-29-2008, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •