Solved

Popup, writing to the textfields

Posted on 1998-09-07
24
257 Views
Last Modified: 2011-09-20
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
0
Comment
Question by:murat080598
  • 16
  • 7
24 Comments
 
LVL 8

Expert Comment

by:diakov
Comment Utility
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
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
The popup window is usually called a dialog. Simply create your own dialog and make it visible when the button is pressed.
0
 

Author Comment

by:murat080598
Comment Utility
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
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
ok
0
 

Author Comment

by:murat080598
Comment Utility
but they are so long it would be easy to send with email:)
0
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
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
 
LVL 5

Accepted Solution

by:
msmolyak earned 30 total points
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
I also want to send you the interface if you give me an email adreess of your .
0
 

Author Comment

by:murat080598
Comment Utility
do you want to receive these interface and help after looking them?
0
 

Author Comment

by:murat080598
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
Hi did you look at your email , i have a question.i m looking forward to hearing from you soon.Regards,
murat
0
 

Author Comment

by:murat080598
Comment Utility
How can i change a window in to a canvas ,cause a want to use 2 window in a container
0
 

Author Comment

by:murat080598
Comment Utility
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
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
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
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
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
 

Author Comment

by:murat080598
Comment Utility
Hi msmolyak did you see my last question about popup window ?i would be very pleased if you answer it.
thanks,
Murat
0
 

Author Comment

by:murat080598
Comment Utility
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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

743 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now