Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Popup, writing to the textfields

Posted on 1998-09-07
24
Medium Priority
?
268 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
ID: 1223701
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
ID: 1223702
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
ID: 1223703
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
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!

 
LVL 5

Expert Comment

by:msmolyak
ID: 1223704
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
ID: 1223705
ok
0
 

Author Comment

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

Expert Comment

by:msmolyak
ID: 1223707
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
ID: 1223708
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 120 total points
ID: 1223709
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
ID: 1223710
I also want to send you the interface if you give me an email adreess of your .
0
 

Author Comment

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

Author Comment

by:murat080598
ID: 1223712
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
 
LVL 5

Expert Comment

by:msmolyak
ID: 1223713
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
ID: 1223714
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
ID: 1223715
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
ID: 1223716
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
ID: 1223717
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
ID: 1223718
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
ID: 1223719
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
ID: 1223720
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
ID: 1223721
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
ID: 1223722
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
ID: 1223723
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
ID: 1223724
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

926 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