• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

simple program not working in swing

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi frnds,
I m new in swing programming, frnds i wrote a sample progam which is shown below.. it shows me the frame but inside that i m not able to view the two jtextfileds and the button...
its two imp for me now.. could u plz help the and tell me where i m wrong...

plz reply me asap...
public class CopyFilesUI extends JFrame{
private JTextField sourceFile = new JTextField ("Source file name");
private JTextField destinationFile = new JTextField ("Destination file name");
private JButton button = new JButton ("Backup");

public CopyFilesUI ()
{
this.getContentPane().setLayout(null);
sourceFile.setBounds( 50 , 50 , 50 , 50);
sourceFile.setVisible(true);
destinationFile.setBounds(150 , 150 , 50 , 50);
sourceFile.setVisible(true);
button.setBounds(250 , 250 , 250 , 250);
sourceFile.setVisible(true);

this.setTitle("Copy files");
this.setVisible(true);
this.setBounds(0 , 0 , 700 , 700);
this.set
}


public static void main(String[] args) {
CopyFilesUI copyFiles = new CopyFilesUI ();
copyFiles.setEnabled(true);


}
}


thanx for ur co-opearation..
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're not actually adding them to your frame. Try this:

this.getContentPane().add(sourceFile);
this.getContentPane().add(destinationFile);
this.getContentPane().add(button);
 
Vishal Methi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx a lot very much...
Now its working .. but now i have one problem...
can u plz tell me how to write the actionperformed event for button.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java Tutorial has a section on ActionListeners.
 
Vishal Methi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx man...
Now its working properly...
 
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic