• 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

actionlistener and restricting size of button

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have few queries using swing?

1. can somebody tell me how do i restrict the size of the button that we create using swing?
2. how to place a particular button at a desired location?
3. how to check whether the user has typed 10 characters or 20 and so on?
4. how to create password window such that it shouldnt display anything when the user types password . also, how to use action listener when user completes typing password and presses enter?
 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

The restriction on the JButton has to do with the Layoutmanager you are using.
You can use the inherited method from JComponent setPerferredSize() to set the size.

If you meen by password that the user only will see ***** when he/she types you can use the JPasswordField. Package javax.swing

to check the length you can do it by checking the .length() on the text. If you want to alert the user then add a keypressListener and check the length in there. See java.awt.event

To add a ActionListener to a button you can try the following

 
reply
    Bookmark Topic Watch Topic
  • New Topic