Jayes Herryl

Greenhorn
+ Follow
since Jun 09, 2006
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 Jayes Herryl

I have a JTable, which will auto-adjust its column widths based on the data in the cells. And to make this work I have to turn auto resize off by calling table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

The table sits in a JPanel with certain width.

The problem is that with auto_resize_off, when initially there is no data in the table or when the data in the grid is not long enough, the table will not expand across the entire width of the JPanel. So there is an empty gap between the right-end of the table and the right edge of the JPanel.
So I tried to do table.setMinimumSize(new Dimension(MyJPanelWidth, whateverHeight)) to make the initial width of the table same as that of the JPanel. But it does not work! Nothing gets changed for the table width.

However, table.setPreferredSize will change the table width, but my table will not auto-expand its columns, which does not serve my purpose either.

So my question is -- how do I set the initial/minimum table width without impacting its ability to auto-adjust its columns based on data?

Any advice is much appreciated!
14 years ago
I got this exception with SSL connection. Sometimes after the handshake completes and it stays connected for 5 mins, this exception happens and SSL connection is dropped.

I have a read method that takes the ByteBuffer inNetData, decrypts the data and puts to ByteBuffer inData.




The exception I got is:
javax.net.ssl.SSLException: bad record MAC
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:166)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1356)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1324)i
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1324)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:882)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:787)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:663)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:566)


Has anyone seen this problem and any idea what caused the exception?

Any help is appreciated!! Thanks!
Hi,

I try to make a JTable adjust its column widths based on the content of the column when the table is initialized.

Apparently the setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS) does not help. Is there a way to make the table smart enough to shrink the widths on columns with more room, and expand those with more contents in the grids?

Any advice is much appreciated!
15 years ago
So does that mean only name can be garbage colleccted?
Hello all,

Could someone help to explain why I am getting such output from running this piece of code?

class Test{
public static void main(string[] args){
int[] arr = {1, 2, 3, 4};
for(int i : arr) {
arr[i] = 0;
System.out.println(i + " " + arr[i]);
}
for(int i : arr)
System.out.print(i);
}
}
OUTPUT:
1 0
0 0
3 0
0 0
0030

How come the first loop gives 1 as the first value for i and gives 0 to the first i at the second loop? After the first loop, elements in arr are all initialized to zero, then why shouldn't the second loop output 0000??
Is it because i is not initialized?

Thanks for any advice in advance!!
Now I see why...thanks a lot for the explaination!
Hi, I tried to run this piece of code:
public class Test{

public static void main(string arg[]){
Object obj = buildTest(3);
System.gc();
System.out.println("Existing");
}

public static test buildTest(int n){
Test t = null;
for (int i = 0; i < n; i++){
t = new Test(i);
}
return t;
}
string name;
public Test(int n){
name = "Number " + n;
}

public void finalize(){
System.out.print("finalize " + name);
}
}

The output I got was:
finalize Number 1
finalize Number 0
Existing

My questions is, why it does not print out "finalize Number 2"? If I pass 4 to buildTest in main(), it will not print "finalize Number 3" as well... Can anyone explain this? Is it because of the first line "Test t = null;" in buildTest()?
Any help is appreciated!!

[ June 09, 2006: Message edited by: Jay Cat ]
[ June 09, 2006: Message edited by: Jay Cat ]