Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

cannot type anthing in JTextField


hello there,

I have a JDialog form in which i cannot type anthing.what could be the reason

cheers
zolf
Avatar of Mick Barry
Mick Barry
Flag of Australia image

the tf may not be editable.
or the EDT is blocked.
Please post code
Avatar of Zolf

ASKER


      import javax.swing.*;
      import java.sql.*;
      import java.awt.*;
      import java.awt.event.*;

      public class Frm_add_edit_city extends JDialog
      {
            JButton JBUpdate = new JButton();
            JButton JBReset = new JButton();
            JButton JBCancel = new JButton();
            
            JLabel JLPic1 = new JLabel();
            JLabel JLBanner = new JLabel("Please fill required fields.");
            
            JLabel JLCEngName = new JLabel("City Name:");
            JLabel JLCFarName = new JLabel("City Name:");
            JLabel JLCPrefix = new JLabel("City Prefix:");
            
            JTextField JTFCEngName = new JTextField();
            JTextField JTFCFarName = new JTextField();
            JTextField JTFCPrefix = new JTextField();
            
                  
            Dimension screen =       Toolkit.getDefaultToolkit().getScreenSize();
            
            boolean ADDING_STATE;
            
            public Frm_add_edit_city(boolean ADD_STATE,JFrame OwnerForm)
            {
                  super(OwnerForm,true);

                  ADDING_STATE = ADD_STATE;
                  
                  if(ADD_STATE==true)
                  {
                        JLPic1.setIcon(new ImageIcon("images/bNew.png"));
                        setTitle("Add New City");
                        JBUpdate.setText("Update");
                        
                  }
                  else
                  {

                  }
                  
                  JPanel JPContainer = new JPanel();
                  JPContainer.setLayout(null);
                  //-- Add the JLPic1
                  JLPic1.setBounds(5,5,32,32);
                  JPContainer.add(JLPic1);
                  
                  //-- Add the JLBanner
                  JLBanner.setBounds(55,5,268,48);
                  JLBanner.setFont(new Font("Dialog",Font.PLAIN,12));
                  JPContainer.add(JLBanner);
                  
                  //******************** Start adding of input field
                  //-- Add Id Input Field
                  JLCEngName.setBounds(5,50,105,20);
                  JLCEngName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JTFCEngName.setBounds(110,50,200,20);
                  JTFCEngName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JPContainer.add(JLCEngName);
                  JPContainer.add(JTFCEngName);
                  
                  //-- Add Name Input Field
                  JLCFarName.setBounds(5,72,105,20);
                  JLCFarName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JTFCFarName.setBounds(110,72,200,20);
                  JTFCFarName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JPContainer.add(JLCFarName);
                  JPContainer.add(JTFCFarName);
                  //-- Add Contact Name Input Field
                  JLCPrefix.setBounds(5,94,105,20);
                  JLCPrefix.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JTFCPrefix.setBounds(110,94,200,20);
                  JTFCPrefix.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JPContainer.add(JLCPrefix);
                  JPContainer.add(JTFCPrefix);
                  
                  //******************** End adding of input field
                  
                  //-- Add the JBUpdate     5,318,105,25
                  JBUpdate.setBounds(5,135,105,25);
                  JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12));
                  JBUpdate.setMnemonic(KeyEvent.VK_A);
                  JBUpdate.addActionListener(JBActionListener);
                  JBUpdate.setActionCommand("update");
                  JPContainer.add(JBUpdate);
                  
                  //-- Add the JBReset
                  JBReset.setBounds(112,135,99,25);
                  JBReset.setFont(new Font("Dialog", Font.PLAIN, 12));
                  JBReset.setMnemonic(KeyEvent.VK_R);
                  JBReset.addActionListener(JBActionListener);
                  JBReset.setActionCommand("reset");
                  JPContainer.add(JBReset);
                  
                  //-- Add the JBCancel
                  JBCancel.setBounds(212,135,99,25);
                  JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12));
                  JBCancel.setMnemonic(KeyEvent.VK_C);
                  JBCancel.addActionListener(JBActionListener);
                  JBCancel.setActionCommand("cancel");
                  JPContainer.add(JBCancel);
                  
                  getContentPane().add(JPContainer);
                  setSize(325,200);
                  setResizable(false);
                  setLocation((screen.width - 325)/2,((screen.height-383)/2));
            }
            
            private boolean RequiredFieldEmpty()
            {
                  if(JTFCEngName.getText().equals(""))
                  {
                        JOptionPane.showMessageDialog(null,"Some required fields is/are empty.\nPlease check it and try again.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE);
                        JTFCEngName.requestFocus();
                        return true;
                  }
                  else
                  {
                        return false;
                  }
            }
            
            private void clearFields()
            {
                  JTFCEngName.setText("");
                  JTFCFarName.setText("");
                  JTFCPrefix.setText("");
            }
            
            ActionListener JBActionListener = new ActionListener(){
                  public void actionPerformed(ActionEvent e)
                  {
                        String srcObj = e.getActionCommand();
                        if(srcObj=="update")
                        {
                              if(RequiredFieldEmpty()==false)
                              {
                                    if(ADDING_STATE == true)
                                    {
                                          
                                    }
                                    else
                                    {
                                          
                                    }
                              }
                        }else if(srcObj=="reset"){
                              clearFields();
                        }else if(srcObj=="cancel"){
                              dispose();
                        }
                  }
            };
            
      }
