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
zolfAsked:
Who is Participating?
 
Giant2Connect With a Mentor Commented:
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
 
objectsCommented:
the tf may not be editable.
or the EDT is blocked.
0
 
CEHJCommented:
Please post code
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
zolfAuthor Commented:

      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
 
zolfAuthor Commented:


what is EDT
0
 
Giant2Commented:
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
 
objectsCommented:
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
 
zolfAuthor Commented:

thanks for that equals but how do i solve my textfield problem
0
 
objectsCommented:
hard to say without seeing how your using the dialog
0
 
zolfAuthor Commented:
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
 
CEHJCommented:
Try setting modal to false when you create the JDIalog
0
 
CEHJCommented:
Try


JDialog JDAdd = new Frm_add_edit_city(true,JFParentFrame,"","");
JDAdd.setModal(false);
JDAdd.setVisible(true);
0
 
Giant2Commented:
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
 
objectsCommented:
That can't be what you're running, you don't have a match ctor.
0
 
zolfAuthor Commented:

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
 
Giant2Commented:
You have:
>super(OwnerForm,true);
try to use:

super(OwnerForm,false);

instead.
0
 
zolfAuthor Commented:

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
 
Giant2Commented:
In your Frm_add_edit_city class you have:
>super(OwnerForm,true);
try to specify "false" instead.
0
 
objectsCommented:
> JFParentFrame

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

it does not help gaint

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

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
 
objectsCommented:
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
 
Giant2Commented:
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
 
zolfAuthor Commented:

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
 
objectsCommented:
what happens if you pass null instead of parent frame?
0
 
zolfAuthor Commented:

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

i cannot type
0
 
objectsCommented:
try this:

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

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

do you want me to send the complete code for the 3 class
0
 
objectsCommented:
Does the dialog work by itself, ie if you just create one directly from main
0
 
zolfAuthor Commented:

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
 
Giant2Commented:
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
 
zolfAuthor Commented:

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
 
zolfAuthor Commented:

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
 
Giant2Commented:
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
 
zolfAuthor Commented:

i use eclipse.i will try to debug

thank you all guys for your help
0
 
zolfAuthor Commented:

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
 
zolfAuthor Commented:

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
 
Giant2Commented:
I try to compile the code you posted but I do not find:
JBActionListener
MyInternalFrame
PictMenuFrameDemo has many many method not declared
0
 
Giant2Commented:
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
 
zolfAuthor Commented:

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
 
Giant2Commented:
>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
 
zolfAuthor Commented:

in which class did you comment those stuffs
0
 
Giant2Commented:
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
 
zolfAuthor Commented:

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

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
 
zolfAuthor Commented:


is it same as

JFrame JFParentFrame;
public TreeTableInternalFrame(JFrame getParentFrame)
{

JFParentFrame = getParentFrame;
0
 
Giant2Commented:
Yes they are the same if PictMenuFrameDemo and JFrame are the same.
0
 
Giant2Commented:
>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
 
zolfAuthor Commented:

PictMenuFrameDemo extends JFrame
0
 
Giant2Commented:
>PictMenuFrameDemo extends JFrame
Ok. So the two pieces of code before are the same.
0
 
zolfAuthor Commented:

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
 
Giant2Commented:
I believe you cannot. I'll ask to moderator. Wait please.
0
 
zolfAuthor Commented:

ok
0
 
zolfAuthor Commented:

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


did you receive it
0
 
Giant2Commented:
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
 
zolfAuthor Commented:

yes
0
 
zolfAuthor Commented:

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

the buton in the JInternalframe is called add city,the jdialog opens with JTextfield in it
0
 
Giant2Commented:
right! It not permit to change. I search for the bug.
0
 
zolfAuthor Commented:

thanks mate
0
 
Giant2Commented:
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
 
zolfAuthor Commented:

appreciate your help,i was workin gon this bit since yesterday.
0
 
zolfAuthor Commented:

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

0
 
Giant2Commented:
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
 
Giant2Commented:
:-)
Tx accepting.

Bye, Giant.
0
 
Giant2Commented:
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
 
VenabiliCommented:
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
 
zolfAuthor Commented:

Thanks very much guys for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.