Java JTable setting Column Width

What happens if you call setMinWidth(400) on the last column instead of setPreferredWidth(400)? In the JavaDoc for JTable, read the docs for doLayout() very carefully. Here are some choice bits: When the method is called as a result of the resizing of an enclosing window, the resizingColumn is null. This means that resizing has taken … Read more

What is the difference between getWidth/Height() and getMeasuredWidth/Height() in Android SDK?

As the name suggests the measuredWidth/height is used during measuring and layoutting phase. Let me give an example, A widget is asked to measure itself, The widget says that it wants to be 200px by 200px. This is measuredWidth/height. During the layout phase, i.e. in onLayout method. The method can use the measuredWidth/height of its … Read more

How to Get True Size of MySQL Database?

From S. Prakash, found at the MySQL forum: SELECT table_schema “database name”, sum( data_length + index_length ) / 1024 / 1024 “database size in MB”, sum( data_free )/ 1024 / 1024 “free space in MB” FROM information_schema.TABLES GROUP BY table_schema; Or in a single line for easier copy-pasting: SELECT table_schema “database name”, sum( data_length + … Read more

How to find android TextView number of characters per line?

Try this: private boolean isTooLarge (TextView text, String newText) { float textWidth = text.getPaint().measureText(newText); return (textWidth >= text.getMeasuredWidth ()); } Detecting how many characters fit will be impossible due to the variable width of the characters. The above function will test if a particular string will fit or not in the TextView. The content of … Read more

How to get total RAM size of a device?

As of API level 16 you can now use the totalMem property of the MemoryInfo class. Like this: ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); actManager.getMemoryInfo(memInfo); long totalMemory = memInfo.totalMem; Api level 15 and lower still requires to use the unix command as shown in cweiske’s answer.