javax.swing.JLayeredPane Java Examples

The following examples show how to use javax.swing.JLayeredPane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BERootPaneUI.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the window title pane -- the JComponent used to provide a plaf a
 * way to override the native operating system's window title pane with
 * one whose look and feel are controlled by the plaf.  The plaf creates
 * and sets this value; the default is null, implying a native operating
 * system window title pane.
 *
 * @param root the root
 * @param titlePane the title pane
 */
private void setTitlePane(JRootPane root, JComponent titlePane) 
{
	JLayeredPane layeredPane = root.getLayeredPane();
	JComponent oldTitlePane = getTitlePane();

	if (oldTitlePane != null)
	{
		oldTitlePane.setVisible(false);
		layeredPane.remove(oldTitlePane);
	}
	if (titlePane != null) 
	{
		layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
		titlePane.setVisible(true);
	}
	this.titlePane = titlePane;
}
 
Example #2
Source File: SlideOperationImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void performOperation(JLayeredPane pane, Integer layer) {
    // XXX - TBD
    switch (type) {
        case SLIDE_IN:
            component.setBounds(finishBounds);
            pane.add(component, layer);
            if( isHeavyWeightShowing() ) {
                repaintLayeredPane();
            }
            break;
        case SLIDE_OUT:
            pane.remove(component);
            break;
        case SLIDE_RESIZE:
            component.setBounds(finishBounds);
            ((JComponent)component).revalidate();
            if( isHeavyWeightShowing() ) {
                repaintLayeredPane();
            }
            break;
    }
}
 
Example #3
Source File: SlideContainer.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
@Override
public Component add(Component comp) {
    setsize(comp.getPreferredSize());
    Component[] comps = getComponents();
    if (comps.length > 0) {
        oldComponent = comps[0];
    }
    if (comp.equals(oldComponent)) {
        return super.add(comp);
    }
    if (oldComponent != null) {
        putLayer((JComponent) oldComponent, JLayeredPane.DEFAULT_LAYER);
    }
    Component returnResult = super.add(comp);
    putLayer((JComponent) comp, JLayeredPane.DRAG_LAYER);
    comp.setSize(getPreferredSize());
    comp.setVisible(true);
    comp.setLocation(0, 0 - getPreferredSize().height);
    slideFromTop(comp, oldComponent);
    return returnResult;
}
 