Avatar of Zolf

ASKER



what is EDT
Avatar of Giant2
Giant2

your textfield could be not editable (like objects told) or it could be not enabled.
txtField.setEditable(true);
txtField.setEnabled(true);

...
Or you create another JDialog in modal mode and not display it.

Bye, Giant.
the problems more likely to be with how you use the dialog, rather than in the dialog itself.

> what is EDT

Event Dispatch Thread
The thread that handles gui processing

>                     if(srcObj=="update")

btw, that (and others) should use equals() not ==
Avatar of Zolf

ASKER


thanks for that equals but how do i solve my textfield problem
hard to say without seeing how your using the dialog
Avatar of Zolf

ASKER

I call that class Frm_add_edit_city(true,JFParentFrame,"",""); in another class which extends JInternalFrame

private JToolBar createToolbar()
    {
          final JToolBar tb = new JToolBar();
          //.. create tool bar buttons
          JButton b1 = new JButton("Add City", testIcon);
          b1.setFocusPainted(false);
          b1.setToolTipText("Test toolbar button : icon + text");
          b1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae)
                {
                      JDialog JDAdd = new Frm_add_edit_city(true,JFParentFrame,"","");
                        JDAdd.show();
                }
          });
Try setting modal to false when you create the JDIalog
Try


JDialog JDAdd = new Frm_add_edit_city(true,JFParentFrame,"","");
JDAdd.setModal(false);
JDAdd.setVisible(true);
I see:
Frm_add_edit_city(true,JFParentFrame,"","");
but no method in your class with 4 parameters
only 2:
Frm_add_edit_city(boolean ADD_STATE,JFrame OwnerForm)

In this manner the method used to create is the super (without your settings)
That can't be what you're running, you don't have a match ctor.
Avatar of Zolf

ASKER


no,does not help changing to
JDAdd.setModal(false);
JDAdd.setVisible(true);

gaints2 that is correct in my code it takes 4 parameters, i pasted wrong

public Frm_add_edit_city(boolean ADD_STATE,JFrame OwnerForm,String srcCN,String srcSQL)
            {
You have:
>super(OwnerForm,true);
try to use:

super(OwnerForm,false);

instead.
Avatar of Zolf

ASKER


in my main class which extends JFrame and uses
//Set up the GUI.
            desktop = new JDesktopPane();
                  
            setContentPane(desktop);

then when u select a menuitem this methids gets called:

protected void createFrame()
 {
            
            frame = new MyInternalFrame(this);      //this class extends JInternalFrame
            frame.setVisible(true); //necessary as of 1.3
            desktop.add(frame);
            try {
                  frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
      }

then in this class MyInternalFrame I have a toolbar with this

private JToolBar createToolbar()
    {
          final JToolBar tb = new JToolBar();
          //.. create tool bar buttons
          JButton b1 = new JButton("Add City", testIcon);
          b1.setFocusPainted(false);
          b1.setToolTipText("Test toolbar button : icon + text");
          b1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae)
                {
                      ////JOptionPane.showConfirmDialog(tb, "Was pressed Button 1");
                      JDialog JDAdd = new Frm_add_edit_city(true,JFParentFrame,"","");          
                      JDAdd.setModal(false);
                      JDAdd.setVisible(true);
                        //JDAdd.show();
                }
          });
          tb.add(b1);
