Jerry Crothers

Ranch Hand
+ Follow
since Mar 06, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jerry Crothers

Geez after I added:

panel.revalidate();

it worked. Thats annoying. Thanks for the code sample though.
17 years ago
I have a class (JPanel) thats uses the gridbag layout - its a form.

One of the event handlers needs to remove a textfield and replace it with a another component (JButton). So I am writing code like this to remove the textfield:

this.remove(textfield);
this.repaint();
this.setVisible(true);

thats fine, but it won't let me create a new JButton (or any component) and put it in that cell. So then I tried to put the original textfield back:

add(textfield, gridbagconstraints);

..and it was there. Even just add(textfield) put the textfield back.

Why I can not put another component in the original cell after the textfield is removed??
17 years ago
I am writing some code to get the text when modified by the user, using a key listener. Problem is when the user changes the text in the JTextField the old text is being returned:

emailField.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
emailKeyPress(e);
}
});

public void emailKeyPress(KeyEvent e)
{
// tried e.consume() - does nothing
String emailText = this.emailField.getText().trim(); // old text..
}

Any ideas?
17 years ago
I am seeing some characters getting truncated in my JLabels. For instance j gets truncated to an i. Is there a way to fix this?
17 years ago
Ok I was loooking in 'variables' in Eclipse and nothing was changing. But then I added a watch expression and the value of it did change. Quite annoying...
17 years ago
This is really starting to tick me off. I just want to get a Calnedar and add to it 6 months:

Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH,6);

I am debugging in eclipse. After the 2nd line there is no change in the calendar object

17 years ago
> Two processes can open the same file for writing.

That surprises me, are u sure?
17 years ago
2 processes cannot open the same file for writing (and reading?) I will try to avoid using the temporary file and use the properties file.
17 years ago
The lock file idea sounds ok. I am using a properties file in my app. How can I create a lock on it and how do I check for a lock on it? Thanks.
17 years ago
How can I enforce only one instance of my app running at once ?

Jerry.
17 years ago
I am usinng http to talk to java servlets from a swing app. The data is encrypted/decrypted at both ends and also sent zipped. The data is not real sensitive so if it is hacked it won't be a major problem.
17 years ago
I need to host my servlet app, where is the best place to do that? I know about Java Servlet Hosting, are they any good?

Jerry.
17 years ago
I have a swing client and need to display a number of images from the web. What is the best way to do that? I know JLabel can use html but this would be a huge label. Any ideas?

Jerry.
17 years ago
I am using a DES decryption method in my Swing client. How do I make the key ("secret123") hidden?
I am planning to obfuscate the source code, but decompiling it would show the string?

Jerry.

private static String decrypt(String str) {
Cipher dcipher;
SecretKey key = new SecretKeySpec("secret123".getBytes(),"DES");
try {
dcipher = Cipher.getInstance("DES");
dcipher.init(Cipher.DECRYPT_MODE, key);

// Decode base64 to get bytes
byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str);

// Decrypt
byte[] utf8 = dcipher.doFinal(dec);

// Decode using utf-8
return new String(utf8, "UTF8");

} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
} catch (javax.crypto.BadPaddingException e) {
} catch (IllegalBlockSizeException e) {
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
return null;
}
17 years ago
I need to create a few different tables in Swing. I wish to use a 2D object array for the data and be able to press the column names for sorting.

Is there a freeware table class I can use? I don't wish to use a separate table model for each table.

Thanks.
18 years ago