Popup, writing to the textfields

I want to have a source code for implementing a window as a popup window to another window .The popup window will appear when a button in the main window is pressed.And
How can i write the values to textFields which are situated rows and columns in a file
murat080598Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
msmolyakConnect With a Mentor Commented:
If I understand you correctly, you want to link the openning of a dialog to a button.  Here is the sample:

Button openButton = new Button("Open");
ActionListener listener = new OpenButtonActionListener();
openButton.addActionListener(listener);

// This is an inner class defined in the same class as the openButton.
class OpenButtonActionListener implements ActionListener
{
  public void actionPerformed(ActionEvent e)
  {
    MyDialog dialog = new MyDialog();
    dialog.setVisible(true);
  }
}

Let me know if you need more information.
0
 
diakovCommented:
Read values and write in lines, when the content of one line is ready. Prepare one, tabulate it and add it to the content of the TextField.
0
 
msmolyakCommented:
The popup window is usually called a dialog. Simply create your own dialog and make it visible when the button is pressed.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
murat080598Author Commented:
Hi msmolyak , i ve created the main window and the dialog window.I wonder wheather you could help me if i send these windows to you .
I look forward to hearing from you soon ,
Regards.
Murat
0
 
msmolyakCommented:
What kind of help do you need. Implementing some type of logic? Why don't you try to describe what you need on this forum first. You can post sections of your code here.
0
 
murat080598Author Commented:
ok
0
 
murat080598Author Commented:
but they are so long it would be easy to send with email:)
0
 
msmolyakCommented:
Again, I'd rather tell you how to address certain problem than try to understand and modify your code. Simply describe what you are unable to do and I will try to help you.
0
 
murat080598Author Commented:
i need soerce codes which are giving a opening dialog window function to a button or button groups ,if you wantto see interface i can send you  by email , give me areply my email is implement@hotmail.com
0
 
murat080598Author Commented:
I also want to send you the interface if you give me an email adreess of your .
0
 
murat080598Author Commented:
do you want to receive these interface and help after looking them?
0
 
murat080598Author Commented:
Hi msmolyak ,
i want get some advises from you :
1)how can i add a gif to a Button and change it due to some results of my program?
2)for opening my popup window there are more than one button ,and there buttons are divided into some groups for example every 4 buuton makes one group and every button opens the same popup window but pop up window must show some results according to groups , how can i arrange these and make a class that i can write and just put in my interfac?
3)how can i combine 4 seperate window into one window,is there a easy way for it?
4)How can i make bound in the two window for example 1st stats the giving some results after a while the second gives values ,then loop starts from the beginning again...?
5)how to add some gifs to a specified area in a empty plane?Can i change it due to the results also?
0
 
msmolyakCommented:
1) This is how you create image button in Swing:
        firstButton = new JButton(new ImageIcon(getClass().getResource("images/b_first_img.gif")));
I do not think you can easily create an image button in AWT (that is you will have to create a new component by drawing a button and an image on top of it).
To change an icon use setIcon(newIcon). You can also specify icons for varios button states (pressed, enabled, disabled, etc.)

2 & 3. Parametrize your window. That is make it a single class (if the layout is the same) but pass some parameter in the constructor to denote which of 4 types this is. (Also you can create a methdo setType() which allows to change the type at runtime).  Another way to do it is to create a common superclass with all the common code (possibly abstract) and 4 subclasses which define what's different for 4 windows. Then each button group will be invoking a particular subclass.

4. I am not sure what the problem is.

5 Create a canvas of the size you need and position it somwhere on the main panel. Then use image drwaing techniques (probably by overriding paint() method of the Canvas class which means that you will have to subclass it) to put an image on the canves. Make the image canvas a listener of an event which causes an image change, change the reference to the gif in the canvas class and repaing the canvas to update the image.

0
 
murat080598Author Commented:
msmolyak can you send me a program that uses jbuttons in order to create image buttons ,and if you can send a popup example program
Regards,
murat

0
 