In your Frm_add_edit_city class you have:
>super(OwnerForm,true);
try to specify "false" instead.
> JFParentFrame

where does that get defined?
what happens if you pass null there instead?
Avatar of Zolf

ASKER


it does not help gaint

>super(OwnerForm,true);
try to specify "false" instead.
Avatar of Zolf

ASKER


objects i defined a JFrame in TreeTableInternalFrame

JFrame JFParentFrame;
      
    public TreeTableInternalFrame(final PictMenuFrameDemo frame)
    {
        super("InternalFrame",
              true, //resizable
              true, //closable
              true, //maximizable
              true);//iconifiable

        Dimension deskSize = frame.getDesktop().getSize();
        setSize((int)deskSize.getWidth() - 20, (int)deskSize.getHeight() - 20);
        //Set the window's location.
        setLocation(10, 10);
        JFParentFrame = frame;
I'd suggest simplifying things by stripping it down to the basics until you can pinpoint whats causing it.
for example, remove all the fields from the dialog except a single text field.
and try creating the dialog from different sections in your code, and see if that makes a difference.
Once you can create a simple example that works (or doesn't), it'll be a lot easier to pinpoint the cause.
To debug try to use a JOptionPane in the createToolBar method instead of JDialog:
String text = JOptionPane.showInputDialog(JFParentFrame, "Debugging");

Do you can modify the textField in this OptionPanel?
Avatar of Zolf

ASKER


no even using JOptionPane i cannot type anything.
 String text = JOptionPane.showInputDialog(JFParentFrame, "Debugging");

i have got a feeling i am messing with the JFParentFrame,i am not calling the corrent window
what happens if you pass null instead of parent frame?
Avatar of Zolf

ASKER


when i do this too
String text = JOptionPane.showInputDialog(null, "Debugging");

i cannot type
try this:

EventQueue.invokeLater(new Runnable()
{
   public void run()
   {
       String text = JOptionPane.showInputDialog(null, "Debugging");
   }
});
Avatar of Zolf

ASKER


Does not help.on simple forms i have made it to work,but when i try to complicate it,it does not work.
Avatar of Zolf

ASKER


do you want me to send the complete code for the 3 class
Does the dialog work by itself, ie if you just create one directly from main
Avatar of Zolf

ASKER


I tried this in main()

EventQueue.invokeLater(new Runnable()
{
   public void run()
   {
       String text = JOptionPane.showInputDialog(null, "Debugging");
   }
});


but still i cannot type in it.....
Do you have other jTextField in your application? Do you can change them?
If in the main you cannot do (like you told before) seems a GUI system problem.
Avatar of Zolf

ASKER


i dont have any JTextField in my application.

i dont understand.i cannot also start from scratch becasue i have written loads of code to do other things.

please help
Avatar of Zolf

ASKER


but when i enter default values in the JTextfield like this

JTextfield  jtf = new JTextfield("hello there");

and i see the result in the JDialog.but i cannot again delete it.
I have a doubt. Are you sure the code you are using is the one you are debugging?
If you use something like Eclipse, JBuilder, NetBeans,... try to debug step by step and see if you pass from the code we are commenting.

>do you want me to send the complete code for the 3 class
As last chance, do you can publish the code on some site we can see it? (here the thread can became really big)
Avatar of Zolf

ASKER


i use eclipse.i will try to debug

thank you all guys for your help
Avatar of Zolf

ASKER


hello there,

when i try to debug the application.when it reaches line
public Frm_add_edit_city(boolean ADD_STATE,final JFrame OwnerForm,String srcCN,String srcSQL)
{
                  super(OwnerForm,true);

the eclipse degugger shows this when initialising the above class:what does it mean is it correct
Frm_add_edit_city[dialog0,0,0,0x0,invalid,hidden,disabled,modeless,defaultCloseOperation=DO_NOTHING_ON_CLOSE,rootPane=,rootPaneCheckingEnabled=false]
Avatar of Zolf

ASKER


this is the three classes which i am using,i have only shown the bits which is related to that Textfield.please help

public class PictMenuFrameDemo extends JFrame
                                    implements ActionListener {
      public static final String DEFAULT_PROPERTY_FILE = "db.properties";
      
      JDesktopPane desktop;
      MyInternalFrame frame = null;
      TreeTableInternalFrame tframe = null;
      
      private ImageIcon menuOneIm = null;
      private ImageIcon menuTwoIm = null;
      private ImageIcon menuTreeIm = null;
      
      private ImageIcon smenuOneIm = null;
      private ImageIcon smenuTwoIm = null;
      
      Connection connect = null;
      
      

      public PictMenuFrameDemo() {
            super("PictMenuFrameDemo");

            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                        screenSize.width  - inset*2,
                        screenSize.height - inset*2);

            //Set up the GUI.
            desktop = new JDesktopPane();       //a specialized layered pane
            createFrame();                               
            setContentPane(desktop);
            
            // create menu
            setJMenuBar(createMenuBar());
            // create db connection
            initConnection();

            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
            
      }

protected void createFrame()
{
            
            tframe = new TreeTableInternalFrame(this);
            tframe.setVisible(true);
            desktop.add(tframe);
            try {
                  tframe.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
}

----------------------

public class TreeTableInternalFrame extends JInternalFrame
{
      private ImageIcon testIcon;
      private ImageIcon cityIcon;
    private ImageIcon coIcon;
    private ImageIcon dslamIcon;
    private ImageIcon linecardIcon;

    private DefaultMutableTreeNode lastSelectedNode;
      
      private JTree tree;
      private JTable cityTable;
      private JTable coTable;
      private JTable dslamTable;
      private JTable linecardTable;
      private JTabbedPane tabPane;
      
      private JPopupMenu treePopupMenu;
      
      private Vector cityCollect;
      private Vector coCollect;
      private Vector dslamCollect;
      private Vector linecardCollect;
      
      PictMenuFrameDemo JFParentFrame;
      
    public TreeTableInternalFrame(final PictMenuFrameDemo frame)
    {
        super("InternalFrame",
              true, //resizable
              true, //closable
              true, //maximizable
              true);//iconifiable

        Dimension deskSize = frame.getDesktop().getSize();
        setSize((int)deskSize.getWidth() - 20, (int)deskSize.getHeight() - 20);
        //Set the window's location.
        setLocation(10, 10);
        JFParentFrame = frame;
        //get database result in to collections
        initCollections(frame.getDBConnection());
       
        //set layout for frame content panel
        Container cp = getContentPane();
        cp.setLayout(new BorderLayout());
       
        //create toolbar
        JToolBar toolbar = createToolbar();           //this method is described below where i call a JDialog
        cp.add(toolbar, BorderLayout.NORTH);

        // create popup menu for tree
        treePopupMenu = createPopupMenu();

        // create tree element
        createAndInitTree();
       
                      
       JScrollPane jsp = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
       
       
        //create tab panel
        tabPane = new JTabbedPane();
       
        JPanel cityPane = new JPanel(new BorderLayout());
        createCityTable();
        JScrollPane jspCity = new JScrollPane(cityTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        cityPane.add(jspCity, BorderLayout.CENTER);
        tabPane.addTab("  City  ", cityIcon, cityPane);
       
       
        JPanel coPane = new JPanel(new BorderLayout());
        createCoTable();
        JScrollPane jspCo = new JScrollPane(coTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        coPane.add(jspCo, BorderLayout.CENTER);
        tabPane.addTab("   Co   ", coIcon, coPane);
       
        JPanel dslamPane = new JPanel(new BorderLayout());
        createDslamTable();
        JScrollPane jspDslam = new JScrollPane(dslamTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        dslamPane.add(jspDslam, BorderLayout.CENTER);
        tabPane.addTab("  Dslam  ", dslamIcon, dslamPane);
       
       
        JPanel linecardPane = new JPanel(new BorderLayout());
        createlinecardTable();
        JScrollPane jspLinecard = new JScrollPane(linecardTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        linecardPane.add(jspLinecard, BorderLayout.CENTER);
        tabPane.addTab("  Linecard  ", linecardIcon, linecardPane);          
 
    }

private JToolBar createToolbar()
    {
          final JToolBar tb = new JToolBar();
          //.. create tool bar buttons
          JButton b1 = new JButton("Add City", testIcon);
          b1.setFocusPainted(false);
          b1.setToolTipText("Test toolbar button : icon + text");
          b1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae)
                {
                      ////JOptionPane.showConfirmDialog(tb, "Was pressed Button 1");
                      //String text = JOptionPane.showInputDialog(null, "Debugging");
                      /*EventQueue.invokeLater(new Runnable()
                                  {
                                     public void run()
                                     {
                                         String text = JOptionPane.showInputDialog(tb, "Debugging");
                                     }
                                  });*/

                      JDialog JDAdd = new Frm_add_edit_city(true,JFParentFrame,"","");
                      JDAdd.setModal(false);
                           JDAdd.show();
                }
          });
          tb.add(b1);
          
          JButton b2 = new JButton(testIcon);
          b2.setFocusPainted(false);
          b2.setToolTipText("Test toolbar button : only icon");
          b2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                      //JOptionPane.showConfirmDialog(tb, "Was pressed Button 2");
                      String text = JOptionPane.showInputDialog(tb, "Debugg 22");
                }
          });
          tb.add(b2);
          
          JButton b3 = new JButton("Button 3");
          b3.setFocusPainted(false);
          b3.setToolTipText("Test toolbar button : only text");
          b3.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                      JOptionPane.showConfirmDialog(tb, "Was pressed Button 3");
                }
          });
          tb.add(b3);
          
          // only for set same button size
          int h1 = b1.getPreferredSize().height;
          int h2 = b2.getPreferredSize().height;
          int h = Math.max(h1, h2);
          int h3 = b3.getPreferredSize().height;
          h = Math.max(h, h3);
          
          b1.setPreferredSize(new Dimension(b1.getPreferredSize().width, h));
          b1.setMaximumSize(new Dimension(b1.getPreferredSize().width, h));
          
          b2.setPreferredSize(new Dimension(b2.getPreferredSize().width, h));
          b2.setMaximumSize(new Dimension(b2.getPreferredSize().width, h));
          
          b3.setPreferredSize(new Dimension(b3.getPreferredSize().width, h));
          b3.setMaximumSize(new Dimension(b3.getPreferredSize().width, h));
          //----------------
          
          tb.setFloatable(false);
          return tb;
    }

