Original Post
using Java 1.5.0_update6 basic setup: main window: JApplet: getContentPane().setLayout( new BorderLayout() ); map: JApplet (getMainView returns JApplet): getContentPane().add( mainView.getMainView(), BorderLayout.CENTER ); menu: JApplet (getMenuView returns JApplet): getContentPane().add( menuView.getMenuView(), BorderLayout.WEST ); i want the menu to be a fixed width (180 pixels). For height i need it to be a minimum of 480, but it can be bigger. 1) is there a way to prevent the user from resizing it to anything below minimum size (automatically)? I have researched this but any document i found was older than 1_5_0 (... i think). If not, i'll probably use something similar to this:
// modified from "Liz" at http://www.codecomments.com/archive245-2004-5-199793.html
public void componentResized(ComponentEvent e){
Component c = e.getComponent();
MyClass.HandleWindowResize(c.getX(), c.getY(), c.getSize().width, c.getSize().height);
}
public void handleResize(...){
if(width < minWidth) resize = true;
//etc
resize(x,y);
} It doesn't really bother me that a user could make the window smaller than it should be, long as it doesn't update while he's dragging (i would get arrays of size 0 or maybe even negative i dunno, it could produce some unpredictable things) :) 2) i've been messing around for a bit now, was having trouble getting the menu to show if i added the main (the main's still not showing, but that's another matter). In the end the problem was solved with setPreferredSize(Dimension d): //menuView.setMinimumSize( new Dimension( 180, 480 ) );
//menuView.getContentPane().setMinimumSize( new Dimension( 180, 480 ) );
//menuView.setPreferredSize( new Dimension( 180, 480 ) );
menuView.getContentPane().setPreferredSize( new Dimension( 180, 480 ) ); why do lines 1-2 do absolutely nothing (is there any use to them?), out of lines 3-4 (or 1-2), which is preferable? They *seem* to have the same effect (but 1/3 set it for JApplet, where 2/4 set it for... JApplet's default JPanel, i think).