When I used a bootstrapped 3.0 template together with Angular JS, I found out that the height of the DIV layer where ng-view resides does not change its height to fill the window viewport height if its content height is small.

I have not found any solution in any forum regarding this problem so what I did was to create a directive and added it to the HTML element where ng-view is located.

My template contains only a horizontal bar at the top, while the bottom is occupied by the content where ng-view is.
This is my HTML:

This is my directive:

What the code does, is that once the ng-view works its magic and populates the HTML contents to the DIV layer, the Angular JS Directive will wait for the DOM till it is ready. Angular JS also has its own way to detect if a DOM is ready the same way JQuery does, but with a different syntax.

Once it is ready, I call on the $(window).resize() function to simulate a window viewport resize, then do the formula to adjust the height of the DIV content layer to fill the extra height of the window viewport.

Without calling the resize() function the height adjustment will not work when, say, you have a tab element and one of those tabs contains small content.

If you have a footer at the top, then simply add the footer height to the computation.

Now this, is the best code snippet I found in Java that can auto adjust the JTable row height regardless what kind of renderer component is used.

I had been using some short code snippet that sets a JTextPane or JEditorPane content, then getting the height. However, when my content was full of HTML tags, the height returned really messed my JTable.

This code I found in Stack Overflow by user camickr really is the best solution for auto adjusting all rows heights of a JTable based on content.

Related Posts Plugin for WordPress, Blogger...