--------------------------------------------------

public class Frm_add_edit_city extends JDialog
      {
            JButton JBUpdate = new JButton(new ImageIcon("images/save.png"));
            JButton JBReset = new JButton("Reset",new ImageIcon("images/reset.png"));
            JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png"));
            
            JLabel JLPic1 = new JLabel();
            JLabel JLBanner = new JLabel("Please fill-up all the required fields.");
            
            JLabel JLCEngName = new JLabel("City Name:");
            JLabel JLCFarName = new JLabel("City Name:");
            JLabel JLCPrefix = new JLabel("City Prefix:");
            
            JTextField JTFCEngName = new JTextField("asds");
            JTextField JTFCFarName = new JTextField();
            JTextField JTFCPrefix = new JTextField();
            
            Connection cnAEC;
            Statement stAEC;
            ResultSet rsAEC;
                  
            Dimension screen =       Toolkit.getDefaultToolkit().getScreenSize();
            
            boolean ADDING_STATE;
            
            public Frm_add_edit_city(boolean ADD_STATE,final JFrame OwnerForm,String srcCN,String srcSQL)
            {
                  super(OwnerForm,true);
                  ////cnAEC = srcCN;
                  ADDING_STATE = ADD_STATE;
                  /*try{
                        stAEC = cnAEC.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                  }catch( SQLException sqlEx){
                        System.out.println("\nERROR IN frm_add_edit_customer(frm_add_edit_customer):" + sqlEx + "\n");
                  }*/
                  
                  //JCBCountry = clsPublicMethods.fillCombo("SELECT * FROM tblCountry",cnAEC,"Name");
                  JTFCEngName.setEditable(true);
                  JTFCFarName.setEnabled(true);
                  if(ADD_STATE==true)
                  {
                        JLPic1.setIcon(new ImageIcon("images/bNew.png"));
                        setTitle("Add New City");
                        JBUpdate.setText("Update");
                        
                  }
                  else
                  {
                        
                  }
                  
                  JPanel JPContainer = new JPanel();
                  JPContainer.setLayout(null);
                  //-- Add the JLPic1
                  JLPic1.setBounds(5,5,32,32);
                  JPContainer.add(JLPic1);
                  
                  //-- Add the JLBanner
                  JLBanner.setBounds(55,5,268,48);
                  JLBanner.setFont(new Font("Dialog",Font.PLAIN,12));
                  JPContainer.add(JLBanner);
                  
                  //******************** Start adding of input field
                  //-- Add Id Input Field
                  JLCEngName.setBounds(5,50,105,20);
                  JLCEngName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JTFCEngName.setBounds(110,50,200,20);
                  JTFCEngName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JPContainer.add(JLCEngName);
                  JPContainer.add(JTFCEngName);
                  
                  //-- Add Name Input Field
                  JLCFarName.setBounds(5,72,105,20);
                  JLCFarName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JTFCFarName.setBounds(110,72,200,20);
                  JTFCFarName.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JPContainer.add(JLCFarName);
                  JPContainer.add(JTFCFarName);
                  //-- Add Contact Name Input Field
                  JLCPrefix.setBounds(5,94,105,20);
                  JLCPrefix.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JTFCPrefix.setBounds(110,94,200,20);
                  JTFCPrefix.setFont(new Font("Dialog",Font.PLAIN,12));
                  
                  JPContainer.add(JLCPrefix);
                  JPContainer.add(JTFCPrefix);
                  
                  //******************** End adding of input field
                  
                  //-- Add the JBUpdate     5,318,105,25
                  JBUpdate.setBounds(5,135,105,25);
                  JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12));
                  JBUpdate.setMnemonic(KeyEvent.VK_A);
                  JBUpdate.addActionListener(JBActionListener);
                  JBUpdate.setActionCommand("update");
                  JPContainer.add(JBUpdate);
                  
                  //-- Add the JBReset
                  JBReset.setBounds(112,135,99,25);
                  JBReset.setFont(new Font("Dialog", Font.PLAIN, 12));
                  JBReset.setMnemonic(KeyEvent.VK_R);
                  JBReset.addActionListener(JBActionListener);
                  JBReset.setActionCommand("reset");
                  JPContainer.add(JBReset);
                  
                  //-- Add the JBCancel
                  JBCancel.setBounds(212,135,99,25);
                  JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12));
                  JBCancel.setMnemonic(KeyEvent.VK_C);
                  JBCancel.addActionListener(JBActionListener);
                  JBCancel.setActionCommand("cancel");
                  JPContainer.add(JBCancel);
                  
                  getContentPane().add(JPContainer);
                  setSize(325,200);
                  setResizable(false);
                  setLocation((screen.width - 325)/2,((screen.height-383)/2));
            }