Example #4
Source File: AgePickDemo.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings ("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jLayeredPane1 = new javax.swing.JLayeredPane();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jLayeredPane1.setBackground(new java.awt.Color(255, 255, 255));
    jLayeredPane1.setOpaque(true);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(jLayeredPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1171, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(jLayeredPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
    );

    pack();
}
 
Example #5
Source File: SessionAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
private Constructor dataModelViewConstructorFactory(String dataModelViewClassName) {
    Constructor<?> dataModelViewConstructor = null;

    try {
        Class<?> dataModelViewClass = Class.forName(dataModelViewClassName);
        Class<?>[] partypes = new Class[5];
        partypes[0] = JLayeredPane.class;
        partypes[1] = TripoliFraction.class;
        partypes[2] = DataModelInterface.class;
        partypes[3] = Rectangle.class;
        partypes[4] = boolean.class;
        dataModelViewConstructor = dataModelViewClass.getConstructor(partypes);
    } catch (ClassNotFoundException | NoSuchMethodException | SecurityException classNotFoundException) {
    }

    return dataModelViewConstructor;
}
 
Example #6
Source File: DataViewsOverlay.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 *
 * @param tripoliFractionRawDataModelViews
 * @param sampleSessionDataView
 * @param dataPresentationMode the value of dataPresentationMode
 * @param bounds
 */
public DataViewsOverlay(//
        AbstractRawDataView[] tripoliFractionRawDataModelViews, //
        JLayeredPane sampleSessionDataView, //
        DataPresentationModeEnum dataPresentationMode,//
        Rectangle bounds) {
    super(bounds);

    this.tripoliFractionRawDataModelViews = tripoliFractionRawDataModelViews;
    this.sampleSessionDataView = sampleSessionDataView;
    this.downholeFractionationDataModel = null;
    this.myFittedAverages = null;
    this.dataPresentationMode = dataPresentationMode;

    this.standardValue = tripoliFractionRawDataModelViews[0].getStandardValue();

    addMeAsMouseListener();

}
 
Example #7
Source File: InterceptFitFunctionsPresentationView.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param sampleSessionDataView
 * @param rawRatioDataModel
 * @param targetDataModelView
 * @param bounds
 * @param forStandards
 * @param meanOnly the value of meanOnly
 */
public InterceptFitFunctionsPresentationView( //
        JLayeredPane sampleSessionDataView, //
        DataModelInterface rawRatioDataModel, //
        FitFunctionDataInterface targetDataModelView, //
        Rectangle bounds, //
        boolean forStandards, //
        boolean meanOnly) {

    super(targetDataModelView, bounds);

    setCursor(Cursor.getDefaultCursor());

    this.sampleSessionDataView = sampleSessionDataView;
    this.rawRatioDataModel = rawRatioDataModel;
    this.forStandards = forStandards;
    this.meanOnly = meanOnly;
}
 
Example #8
Source File: ComponentPeer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private int[] computeVisibleSpan() {
    Component parent = pane.getParent();
    
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }

    if (parent instanceof JViewport) {
        JViewport vp = (JViewport) parent;

        Point start = vp.getViewPosition();
        Dimension size = vp.getExtentSize();
        Point end = new Point((int) (start.getX() + size.getWidth()), (int) (start.getY() + size.getHeight()));

        int startPosition = pane.viewToModel(start);
        int endPosition = pane.viewToModel(end);

        if (parentWithListener != vp) {
            vp.addChangeListener(WeakListeners.change(this, vp));
            parentWithListener = vp;
        }
        return new int[] {startPosition, endPosition};
    }

    return new int[] {0, pane.getDocument().getLength()};
}
 
Example #9
Source File: AbstractRawDataView.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 *
 * @param sampleSessionDataView
 * @param tripoliFraction
 * @param bounds
 * @param invokeMouseListener
 * @param forStandards the value of forStandards
 */
public AbstractRawDataView(//
        JLayeredPane sampleSessionDataView, //
        TripoliFraction tripoliFraction, //
        Rectangle bounds, //
        boolean invokeMouseListener,//
        boolean forStandards) {
    this(bounds);

    this.sampleSessionDataView = sampleSessionDataView;
    this.tripoliFraction = tripoliFraction;
    this.forStandards = forStandards;

    if (tripoliFraction != null) {
        if (!tripoliFraction.isStandard()) {
            setBackground(ReduxConstants.LightBlueForUnknowns);
        }
    }

    if (invokeMouseListener) {
        addMeAsMouseListener();
    }

}
 
Example #10
Source File: LightBoxPanel.java    From RipplePower with Apache License 2.0 6 votes vote down vote up
public void close() {

		Preconditions.checkState(SwingUtilities.isEventDispatchThread(), "Must be on the EDT");
		JLayeredPane layeredPane = Panels.getApplication().getLayeredPane();

		Component[] components = layeredPane.getComponents();

		if (components.length == 4 || components.length == 6) {
			layeredPane.remove(0);
		}

		if (components.length > 2 && components.length < 7) {
			layeredPane.remove(1);
			layeredPane.remove(0);
		}
		Panels.getApplication().validate();
		Panels.getApplication().repaint();

	}
 
Example #11
Source File: FitFunctionsOnDownHoleRatioDataView.java    From ET_Redux with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param sampleSessionDataView
 * @param tripoliFraction
 * @param rawRatioDataModel
 * @param bounds
 * @param invokeMouseListener
 */
public FitFunctionsOnDownHoleRatioDataView(//
        JLayeredPane sampleSessionDataView, //
        TripoliFraction tripoliFraction,//
        DataModelInterface rawRatioDataModel,//
        Rectangle bounds,//
        boolean invokeMouseListener) {
    super(sampleSessionDataView, tripoliFraction, bounds, invokeMouseListener, true);

    this.rawRatioDataModel = rawRatioDataModel;
    this.fittedFunctionValues = null;
    this.showFittedFunction = false;

    this.standardValue = rawRatioDataModel.getStandardValue();

    this.dataPresentationMode = DataPresentationModeEnum.LOGRATIO;
}
 
Example #12
Source File: javax_swing_JLayeredPane.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}
 
Example #13
Source File: CursorOverlappedPanelsTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(400, 400));
    JPanel enabledPanel = createPanel(new Point(10, 10), true);
    JPanel disabledPanel = createPanel(new Point(100, 100), false);
    layeredPane.add(disabledPanel, JLayeredPane.PALETTE_LAYER);
    layeredPane.add(enabledPanel, JLayeredPane.DEFAULT_LAYER);

    frame.getContentPane().add(layeredPane);
    frame.pack();
    frame.setVisible(true);
}
 
Example #14
Source File: CorrectedIntensitiesDataView.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param sampleSessionDataView
 * @param tripoliFraction
 * @param rawIsotopeDataModel
 * @param bounds
 * @param invokeMouseListener
 */
public CorrectedIntensitiesDataView(//
        JLayeredPane sampleSessionDataView, //
        TripoliFraction tripoliFraction,//
        DataModelInterface rawIsotopeDataModel,//
        Rectangle bounds,//
        boolean invokeMouseListener) {
    super(sampleSessionDataView, tripoliFraction, bounds, invokeMouseListener, true);

    this.rawRatioDataModel = rawIsotopeDataModel;

}
 
Example #15
Source File: JDialogOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JDialog.setLayeredPane(JLayeredPane)} through queue
 */
public void setLayeredPane(final JLayeredPane jLayeredPane) {
    runMapping(new MapVoidAction("setLayeredPane") {
        @Override
        public void map() {
            ((JDialog) getSource()).setLayeredPane(jLayeredPane);
        }
    });
}
 
Example #16
Source File: CursorOverlappedPanelsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(400, 400));
    JPanel enabledPanel = createPanel(new Point(10, 10), true);
    JPanel disabledPanel = createPanel(new Point(100, 100), false);
    layeredPane.add(disabledPanel, JLayeredPane.PALETTE_LAYER);
    layeredPane.add(enabledPanel, JLayeredPane.DEFAULT_LAYER);

    frame.getContentPane().add(layeredPane);
    frame.pack();
    frame.setVisible(true);
}
 
Example #17
Source File: ConcordiaGraphPanel.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param preferredDatePanel
 */
public void setPreferredDatePanel(JLayeredPane preferredDatePanel) {
    this.preferredDatePanel = preferredDatePanel;
    if (preferredDatePanel != null) {
        initPreferredDatePanel();
    }
}
 
Example #18
Source File: TextHighlightingDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void installInLayeredPane(JComponent component) {
    JLayeredPane layeredPane = getRootPane().getLayeredPane();
    layeredPane.add(component, JLayeredPane.PALETTE_LAYER, 20);
    Dimension size = component.getPreferredSize();
    component.setSize(size);
    component.setLocation((getWidth() - size.width) / 2,
            (getHeight() - size.height) / 2);
    component.revalidate();
    component.setVisible(true);
}
 
Example #19
Source File: javax_swing_JLayeredPane.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected JLayeredPane getObject() {
    JLayeredPane pane = new JLayeredPane();
    init(pane, 0, 25, 25, 50, 50, Color.RED);
    init(pane, 1, 10, 10, 50, 50, Color.BLUE);
    init(pane, 2, 40, 40, 50, 50, Color.YELLOW);
    pane.setSize(200, 200);
    return pane;
}
 
Example #20
Source File: FractionInfoPanel.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
public ToggleFractionCheckBoxActionListener( //
        TripoliFraction tripoliFraction, //
        TripoliFractionIncludeChangeInterface rawDataModelView, //
        JLayeredPane sampleSessionDataView) {
    this.rawDataModelView = rawDataModelView;
    //this.sampleSessionDataView = sampleSessionDataView;
}
 
Example #21
Source File: CursorOverlappedPanelsTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(400, 400));
    JPanel enabledPanel = createPanel(new Point(10, 10), true);
    JPanel disabledPanel = createPanel(new Point(100, 100), false);
    layeredPane.add(disabledPanel, JLayeredPane.PALETTE_LAYER);
    layeredPane.add(enabledPanel, JLayeredPane.DEFAULT_LAYER);

    frame.getContentPane().add(layeredPane);
    frame.pack();
    frame.setVisible(true);
}
 
Example #22
Source File: DefaultSlidingFx.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
//        Component comp = operation.getComponent();
//        Graphics2D gr2d = (Graphics2D)pane.getGraphics();
//        Color original = gr2d.getColor();
//        gr2d.setColor(Color.BLUE.darker().darker());
//        Rectangle start = operation.getStartBounds();
//        Rectangle finish = operation.getFinishBounds();
//        Rectangle current = start;
//        for (int i = 0; i < 6 /** magic constant **/; i++) {
//            Rectangle newRect;
//            if (i > 0) {
//                // wipe out old
//            } 
//            newRect = new Rectangle();
//            newRect.x = Math.abs((current.x + finish.x) / 2);
//            newRect.y = Math.abs((current.y + finish.y) / 2);
//            newRect.height = Math.abs((current.height + finish.height) / 2);
//            newRect.width = Math.abs((current.width + finish.width) / 2);
//            gr2d.drawRect(newRect.x, newRect.y, newRect.width, newRect.height);
//            gr2d.setColor(gr2d.getColor().brighter());
//            current = newRect;
//        }
//        gr2d.setColor(original);
////        try {
////            Thread.sleep(5000);
////        } catch (Throwable th) {
////            
////        }
        
    }
 
Example #23
Source File: LayeredScrollPane.java    From Carcassonne with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a layered scroll pane and centers it for a certain grid size.
 */
public LayeredScrollPane() {
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new OverlayLayout(layeredPane));
    setViewportView(layeredPane);
    getVerticalScrollBar().setUnitIncrement(SCROLL_SPEED);
    getHorizontalScrollBar().setUnitIncrement(SCROLL_SPEED);
}
 
Example #24
Source File: MetaData.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);
    // Ignore the children of a JScrollPane.
    // Pending(milne) find a better way to do this.
    if (oldInstance instanceof javax.swing.JScrollPane) {
        return;
    }
    java.awt.Container oldC = (java.awt.Container)oldInstance;
    java.awt.Component[] oldChildren = oldC.getComponents();
    java.awt.Container newC = (java.awt.Container)newInstance;
    java.awt.Component[] newChildren = (newC == null) ? new java.awt.Component[0] : newC.getComponents();

    BorderLayout layout = ( oldC.getLayout() instanceof BorderLayout )
            ? ( BorderLayout )oldC.getLayout()
            : null;

    JLayeredPane oldLayeredPane = (oldInstance instanceof JLayeredPane)
            ? (JLayeredPane) oldInstance
            : null;

    // Pending. Assume all the new children are unaltered.
    for(int i = newChildren.length; i < oldChildren.length; i++) {
        Object[] args = ( layout != null )
                ? new Object[] {oldChildren[i], layout.getConstraints( oldChildren[i] )}
                : (oldLayeredPane != null)
                        ? new Object[] {oldChildren[i], oldLayeredPane.getLayer(oldChildren[i]), Integer.valueOf(-1)}
                        : new Object[] {oldChildren[i]};

        invokeStatement(oldInstance, "add", args, out);
    }
}
 
Example #25
Source File: VisualDesignerPopupFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException {
    final JMenu menu = (JMenu) owner;
    JPanel cont = containerMap.get(menu);
    
    if (cont == null) {
        cont = new VisualDesignerJPanelContainer(menu,this);
        cont.setLayout(new BoxLayout(cont, BoxLayout.Y_AXIS));

        RADVisualContainer menuRAD = (RADVisualContainer) canvas.formDesigner.getMetaComponent(menu);
        for(RADComponent c : menuRAD.getSubBeans()) {
            JComponent comp = (JComponent) canvas.formDesigner.getComponent(c);
            cont.add(comp);
        }
        
        cont.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        containerMap.put(menu,cont);
        canvas.layers.add(cont, JLayeredPane.DEFAULT_LAYER);
    }
    
    cont.setSize(cont.getLayout().preferredLayoutSize(cont));
    canvas.validate();
    canvas.setVisible(true);
    final JPanel fcont = cont;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            setLocationFromMenu(menu, fcont);
        }
    });
    
    canvas.validate();
    canvas.repaint();
    VisualDesignerJPanelPopup popup = new VisualDesignerJPanelPopup(cont, menu, this);
    popupMap.put(menu,popup);
    return popup;
}
 
Example #26
Source File: javax_swing_JLayeredPane.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected JLayeredPane getObject() {
    JLayeredPane pane = new JLayeredPane();
    init(pane, 0, 25, 25, 50, 50, Color.RED);
    init(pane, 1, 10, 10, 50, 50, Color.BLUE);
    init(pane, 2, 40, 40, 50, 50, Color.YELLOW);
    pane.setSize(200, 200);
    return pane;
}
 
Example #27
Source File: javax_swing_JLayeredPane.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}
 
Example #28
Source File: PeriodicTablePanel.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor of the PeriodicTablePanel object
 */
public PeriodicTablePanel() {
  super();
  setLayout(new BorderLayout());
  layeredPane = new JLayeredPane();
  layeredPane.setPreferredSize(new Dimension(581, 435));
  JPanel tp = PTPanel();
  tp.setBounds(8, 85, 570, 340);

  panel = CreateLabelProperties(null);

  layeredPane.add(tp, new Integer(0));
  layeredPane.add(panel, new Integer(1));
  add(layeredPane);
}
 
Example #29
Source File: MetaData.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
    super.initialize(type, oldInstance, newInstance, out);
    // Ignore the children of a JScrollPane.
    // Pending(milne) find a better way to do this.
    if (oldInstance instanceof javax.swing.JScrollPane) {
        return;
    }
    java.awt.Container oldC = (java.awt.Container)oldInstance;
    java.awt.Component[] oldChildren = oldC.getComponents();
    java.awt.Container newC = (java.awt.Container)newInstance;
    java.awt.Component[] newChildren = (newC == null) ? new java.awt.Component[0] : newC.getComponents();

    BorderLayout layout = ( oldC.getLayout() instanceof BorderLayout )
            ? ( BorderLayout )oldC.getLayout()
            : null;

    JLayeredPane oldLayeredPane = (oldInstance instanceof JLayeredPane)
            ? (JLayeredPane) oldInstance
            : null;

    // Pending. Assume all the new children are unaltered.
    for(int i = newChildren.length; i < oldChildren.length; i++) {
        Object[] args = ( layout != null )
                ? new Object[] {oldChildren[i], layout.getConstraints( oldChildren[i] )}
                : (oldLayeredPane != null)
                        ? new Object[] {oldChildren[i], oldLayeredPane.getLayer(oldChildren[i]), Integer.valueOf(-1)}
                        : new Object[] {oldChildren[i]};

        invokeStatement(oldInstance, "add", args, out);
    }
}
 
Example #30
Source File: javax_swing_JLayeredPane.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}