?
Solved

cannot type anthing in JTextField

Posted on 2006-05-02
73
Medium Priority
?
601 Views
Last Modified: 2013-12-03

hello there,

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

cheers
zolf
0
Comment
Question by:zolf
  • 35
  • 22
  • 9
  • +2
70 Comments
 
LVL 92

Expert Comment

by:objects
ID: 16584447
the tf may not be editable.
or the EDT is blocked.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16584449
Please post code
0
 

Author Comment

by:zolf
ID: 16584474

      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();
                        }
                  }
            };
            
      }
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zolf
ID: 16584476


what is EDT
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16584479
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.
0
 
LVL 92

Expert Comment

by:objects
ID: 16584487
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 ==
0
 

Author Comment

by:zolf
ID: 16584515

thanks for that equals but how do i solve my textfield problem
0
 
LVL 92

Expert Comment

by:objects
ID: 16584520
hard to say without seeing how your using the dialog
0
 

Author Comment

by:zolf
ID: 16584521
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();
                }
          });
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16584523
Try setting modal to false when you create the JDIalog
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16584532
Try


JDialog JDAdd = new Frm_add_edit_city(true,JFParentFrame,"","");
JDAdd.setModal(false);
JDAdd.setVisible(true);
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16584535
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)
0
 
LVL 92

Expert Comment

by:objects
ID: 16584553
That can't be what you're running, you don't have a match ctor.
0
 

Author Comment

by:zolf
ID: 16584573

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)
            {
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16584582
You have:
>super(OwnerForm,true);
try to use:

super(OwnerForm,false);

instead.
0
 

Author Comment

by:zolf
ID: 16584603

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);
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16584613
In your Frm_add_edit_city class you have:
>super(OwnerForm,true);
try to specify "false" instead.
0
 
LVL 92

Expert Comment

by:objects
ID: 16584624
> JFParentFrame

where does that get defined?
what happens if you pass null there instead?
0
 

Author Comment

by:zolf
ID: 16584647

it does not help gaint

>super(OwnerForm,true);
try to specify "false" instead.
0
 

Author Comment

by:zolf
ID: 16584655

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;
0
 
LVL 92

Expert Comment

by:objects
ID: 16584685
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.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16584721
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?
0
 

Author Comment

by:zolf
ID: 16584765

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
0
 
LVL 92

Expert Comment

by:objects
ID: 16584769
what happens if you pass null instead of parent frame?
0
 

Author Comment

by:zolf
ID: 16584786

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

i cannot type
0
 
LVL 92

Expert Comment

by:objects
ID: 16584815
try this:

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

Author Comment

by:zolf
ID: 16584853

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

Author Comment

by:zolf
ID: 16584861

do you want me to send the complete code for the 3 class
0
 
LVL 92

Expert Comment

by:objects
ID: 16584930
Does the dialog work by itself, ie if you just create one directly from main
0
 

Author Comment

by:zolf
ID: 16584998

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.....
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16585014
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.
0
 

Author Comment

by:zolf
ID: 16585072

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
0
 

Author Comment

by:zolf
ID: 16585093

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.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16585135
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)
0
 

Author Comment

by:zolf
ID: 16585167

i use eclipse.i will try to debug

thank you all guys for your help
0
 

Author Comment

by:zolf
ID: 16593284

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]
0
 

Author Comment

by:zolf
ID: 16593390

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));
            }
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16593741
I try to compile the code you posted but I do not find:
JBActionListener
MyInternalFrame
PictMenuFrameDemo has many many method not declared
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16593875
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
0
 

Author Comment

by:zolf
ID: 16593919

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
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16593932
>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,...)
0
 

Author Comment

by:zolf
ID: 16593952

in which class did you comment those stuffs
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594002
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.
0
 

Author Comment

by:zolf
ID: 16594169

actually i am not using this class MyInternalFrame anywere in my code.
0
 

Author Comment

by:zolf
ID: 16594188

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;
0
 

Author Comment

by:zolf
ID: 16594198


is it same as

JFrame JFParentFrame;
public TreeTableInternalFrame(JFrame getParentFrame)
{

JFParentFrame = getParentFrame;
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594205
Yes they are the same if PictMenuFrameDemo and JFrame are the same.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594210
>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.
0
 

Author Comment

by:zolf
ID: 16594211

PictMenuFrameDemo extends JFrame
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594226
>PictMenuFrameDemo extends JFrame
Ok. So the two pieces of code before are the same.
0
 

Author Comment

by:zolf
ID: 16594240

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
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594257
I believe you cannot. I'll ask to moderator. Wait please.
0
 

Author Comment

by:zolf
ID: 16594275

ok
0
 

Author Comment

by:zolf
ID: 16594348

i have sent,could you please let me know when you receive it.
0
 

Author Comment

by:zolf
ID: 16594461


did you receive it
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594784
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?
0
 

Author Comment

by:zolf
ID: 16594789

yes
0
 

Author Comment

by:zolf
ID: 16594800

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

Author Comment

by:zolf
ID: 16594833

the buton in the JInternalframe is called add city,the jdialog opens with JTextfield in it
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16594835
right! It not permit to change. I search for the bug.
0
 

Author Comment

by:zolf
ID: 16594845

thanks mate
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16595010
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.
0
 

Author Comment

by:zolf
ID: 16595022

appreciate your help,i was workin gon this bit since yesterday.
0
 
LVL 12

Accepted Solution

by:
Giant2 earned 2000 total points
ID: 16595070
Go in SimplePictMenu and change in this manner:
      public boolean dispatchKeyEvent(KeyEvent e) {
            KeyEvent kee = new KeyEvent((Component)this, e.getID(), e.getWhen(),
                        e.getModifiers(), e.getKeyCode(),e.getKeyChar());
            if (isSelected()) {
                  if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_SPACE) {
                        kee = new KeyEvent((Component)this, e.getID(), e.getWhen(),
                                    e.getModifiers(), 27, (char)27);
                        doAction();
                                return true;
                  }
            }
            return false;
      }

On my Eclipse it works.

Bye, Giant.
0
 

Author Comment

by:zolf
ID: 16595089

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

0
 
LVL 12

Expert Comment

by:Giant2
ID: 16595127
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.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16595147
:-)
Tx accepting.

Bye, Giant.
0
 
LVL 12

Expert Comment

by:Giant2
ID: 16595187
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.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 16595218
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 :)
0
 

Author Comment

by:zolf
ID: 16596300

Thanks very much guys for your help.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question