I try to compile the code you posted but I do not find:
JBActionListener
MyInternalFrame
PictMenuFrameDemo has many many method not declared
I comment many things and try your code. It goes, permits editing JTextField.
I use Eclipse 2.1.2 and java Version 1.4.2_06
Avatar of Zolf

ASKER


Hi gaints2,

i just posted all the class that are related to opening the Jdialog form.
i am using eclipse Version: 3.1.2 and java 1.4.2

so did it work for you??i mean can you type inside those JTextfield inside the JDialog
>so did it work for you??i mean can you type inside those JTextfield inside the JDialog
Yes!
I commented the connection, the action listener not needed, and so on. It permits edit the JTextFields inside the JDialog (city,...)
Avatar of Zolf

ASKER


in which class did you comment those stuffs
These are the line commented:
PictMenuFrameDemo:
implements ActionListener
MyInternalFrame frame = null; and substitue by JFrame frame = null;
setJMenuBar(createMenuBar());
initConnection();

TreeTableInternalFrame:
Dimension deskSize = frame.getDesktop().getSize();
setSize((int) deskSize.getWidth() - 20, (int) deskSize.getHeight() - 20); and substitued by setSize((int) 500, (int) 600);
initCollections(frame.getDBConnection());
treePopupMenu = createPopupMenu();
createAndInitTree();
createCityTable();
createCoTable();
createDslamTable();
createlinecardTable();