murat080598Author Commented:
msmolyak i tried to use the jbutton i changed my normal button declerations with the jbuttons but the compiler gives an error like
Window1.java:58: Missing term.
               size1 =  new JButton(ImageIcon(getClass().getResource(*images/face1.gif)));

How can i getrid of this error  and do i have to write an additional class for using getClass.getResource() command?

0
 
murat080598Author Commented:
Hi did you look at your email , i have a question.i m looking forward to hearing from you soon.Regards,
murat
0
 
murat080598Author Commented:
How can i change a window in to a canvas ,cause a want to use 2 window in a container
0
 
murat080598Author Commented:
Hi msmolyak,
Can you send me some examles or information about JDialog ,and writing data to the textfield?did you receive my email ,if so waiting for your reply .
0
 
msmolyakCommented:
I did respond to your e-mail.

To write data to text field use
tf.setText("Some text");

Your error is probably caused by not using quotes around file name.

Window is an independent frame, you cannot use Window in a container.


0
 
murat080598Author Commented:
but i want get data from a file and this file everytimes produces new values , so everytime i want to see values there would be different value so ,is there another way to write tis value to the TextField?

Do you have any examples that adds a window as a popup to another window (it could be using JDialog , or any other ways)

Thanks,
Murat
0
 
murat080598Author Commented:
Now it gives an error ,i think i need ImageIcon method ,do you have ?
 Method ImageIcon(java.net.URL) not found in class Window1.
               size1 =  new JButton(ImageIcon(getClass().getResource("/Image.gif")));
0
 
msmolyakCommented:
You are not following the syntax in my example:
firstButton = new JButton(new ImageIcon(getClass().getResource("images/b_first_img.gif")));

ImageIcon is a class, not a method.

I do not understand your problem with text fields.
0
 
murat080598Author Commented:
Hi msmolyak did you see my last question about popup window ?i would be very pleased if you answer it.
thanks,
Murat
0
 
murat080598Author Commented:
Hi msmolyak can you tell me what are my faults in the classes ,and what changes do i have to do .I m looking forward to hearing from you .
Than you,
Murat


ActionListener list = new ButtonActionListener();
for(int j = 0 ;j<92;j++)
  {
 buttons[j] =new JButton("   ");
  }
for(int i = 93;i<112;i++)  
  {
buttons[i] = new JButton("   ");
buttons[i].ActionListener(list);
  }



and



         class ButtonActionListener implements ActionListener
         {public void actionPerformed(Action Event list)
        
            {
             int t = 0;
             String command = list.getActionCommand();
             if(command.equals.buttons[93]){
               t = 0;
               Popup1.setVisible(true);
               /*  String hex1 = toHex(ha1,r,t);
               String hex2 = toHex(ha1,r,t+1);
               String hex3 = toHex(ha1,r,t+2);
               String hex4 = toHex(ha1,r,t+3);
               String hex5 = toHex(ha1,r,t+4);
               
               String hex6 = toHex(ha2,r,t);
               String hex7 = toHex(ha2,r,t+1);
               String hex8 = toHex(ha2,r,t+2);
               String hex9 = toHex(ha2,r,t+3);
               String hex10 = toHex(ha2,r,t+4);
         */       }
      else if{....
            }
}

and


public void read(){
           HexArray ha1 = new HexArray();
           HexArray ha2 = new HexArray();
           try{
             ha1.read("/home/entmw4/stumf/acar/inputexample.5");
             ha2.read("/home/entmw4/stumf/acar/inputexample.6");
            
             for (int r=0; r<ha1.getRowsNumber() && r<ha2.getrowsNumber;r++){
             for(int c = 0;c <= ha1.getColumnsNumber();c++){
               if(c = 92)
                 {Image im = getToolkit().getImage("images/Empty.gif");
                 for (int k = 0 ; k<92 ;k++){
                   
                  else if(ha1.getItemAt(r,c) == ha2.getItemAt(r,c))
                    {
                      Image im = getToolkit().getImage("images/Equal.gif");}
                  else
                    {
                      Image im = getToolkit().getImage("images/Notequal.gif");
                    }
                 
             
0
All Courses

From novice to tech pro — start learning today.