Here you can find the source of smartSetBounds(JFrame frame)
Parameter | Description |
---|---|
frame | a parameter |
public static void smartSetBounds(JFrame frame)
//package com.java2s; /*/*ww w.j a v a2 s . com*/ * @(#)SwingUtils.java 2010.01.25 at 11:23:37 PST * * Copyright 2009 MBARI * * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.*; import javax.swing.*; public class Main { /** * <p><!-- Method description --></p> * * * @param frame */ public static void smartSetBounds(JFrame frame) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width = 500; int height = 500; if (screenSize.height <= 600) { height = (int) (screenSize.height * .95); } else if (screenSize.height <= 1000) { height = (int) (screenSize.height * .90); } else if (screenSize.height <= 1200) { height = (int) (screenSize.height * .85); } else { height = (int) (screenSize.height * .80); } if (screenSize.width <= 1000) { width = (int) (screenSize.width * .95); } else if (screenSize.width <= 1200) { width = (int) (screenSize.width * .90); } else if (screenSize.width <= 1600) { width = (int) (screenSize.width * .85); } else { width = (int) (screenSize.width * .80); } frame.setBounds(0, 0, width, height); } }