Frm_add_edit_city:
JBUpdate.addActionListener(JBActionListener);
JBReset.addActionListener(JBActionListener);
JBCancel.addActionListener(JBActionListener);

I think your problem could be find in the definition of MyInternalFrame.
Other commented lines aren't so critical for displaying.
Could you see it? OR try to comment it's creation in PictMenuFrameDemo as I did. See if something changes.
Avatar of Zolf

ASKER


actually i am not using this class MyInternalFrame anywere in my code.
Avatar of Zolf

ASKER


i have deleted the class to make sure it is not causing the trouble. but i still could not type in the JDialog.

tell me something

PictMenuFrameDemo JFParentFrame;
public TreeTableInternalFrame(final PictMenuFrameDemo frame)
{

JFParentFrame =  frame;

is it same as

JFrame JFParentFrame;
public FrmCustomer(Connection srcCN,JFrame getParentFrame)
{

JFParentFrame = getParentFrame;
Avatar of Zolf

ASKER



is it same as

JFrame JFParentFrame;
public TreeTableInternalFrame(JFrame getParentFrame)
{

JFParentFrame = getParentFrame;
Yes they are the same if PictMenuFrameDemo and JFrame are the same.
>actually i am not using this class MyInternalFrame anywere in my code.
>i have deleted the class to make sure it is not causing the trouble.

Even in the code you have substitued all the MyInternalFrame occurrence with JFrame?
Even if you delete the class, the rebuild process rebuild all classes if they are (used) in the project.
Avatar of Zolf

ASKER


PictMenuFrameDemo extends JFrame
>PictMenuFrameDemo extends JFrame
Ok. So the two pieces of code before are the same.
Avatar of Zolf

ASKER


i dont know what to do,i have wriiten so much code and now getting this problem is fustrating.

can i send you my complete application so you can have a look.

please help
I believe you cannot. I'll ask to moderator. Wait please.
Avatar of Zolf

ASKER


ok
Avatar of Zolf

ASKER


i have sent,could you please let me know when you receive it.
Avatar of Zolf

ASKER



did you receive it
Downloaded and running.
I have not the DB you are referring so I must comment all the connection you are doing.
The problem is on clicking Add New. Isn't it?
Avatar of Zolf

ASKER


yes
Avatar of Zolf

ASKER


no,when you click add new a JInternal frame opens. then when you clcik on the button in the JInternalFrame
Avatar of Zolf

ASKER


the buton in the JInternalframe is called add city,the jdialog opens with JTextfield in it
right! It not permit to change. I search for the bug.
Avatar of Zolf

ASKER


thanks mate
Find it!
In SimplePictMenu you have dispatchKeyEvent method.
If it return everytime true, the change on the windows aren't executed out.
So now I'm trying to find a way to bypass this check.
Avatar of Zolf

ASKER


appreciate your help,i was workin gon this bit since yesterday.
ASKER CERTIFIED SOLUTION
Avatar of Giant2
Giant2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zolf

ASKER


appreciate your help.can you please tell me what was causing the error.

You declared the SimplePictMenu class dispatching the keyEvent of your application.
So when a key was pressed the control passes from this method (dispatchKeyEvent).
In this method you simply create a new KeyEvent and return everytime true, so the GUI see this true as "the Event is terminated". In this manner the event is stopped at that point and do not go to the thread make change to your GUI.
Now the true is returned only when a doAction() is called. In all the other cases it return false and the Event can be finished by the other handler.

Hope I explain the reason in a comphrensible way.
:-)
Tx accepting.

Bye, Giant.
Venabili,
allready done. I posted the modified code and the comment to better understand (I hope) the reason of modify.
:-)

P.S. This new feature (public space to share the java file) is a really good thing. Thanks.
Yes but:
1. This does not mean that the relevant parts should not be posted in the question as above. The questions should be really worth reading without downloading a bunch of files...
2. If we speak for one class, it is still better to post it here directly :)
Avatar of Zolf

ASKER


Thanks very much guys for your help.