Link to home
Start Free TrialLog in
Avatar of murat080598
murat080598

asked on

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
Avatar of diakov
diakov

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.
The popup window is usually called a dialog. Simply create your own dialog and make it visible when the button is pressed.
Avatar of murat080598

ASKER

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
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.
ok
but they are so long it would be easy to send with email:)
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.
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
ASKER CERTIFIED SOLUTION
Avatar of msmolyak
msmolyak

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
I also want to send you the interface if you give me an email adreess of your .
do you want to receive these interface and help after looking them?
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?
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.

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

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?

Hi did you look at your email , i have a question.i m looking forward to hearing from you soon.Regards,
murat
How can i change a window in to a canvas ,cause a want to use 2 window in a container
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 .
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.


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
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")));
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.
Hi msmolyak did you see my last question about popup window ?i would be very pleased if you answer it.
thanks,
Murat
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");
                    }