Here you can find the source of addPanelToFrame(final JFrame frame, final JPanel panel, final String title)
Parameter | Description |
---|---|
frame | the frame |
panel | the panel |
title | the title |
Parameter | Description |
---|---|
HeadlessException | the headless exception |
public static void addPanelToFrame(final JFrame frame, final JPanel panel, final String title) throws HeadlessException
//package com.java2s; /*//from ww w . j a v a 2 s . co m * Copyright 2002-2016 Jalal Kiswani. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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.ComponentOrientation; import java.awt.HeadlessException; import javax.swing.JFrame; import javax.swing.JPanel; public class Main { static ComponentOrientation defaultComponentOrientation = ComponentOrientation.LEFT_TO_RIGHT; /** * Adds the panel to frame. * * @param frame * the frame * @param panel * the panel * @param title * the title * @throws HeadlessException * the headless exception */ public static void addPanelToFrame(final JFrame frame, final JPanel panel, final String title) throws HeadlessException { frame.add(panel); frame.setTitle(title); frame.applyComponentOrientation(getDefaultComponentOrientation()); } /** * Gets the default component orientation. * * @return the default component orientation */ public static ComponentOrientation getDefaultComponentOrientation() { return defaultComponentOrientation; } }