Results 1 to 18 of 18
- 07-21-2011, 10:28 AM #1
How to set Jtextfield Maxlength?..
I have coded my password field's length like this. But i wanna set the password field to 8 characters, user can't write anything bigger than 8 characters. how can i do that ? is there anything something like "textfield maxlength" in jtextfield proporties ??? Waiting for you help...
Best Regards...Java Code:String password = txtPassword.getText().trim(); int passwordLength = sifre.length(); ... ... else if(passwordLength != 8 ) { JOptionPane.showMessageDialog(null, "Your password must be 8 characters!.."); boolean requestFocusInWindow = txtPassword.requestFocusInWindow(); } ... ...Last edited by qwerty53; 07-21-2011 at 10:32 AM. Reason: grammar and some mistakes
- 07-21-2011, 11:02 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-21-2011, 11:08 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
There are also document filters.
- 07-21-2011, 11:44 AM #4
the declaration of the buttons are in initComponents part. they can't be changed...
- 07-21-2011, 11:45 AM #5
Java Code:@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { mainPanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jLabel16 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); txtKullaniciAdi = new javax.swing.JTextField(); txtOgrenciNumarasi = new javax.swing.JTextField(); txtOgrenciAdi = new javax.swing.JTextField(); txtVerildigiTarih = new javax.swing.JTextField(); txtOgrenciSoyadi = new javax.swing.JTextField(); txtGecerlilikTarihi = new javax.swing.JTextField(); txtSifre = new javax.swing.JTextField(); btnBulOgrenciAdi = new javax.swing.JButton(); btnYazdir = new javax.swing.JButton(); btnBulOgrenciNo = new javax.swing.JButton(); txtEpostaAdresi = new javax.swing.JTextField(); jLabel7 = new javax.swing.JLabel(); btnBulOgrenciNo1 = new javax.swing.JButton(); btnTemizle = new javax.swing.JButton();
- 07-21-2011, 11:52 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
- 07-21-2011, 12:03 PM #7
so how can i use DocumentListener ???
- 07-21-2011, 12:41 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
- 07-21-2011, 12:50 PM #9
it seems too long... there must be an another way.
Last edited by qwerty53; 07-21-2011 at 01:10 PM.
- 07-21-2011, 02:44 PM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Then maybe you should give up and find a different hobby/career.
- 07-21-2011, 04:47 PM #11
Don't attempt something remotely complex if you want a simple solution.
Don't attempt Algebra if you only want to use basic math.- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 07-21-2011, 06:10 PM #12
- 07-21-2011, 06:17 PM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
I don't know, maybe it's just me but:
"it seems too long"
sounds very close to:
"but it's too hard"
You've been given the answer to what needs to be done (and how it's done in Swing).
That you think it's too difficult in some way implies this isn't the job for you.
- 07-21-2011, 07:32 PM #14
i don't need philosophical sentences, i just want a simple example. So i ll learn what to do... Oh Gooood!..
Last edited by qwerty53; 07-21-2011 at 09:55 PM.
- 07-22-2011, 12:24 AM #15
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
@OP: Good luck finding it. And thanks for the question: if I had known about DocumentFilter before, I had forgotten about it.i just want a simple example
@World: Is this a modern tendency, to introduce everything with "hafta" or "juswanna"?
The first denies the essential contingency of everything and ignores the fact that whatever we do involves choice and decision. The second pretends that our actions do not have consequence and entail nothing.
It is a cheap rhetorical reflex whereby the speaker aims to obtain agreement either by claiming that something is inevitable (the haftas) or a small matter that it would be churlish to reject (the juswannas). With uncritical repetition the rhetoric becomes ingrained in both speaker and listener as an idle and irresponsible philosophy.Last edited by pbrockway2; 07-22-2011 at 12:27 AM.
- 07-22-2011, 02:51 AM #16
Of course there is a much simpler way but we are complete bastards and do not what to share the secret with a schmuck like you. Therefore the much harder solution was suggested. So you can either bite the bullet and do it the hard way or study lots, become more proficient and experienced and then after ~10 years when you are a Java Guru somebody MIGHT tell you how to do it the easy way.
- 07-22-2011, 08:13 AM #17
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
- 07-22-2011, 03:59 PM #18
Similar Threads
-
Help - maxLength method for 2D Array
By Hardo in forum New To JavaReplies: 4Last Post: 09-14-2009, 04:28 PM -
JTextField
By gancio in forum AWT / SwingReplies: 20Last Post: 08-26-2009, 03:11 PM -
how to access jTextField of one JFrame1 from JFrame2 & Modify JTextField contents
By sumit1mca in forum AWT / SwingReplies: 1Last Post: 01-30-2009, 06:44 PM -
JtextField
By kashifu in forum Advanced JavaReplies: 2Last Post: 06-27-2008, 04:25 PM -
help with JTextfield
By gary in forum New To JavaReplies: 4Last Post: 07-11-2007, 01:58 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks