public GlobalControls() { setLayout(new GridBagLayout()); setBorder(new TitledBorder(new EtchedBorder(), "Global Controls")); aliasCB = createCheckBox("Anti-Aliasing", true, 0); renderCB = createCheckBox("Rendering Quality", false, 1); textureCB = createCheckBox("Texture", false, 2); compositeCB = createCheckBox("AlphaComposite", false, 3); screenCombo = new JComboBox(); screenCombo.setPreferredSize(new Dimension(120, 18)); screenCombo.setLightWeightPopupEnabled(true); screenCombo.setFont(font); for (int i = 0; i < screenNames.length; i++) { screenCombo.addItem(screenNames[i]); } screenCombo.addItemListener(this); Java2Demo.addToGridBag(this, screenCombo, 0, 4, 1, 1, 0.0, 0.0); toolBarCB = createCheckBox("Tools", false, 5); slider = new JSlider(JSlider.HORIZONTAL, 0, 200, 30); slider.addChangeListener(this); TitledBorder tb = new TitledBorder(new EtchedBorder()); tb.setTitleFont(font); tb.setTitle("Anim delay = 30 ms"); slider.setBorder(tb); slider.setMinimumSize(new Dimension(80, 46)); Java2Demo.addToGridBag(this, slider, 0, 6, 1, 1, 1.0, 1.0); texturechooser = new TextureChooser(0); Java2Demo.addToGridBag(this, texturechooser, 0, 7, 1, 1, 1.0, 1.0); }
public DemoControls(ImageOps demo) { super(demo.name); this.demo = demo; setBackground(Color.gray); add(imgCombo = new JComboBox()); imgCombo.setFont(font); for (int i = 0; i < ImageOps.imgName.length; i++) { imgCombo.addItem(ImageOps.imgName[i]); } imgCombo.addActionListener(this); add(opsCombo = new JComboBox()); opsCombo.setFont(font); for (int i = 0; i < ImageOps.opsName.length; i++) { opsCombo.addItem(ImageOps.opsName[i]); } opsCombo.addActionListener(this); }
public static JComboBox getComboBox() { JComboBox component = new JComboBox(); component.setBackground(BACKGROUND_COLOR_TXTA); component.setForeground(TEXT_COLOR); component.setCursor(CURSOR); component.setFont(FONT_TYPE_TXTA); return component; }
/** * Contruct a new AnimationWidget. * * @param parentf the parent JFrame * @param anim a ucar.visad.display.Animation object to manage * @param info Default values for the AnimationInfo */ public AnimationWidget(JFrame parentf, Animation anim, AnimationInfo info) { // Initialize sharing to true super("AnimationWidget", true); timesCbx = new JComboBox() { public String getToolTipText(MouseEvent event) { if (boxPanel != null) { return boxPanel.getToolTipText(); } return " "; } }; timesCbx.setToolTipText(""); timesCbxMutex = timesCbx.getTreeLock(); timesCbx.setFont(new Font("Dialog", Font.PLAIN, 9)); timesCbx.setLightWeightPopupEnabled(false); // set to non-visible until items are added timesCbx.setVisible(false); timesCbx.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!ignoreTimesCbxEvents && (anime != null)) { debug("got timesCbx event"); setTimeFromUser((Real) timesCbx.getSelectedItem()); if (boxPanel != null) { boxPanel.setOnIndex(timesCbx.getSelectedIndex()); } } } }); animationInfo = new AnimationInfo(); if (anim != null) { setAnimation(anim); } if (anime != null) { animationInfo.set(anime.getAnimationInfo()); } if (info != null) { setProperties(info); animationInfo.setRunning(info.getRunning()); } boxPanel = new AnimationBoxPanel(this); if (timesArray != null) { updateBoxPanel(timesArray); } }
JPanel bottomPanel() { bot.setLayout(new BoxLayout(bot, BoxLayout.X_AXIS)); bot.setBackground(COLOR); menu.setFont(DLOG); bot.add(menu); bot.add(Box.createHorizontalStrut(scaled(GAP))); stop.setFont(DLOG); bot.add(stop); bot.add(Box.createHorizontalGlue()); who.setForeground(Color.black); who.setFont(BOLD); bot.add(who); return bot; }
/** * Constructeur de la classe * * @param numJoueur rang du joueur dans la liste des joueurs */ public CadranSaisieInfoOrdinateur(int numJoueur) { this.setOpaque(false); this.setLayout(null); imageCadran.setIcon( new ImageIcon(getClass().getResource("/CadranJoueur" + numJoueur + ".png"))); this.add(imageCadran); imageCadran.setBounds(0, 0, 160, 150); strategie.setOpaque(false); strategie.setFont(new java.awt.Font("Wawati SC", 0, 13)); strategie.setBounds(3, 112, 150, 33); this.add(strategie, 0); strategie.setModel( new javax.swing.DefaultComboBoxModel( new String[] {"Agressif", "Agressif avec Bluff", "Normal", "Passif"})); }
private void createComponents() { categoryLabel = new JLabel(Language.text("contrib.category")); categoryChooser = new JComboBox<String>(); categoryChooser.setMaximumRowCount(20); categoryChooser.setFont(Toolkit.getSansFont(14, Font.PLAIN)); updateCategoryChooser(); categoryChooser.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { category = (String) categoryChooser.getSelectedItem(); if (ContributionManagerDialog.ANY_CATEGORY.equals(category)) { category = null; } filterLibraries(category, filterField.filters); contributionListPanel.updateColors(); } }); filterField = new FilterField(); }
/** * Create a choicebox for link line style options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the link style options. */ private JPanel createLinkDashedChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLinkDashed = new JComboBox(); cbLinkDashed.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectDashed")); // $NON-NLS-1$ cbLinkDashed.setOpaque(true); cbLinkDashed.setEditable(false); cbLinkDashed.setEnabled(false); cbLinkDashed.setMaximumRowCount(10); cbLinkDashed.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.plainLine"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.largeDashes"))); //$NON-NLS-1$ cbLinkDashed.addItem( new String( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.smallDashes"))); //$NON-NLS-1$ cbLinkDashed.validate(); cbLinkDashed.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLinkDashed.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateLinkDashed(cbLinkDashed.getSelectedIndex()); } }; cbLinkDashed.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLinkDashed, BorderLayout.CENTER); return drawPanel; }
/** * Create a choicbox for link line thickness options and return the panel it is in. * * @return JPanel the panel holding the new choicebox for the line thickness options. */ private JPanel createWeightChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbLineWeight = new JComboBox(); cbLineWeight.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectWeight")); // $NON-NLS-1$ cbLineWeight.setOpaque(true); cbLineWeight.setEditable(false); cbLineWeight.setEnabled(false); cbLineWeight.setMaximumRowCount(10); cbLineWeight.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ cbLineWeight.addItem(new String("1 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("2 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("3 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("4 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("5 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("6 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("7 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("8 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("9 px")); // $NON-NLS-1$ cbLineWeight.addItem(new String("10 px")); // $NON-NLS-1$ cbLineWeight.validate(); cbLineWeight.setSelectedIndex(0); DefaultListCellRenderer drawRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (list != null) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } } setText((String) value); return this; } }; cbLineWeight.setRenderer(drawRenderer); ActionListener drawActionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { int ind = cbLineWeight.getSelectedIndex(); if (ind == 0) onUpdateLinkWeight(1); else if (ind == 1) onUpdateLinkWeight(2); else if (ind == 2) onUpdateLinkWeight(3); else if (ind == 3) onUpdateLinkWeight(4); else if (ind == 4) onUpdateLinkWeight(5); else if (ind == 5) onUpdateLinkWeight(6); else if (ind == 6) onUpdateLinkWeight(7); else if (ind == 7) onUpdateLinkWeight(8); else if (ind == 8) onUpdateLinkWeight(9); else if (ind == 9) onUpdateLinkWeight(10); } }; cbLineWeight.addActionListener(drawActionListener); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbLineWeight, BorderLayout.CENTER); return drawPanel; }
/** Create the arrow head choicebox. */ private JPanel createArrowChoiceBox() { JPanel drawPanel = new JPanel(new BorderLayout()); CSH.setHelpIDString(drawPanel, "toolbars.formatlink"); // $NON-NLS-1$ cbArrows = new JComboBox(); cbArrows.setToolTipText( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarFormatLink.selectArrow")); // $NON-NLS-1$ cbArrows.setOpaque(true); cbArrows.setEditable(false); cbArrows.setEnabled(false); cbArrows.setMaximumRowCount(4); cbArrows.setFont(new Font("Dialog", Font.PLAIN, 10)); // $NON-NLS-1$ Vector arrows = new Vector(5); arrows.insertElementAt( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.noArrows"), 0); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.fromTo"), 1); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString(LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.toFfrom"), 2); //$NON-NLS-1$ arrows.insertElementAt( LanguageProperties.getString( LanguageProperties.DIALOGS_BUNDLE, "UILinkEditDialog.bothWays"), 3); //$NON-NLS-1$ DefaultComboBoxModel comboModel = new DefaultComboBoxModel(arrows); cbArrows.setModel(comboModel); cbArrows.setSelectedIndex(0); DefaultListCellRenderer comboRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int modelIndex, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setText((String) value); return this; } }; cbArrows.setRenderer(comboRenderer); cbArrows.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { onUpdateArrowType(cbArrows.getSelectedIndex()); } }); drawPanel.add(new JLabel(" "), BorderLayout.WEST); // $NON-NLS-1$ drawPanel.add(cbArrows, BorderLayout.CENTER); return drawPanel; }
// again, sets the gui void init(final int perspective, final Puzzle puzzle) { con.removeAll(); setBounds(0, 0, 1400, 1030); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel header = new JLabel("Edit Puzzle"); header.setFont(new Font("Serif", Font.BOLD, 40)); header.setForeground(Color.BLACK); header.setBounds(600, 0, 290, 50); canvas = new MyCanvas(perspective); canvas.setBounds(30, 120, 800, 800); canvas.boxItem = puzzle.boxItems; canvas.isfromEditBoard = true; panel.setBackground(Color.orange); panel.setBounds(0, 0, 1300, 1000); JLabel[] alphabets = asigningalphabets(perspective); JLabel[] alphabets1 = asigningalphabets1(perspective); JLabel[] numbers = assigningnumbers(perspective); JLabel[] numbers1 = assigningnumbers1(perspective); JButton buttonNext = new JButton("Edit"); buttonNext.setBounds(1150, 850, 120, 30); buttonNext.setFont(new Font("Serif", Font.BOLD, 20)); buttonNext.setFocusable(false); JButton backButton = new JButton("Return"); backButton.setBounds(930, 850, 120, 30); backButton.setFont(new Font("Serif", Font.BOLD, 20)); backButton.setFocusable(false); listmodel = new DefaultListModel(); enterPuzzle(puzzle.getcategoryName()); final JList listofMoves = new JList(listmodel); JScrollPane list = new JScrollPane(); list.setViewportView(listofMoves); list.setBounds(870, 350, 500, 300); listofMoves.setFont(new Font("Serif", Font.PLAIN, 20)); for (int i = 0; i < listmodel.getSize(); i++) { CategoryNode tmp = ChessApplication.l.head; while (tmp != null) { if (tmp.categoryName.equalsIgnoreCase(puzzle.getcategoryName())) { Puzzle temp = tmp.h; int counter = 0; while (temp != null) { if (temp.getFenString().equalsIgnoreCase(puzzle.getFenString())) { listofMoves.setSelectedIndex(counter); } temp = temp.next; counter++; } } tmp = tmp.next; } } JLabel categoryLabel = new JLabel("Select Category"); categoryLabel.setFont(new Font("Serif", Font.BOLD, 20)); categoryLabel.setBounds(1020, 160, 290, 30); JLabel movesLabel = new JLabel("Select Puzzle"); movesLabel.setFont(new Font("Serif", Font.BOLD, 20)); movesLabel.setBounds(1030, 310, 290, 30); DefaultComboBoxModel catagorylist = new DefaultComboBoxModel(); for (int i = 1; i < BoardtoAdd.listofCategory.getSize(); i++) { catagorylist.addElement(BoardtoAdd.listofCategory.getElementAt(i)); } final JComboBox categoryBox = new JComboBox(catagorylist); categoryBox.setBounds(1000, 200, 200, 30); categoryBox.setFont(new Font("Serif", Font.BOLD, 20)); categoryBox.setSelectedItem(puzzle.getcategoryName()); backButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setRunningFalse(); ChessApplication.editboard.setVisible(false); ChessApplication.startform.setVisible(true); } }); buttonNext.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setRunningFalse(); ChessApplication.editboard.setVisible(false); ChessApplication.boardtoedit.init("Edit Moves", perspective, false, puzzle); } }); listofMoves.addMouseListener( new MouseListener() { @Override public void mouseClicked(MouseEvent e) { setRunningFalse(); ChessApplication.editboard.setVisible(false); puzzle.setBoxItems(); ChessApplication.editboard.init( getPuzzle(categoryBox.getSelectedItem().toString(), listofMoves.getSelectedIndex()) .position .getToPlay(), getPuzzle( categoryBox.getSelectedItem().toString(), listofMoves.getSelectedIndex())); } @Override public void mousePressed(MouseEvent e) {} @Override public void mouseReleased(MouseEvent e) {} @Override public void mouseEntered(MouseEvent e) {} @Override public void mouseExited(MouseEvent e) {} }); categoryBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRunningFalse(); ChessApplication.editboard.setVisible(false); puzzle.setBoxItems(); ChessApplication.editboard.init( getPuzzle(categoryBox.getSelectedItem().toString()).position.getToPlay(), getPuzzle(categoryBox.getSelectedItem().toString())); } }); for (int i = 0; i < 8; i++) { con.add(alphabets[i]); con.add(numbers[i]); con.add(alphabets1[i]); con.add(numbers1[i]); } con.add(categoryLabel); con.add(movesLabel); con.add(categoryBox); con.add(list); con.add(backButton); con.add(buttonNext); con.add(header); con.add(canvas); con.setBackground(Color.orange); con.add(panel); setVisible(true); canvas.start(); }
public SyntaxTab() { super(new BorderLayout(), "Syntax highlighting"); /* * upper checkboxes */ JPanel upper = new JPanel(new GridLayout(2, 1, 0, 0)); upper.setOpaque(false); upper.add(MyPanel.wrap(highlightSyntax)); upper.add(MyPanel.wrap(matchBracket)); highlightSyntax.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { SyntaxTab.this.updateComponentStatus(); } }); this.add(upper, BorderLayout.PAGE_START); /* * upper panel (painters) */ painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getCurrentInstance()); painterComboBox.setFont(f13); if (isMetal) painterComboBox.setBackground(Color.WHITE); painterComboBox.addItemListener(this.painterChangeListener); JButton addPainter = new MyButton("+") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { String name; do { name = JOptionPane.showInputDialog( SyntaxTab.this, "Enter a name:", "Name", JOptionPane.QUESTION_MESSAGE); } while (!myjava.gui.syntax.Painter.isValidPrompt(name, SyntaxTab.this)); if ((name != null) && (!name.isEmpty())) { // name is valid, neither cancelled nor pressed enter directly myjava.gui.syntax.Painter newPainter = ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem())) .newInstance(name); addPainter(newPainter); System.out.println("now set, should call listener"); painterComboBox.setSelectedItem(newPainter); // auto-call ItemListener(s) } } }; JButton removePainter = new MyButton("-") { { if (isMetal) { this.setPreferredSize(new Dimension(28, 28)); } } @Override public void actionPerformed(ActionEvent ev) { myjava.gui.syntax.Painter painter = (myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem()); if (painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) { JOptionPane.showMessageDialog( SyntaxTab.this, "The default painter cannot be removed.", "Error", JOptionPane.ERROR_MESSAGE); } else { int option = JOptionPane.showConfirmDialog( SyntaxTab.this, "Remove painter \"" + painter.getName() + "\"?", "Confirm", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { // remove "painter" removedPainters.add(painter); painterComboBox.removeItemListener(painterChangeListener); painterComboBox.setSelectedItem(myjava.gui.syntax.Painter.getDefaultInstance()); painterComboBox.removeItem(painter); for (Iterator<EntryListPanel> it = listPanelSet.iterator(); it.hasNext(); ) { EntryListPanel panel = it.next(); if (panel.getPainter().getName().equals(painter.getName())) { System.out.println("removing, then break"); it.remove(); centerPanel.remove(panel); break; } } painterComboBox.addItemListener(painterChangeListener); cardLayout.show( centerPanel, myjava.gui.syntax.Painter.getDefaultInstance().getName()); } } } }; // lower part JPanel center = new JPanel(new BorderLayout()); JLabel selectLabel = new MyLabel("Selected painter:"); center.add( MyPanel.wrap(MyPanel.CENTER, selectLabel, painterComboBox, addPainter, removePainter), BorderLayout.PAGE_START); componentSet.addAll(Arrays.asList(selectLabel, addPainter, removePainter)); center.add(centerPanel, BorderLayout.CENTER); this.add(center, BorderLayout.CENTER); cardLayout.show(centerPanel, myjava.gui.syntax.Painter.getCurrentInstance().getName()); }
public OptionsDialogOld(JFrame parent) { super(parent, true); game = new SurroundGame(10, 2, 1, 1); setTitle("Game Options"); setUndecorated(true); closeStatus = false; try { background = ImageIO.read( new File( "C:\\Users\\Frank\\" + "workspace\\Surround\\src\\package1\\" + "bcktile.png")); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Image not found"); } Font font2 = new Font("Cooper Black", Font.BOLD, 30); okButton = new JButton("OK"); okButton.setFont(font2); cancelButton = new JButton("CANCEL"); cancelButton.setFont(font2); okButton.addActionListener(this); cancelButton.addActionListener(this); JPanel container = new ImagePanel(background); container.setLayout(new BorderLayout()); JLabel title = new JLabel("Game Options", SwingConstants.CENTER); Font font = new Font("Cooper Black", Font.BOLD, 60); title.setFont(font); // title.setAlignmentX(CENTER_ALIGNMENT); container.add(BorderLayout.NORTH, title); JPanel panel = new JPanel(); panel.setName("Game Options"); panel.setLayout(new GridLayout(5, 2)); DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER); String[] board = { "4 x 4", "5 x 5", "6 x 6", "7 x 7", "8 x 8", "9 x 9", "10 x 10", "11 x 11", "12 x 12" }; boardBox = new JComboBox<String>(board); boardBox.setFont(font2); boardBox.setRenderer(dlcr); JLabel sizeLabel = new JLabel("Size of the board:"); sizeLabel.setFont(font2); panel.add(sizeLabel); panel.add(boardBox); String[] players = {"2", "3", "4", "5", "6", "7", "8", "9", "10"}; String[] turns = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; playersBox = new JComboBox<String>(players); playersBox.setFont(font2); playersBox.setRenderer(dlcr); JLabel playersLabel = new JLabel("Number of players:"); playersLabel.setFont(font2); panel.add(playersLabel); panel.add(playersBox); humansBox = new JComboBox<String>(turns); humansBox.setFont(font2); humansBox.setRenderer(dlcr); JLabel humansLabel = new JLabel("Number of human players:"); humansLabel.setFont(font2); panel.add(humansLabel); panel.add(humansBox); startBox = new JComboBox<String>(turns); startBox.setFont(font2); startBox.setRenderer(dlcr); JLabel startLabel = new JLabel("Starting player:"); startLabel.setFont(font2); panel.add(startLabel); panel.add(startBox); panel.add(okButton); panel.add(cancelButton); // container.setPreferredSize(new Dimension(700,700)); container.add(BorderLayout.CENTER, panel); panel.setOpaque(false); container.setOpaque(false); Box box = new Box(BoxLayout.Y_AXIS); box.add(Box.createVerticalGlue()); box.add(container); // box.setVisible(true); // setContentPane(background); // background. getContentPane().add(box); // add(box); // getContentPane().add(container); setAlwaysOnTop(true); setSize(parent.getSize()); setLocation(parent.getLocation()); setVisible(true); }