public Component getControls() { if (panel == null) { panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); Box filler = Box.createHorizontalBox(); filler.setPreferredSize(new Dimension(50, 10)); panel.add(filler); visBox = Box.createHorizontalBox(); visBox.setAlignmentX(Box.CENTER_ALIGNMENT); visualizer = new Visualizer(defn); visBox.add(new ScrollPane(visualizer)); panel.add(visBox); filler = Box.createHorizontalBox(); filler.setPreferredSize(new Dimension(50, 10)); panel.add(filler); symbolPanel = new SymbolPanel(); panel.add(symbolPanel); } return panel; }
protected SpielerSternePanel(int positionsID, boolean print, JPanel parent, int x, int y) { super(print); m_iPositionsID = positionsID; m_jpParent = parent; initComponents(); initLabel(positionsID, (byte) 0); // Tactic does not matter anymore... // This one size fits all will be bad whenever it is decided to // remove subs/captain/setpiece-taker panels when empty m_jpDummy.setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT)); // Init the constraints object, and add this panel to the parent m_gbcConstraints.anchor = GridBagConstraints.NORTH; m_gbcConstraints.fill = GridBagConstraints.NONE; m_gbcConstraints.weightx = 0.0; m_gbcConstraints.weighty = 0.0; m_gbcConstraints.insets = new Insets(2, 2, 2, 2); m_gbcConstraints.gridx = x; m_gbcConstraints.gridy = y; m_gbcConstraints.gridwidth = 1; addPanel(); }
private Box getPanel() { Box result = Box.createVerticalBox(); result.setBorder(new EmptyBorder(BORDER_WIDTH, BORDER_WIDTH, BORDER_WIDTH, BORDER_WIDTH)); result.add(getLabel()); result.add(Box.createVerticalGlue()); result.add(getBar()); result.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); return result; }
// создание телефона и отображение его на экране public void CreatePhone() { DisplayField = new JTextField(); DisplayField.setPreferredSize(new Dimension(500, 150)); DisplayField.setMaximumSize(new Dimension(500, 150)); DisplayField.setEditable(false); DisplayField.setHorizontalAlignment(SwingConstants.CENTER); DisplayField.setFont(DisplayFont); DisplayField.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JPanel ButtonPanel = addNumberButtons(DisplayField); JPanel CallBox = addFuncButtons(); Box contentBox = Box.createVerticalBox(); contentBox.setPreferredSize(new Dimension(600, 620)); contentBox.add(Box.createVerticalGlue()); contentBox.add(Box.createVerticalStrut(40)); contentBox.add(DisplayField); contentBox.add(Box.createVerticalStrut(10)); contentBox.add(ButtonPanel); contentBox.add(Box.createVerticalStrut(10)); contentBox.add(CallBox); contentBox.add(Box.createVerticalGlue()); HistoryList(); JButton sleep = Sleep(); JPanel slPanel = new JPanel(); slPanel.setLayout(new BorderLayout()); slPanel.add(sleep, BorderLayout.EAST); Box boxForList = Box.createVerticalBox(); boxForList.setPreferredSize(new Dimension(140, 620)); boxForList.add(Box.createVerticalGlue()); contentBox.add(Box.createVerticalStrut(10)); boxForList.add(listBox); boxForList.add(Box.createVerticalGlue()); this.add(slPanel, BorderLayout.NORTH); this.add(contentBox, BorderLayout.WEST); this.add(boxForList, BorderLayout.CENTER); MainFrame.container.add(this, BorderLayout.CENTER); }
/** * Immediately shows the popup at the specified point. {@link getContent()} is called to get the * content of the popup. * * @param showAt Show at the specified point. */ public void show(Point showAt) { this.removeAll(); Box content = new Box(BoxLayout.Y_AXIS); UIUtils.setPadding(content, 5, 5, 5, 5); content.add(this.getContent()); this.add(content); // For some reason we need to set the size manually. content.setPreferredSize(new Dimension(310, content.getPreferredSize().height)); this.viewer.showPopupAt(this, showAt, true); }
/** Create buttons for choosing the spatial criteria and a panel for them */ private JComponent createSpatialButtons() { // JLabel label = new JLabel( GUIMessages.SPATIAL_CRITERIA ); // label.setBounds(LEFT_MARGIN + 2, 370,200,18); // add(label); noCritButton = new JRadioButton(I18N.getString("AttributeResearchPanel.none")); noCritButton.setActionCommand(WFSPanel.NONE); noCritButton.doClick(); bboxCritButton = new JRadioButton(I18N.getString("AttributeResearchPanel.bbox")); bboxCritButton.setActionCommand(WFSPanel.BBOX); bboxCritButton.setBounds(10, 30, 200, STD_HEIGHT); selecGeoButton = new JRadioButton(I18N.getString("AttributeResearchPanel.selectedGeometry")); selecGeoButton.setActionCommand(WFSPanel.SELECTED_GEOM); ActionListener bal = new ActionListener() { public void actionPerformed(ActionEvent e) { JRadioButton rb = (JRadioButton) e.getSource(); spatialSearchCriteria = rb.getActionCommand(); } }; noCritButton.addActionListener(bal); bboxCritButton.addActionListener(bal); selecGeoButton.addActionListener(bal); ButtonGroup bg = new ButtonGroup(); bg.add(noCritButton); bg.add(bboxCritButton); bg.add(selecGeoButton); Box b = Box.createVerticalBox(); b.setAlignmentX(0.95f); b.setBorder( BorderFactory.createTitledBorder(I18N.getString("AttributeResearchPanel.spatialCriteria"))); b.add(noCritButton); b.add(bboxCritButton); b.add(selecGeoButton); b.setPreferredSize(new Dimension(150, 100)); return b; }
@Override protected void zmenaVyberu(final Set<Alela> aAlelyx) { jmenaVybranychAlel = Alela.alelyToNames(aAlelyx); final Genotyp genotyp = new Genotyp(aAlelyx, bag.getGenom()); final Sklivec sklivec = bag.getSklivec(genotyp); jskelneikony.removeAll(); // BoundingRect br = Imagant.sjednoceni(sklivec.imaganti); { jskelneikony.add(Box.createVerticalStrut(20)); final JButton jLabel = new JButton(); jLabel.setAlignmentX(CENTER_ALIGNMENT); // jLabel.setText("všechna skla přes sebe"); final Imagant imagant = Sklo.prekresliNaSebe(sklivec.imaganti); if (imagant != null) { jLabel.setIcon(new ImageIcon(imagant.getImage())); } jskelneikony.add(jLabel); } jskelneikony.add(Box.createVerticalStrut(50)); final Iterator<SkloAplikant> iterator = bag.getSada().getSkloAplikanti().iterator(); for (final Imagant imagant : sklivec.imaganti) { final SkloAplikant skloAplikant = iterator.next(); final Box panel = Box.createHorizontalBox(); final TitledBorder border = BorderFactory.createTitledBorder(skloAplikant.sklo.getName()); border.setTitleJustification(TitledBorder.CENTER); panel.setBorder(border); final JLabel jLabel = new JLabel(); // jLabel.setText("sklo"); if (imagant != null) { jLabel.setIcon(new ImageIcon(imagant.getImage())); } jLabel.setAlignmentX(CENTER_ALIGNMENT); panel.add(Box.createHorizontalGlue()); panel.add(jLabel); panel.add(Box.createHorizontalGlue()); panel.setMinimumSize(new Dimension(150, 100)); panel.setPreferredSize(new Dimension(150, 100)); // JLabel jJmenoSady = new JLabel(skloAplikant.sklo.getName()); // jJmenoSady.setAlignmentX(JComponent.CENTER_ALIGNMENT); // jskelneikony.add(jJmenoSady); jskelneikony.add(panel); jskelneikony.add(Box.createVerticalStrut(10)); } jskelneikony.add(Box.createVerticalGlue()); final JCheckBox jZobrazovaniVseho = new JCheckBox("Zobrazit vše"); jZobrazovaniVseho.setSelected(zobrazovatVse); jskelneikony.add(jZobrazovaniVseho); jZobrazovaniVseho.addItemListener( e -> { zobrazovatVse = jZobrazovaniVseho.isSelected(); resetBag(bag); }); // a teď vyrendrovat vše přes sebe System.out.println(genotyp); jskelneikony.revalidate(); // pack(); }
public WheelOfFortuneWheelPanel( WheelOfFortuneGame game, WheelOfFortuneTopPanel topPanel, WheelOfFortunePuzzlePanel puzzlePanel) { super(); this.game = game; this.topPanel = topPanel; this.puzzlePanel = puzzlePanel; SPINNING_WHEEL_CLIP = Applet.newAudioClip(getClass().getResource(SOUNDS_DIR + "spinningWheel.wav")); GOOD_GUESS_CLIP = Applet.newAudioClip(getClass().getResource(SOUNDS_DIR + "goodGuess.wav")); BAD_GUESS_CLIP = Applet.newAudioClip(getClass().getResource(SOUNDS_DIR + "badGuess.wav")); BANKRUPT_CLIP = Applet.newAudioClip(getClass().getResource(SOUNDS_DIR + "bankrupt.wav")); NO_MORE_VOWELS_CLIP = Applet.newAudioClip(getClass().getResource(SOUNDS_DIR + "noMoreVowels.wav")); // Store the toolkit for easier access and fewer calls Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); IMAGES = new HashMap<String, Image>(); for (String imageName : IMAGE_NAMES) { IMAGES.put( imageName, defaultToolkit.getImage(getClass().getResource(IMAGES_DIR + imageName))); } IMAGES.put( "arrow.png", defaultToolkit.getImage(getClass().getResource(IMAGES_DIR + "arrow.png"))); wheelTimer = new Timer( 25, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String value = imageNames.get(0); imageNames.remove(0); imageNames.add(value); repaint(); } }); letterButtons = new JButton[26]; buttonListener = new ButtonListener(); for (int i = 0; i < letterButtons.length; i++) { letterButtons[i] = new JButton("" + (char) (i + 65)); letterButtons[i].addActionListener(buttonListener); letterButtons[i].setEnabled(false); } lettersPanel = new JPanel(); lettersPanel.setPreferredSize(new Dimension(100, 200)); lettersPanel.setLayout(new GridLayout(6, 5, 2, 2)); // Vowel buttons are red, consonant buttons are blue for (int i = 0; i < letterButtons.length; i++) { letterButtons[i].setBackground( (i == 0 || i == 4 || i == 8 || i == 14 || i == 20) ? Color.RED : Color.BLUE); lettersPanel.add(letterButtons[i]); } spinWheel = new JButton("Spin Wheel"); spinWheel.addActionListener(buttonListener); solvePuzzle = new JButton("Solve Puzzle"); solvePuzzle.addActionListener(buttonListener); newGame = new JButton("New Game"); newGame.addActionListener(buttonListener); howToPlay = new JButton("How to Play"); howToPlay.addActionListener(buttonListener); about = new JButton("About"); about.addActionListener(buttonListener); statusArea = new JTextArea(); statusArea.setFont(new Font("Tahoma", Font.PLAIN, 11)); statusArea.setEditable(false); statusArea.setBorder(BorderFactory.createLineBorder(Color.GRAY)); statusArea.setLineWrap(true); statusArea.setWrapStyleWord(true); Box optionButtonsBox = Box.createVerticalBox(); optionButtonsBox.add(spinWheel); optionButtonsBox.add(Box.createVerticalStrut(15)); optionButtonsBox.add(solvePuzzle); optionButtonsBox.add(Box.createVerticalStrut(60)); optionButtonsBox.add(newGame); optionButtonsBox.add(Box.createVerticalStrut(15)); optionButtonsBox.add(howToPlay); optionButtonsBox.add(Box.createVerticalStrut(15)); optionButtonsBox.add(about); optionButtonsBox.add(Box.createVerticalStrut(250)); Box letterButtonsBox = Box.createVerticalBox(); letterButtonsBox.add(lettersPanel); letterButtonsBox.add(Box.createVerticalStrut(10)); letterButtonsBox.add(statusArea); letterButtonsBox.add(Box.createVerticalStrut(235)); Box outsideBox = Box.createHorizontalBox(); outsideBox.add(Box.createHorizontalStrut(20)); outsideBox.add(optionButtonsBox); outsideBox.add(Box.createHorizontalStrut(550)); outsideBox.add(letterButtonsBox); outsideBox.add(Box.createHorizontalStrut(20)); outsideBox.setPreferredSize(new Dimension(900, 500)); add(outsideBox); setPreferredSize(new Dimension(900, 300)); newGame(); }
/** * Constructeur du menu. * * @param gameName nom du jeu */ public MenuView(String gameName) { super("Menu - " + gameName); this.titleLabel = new JLabel(gameName); this.titleLabel.setFont(new Font("Verdana", Font.PLAIN, 30)); this.gridSize = new JLabel(Settings.defaultLineSize + " x " + Settings.defaultColSize); gridSize.setFont(new Font("Verdana", Font.PLAIN, 18)); /* *Instanciation et définition des dimensions du bouton play */ this.playBtn = new JButton("Play"); this.playBtn.setPreferredSize(new Dimension(100, 20)); /* *Instanciation et définition des dimensions du bouton history */ this.historyBtn = new JButton("History"); this.historyBtn.setPreferredSize(new Dimension(100, 20)); /* *Instanciation et définition des dimensions du bouton thèmes */ this.themeBtn = new JButton("Themes"); this.themeBtn.setPreferredSize(new Dimension(100, 20)); /* *Instanciation et définition des dimensions du bouton quitter */ this.quitBtn = new JButton("Quit"); this.quitBtn.setPreferredSize(new Dimension(100, 20)); /* Instanciation et définition des dimensions des slider vertical et horizontal */ this.lineSlider = new JSlider(JSlider.VERTICAL, 4, Settings.defaultMaxLine, Settings.defaultLineSize); this.colSlider = new JSlider(JSlider.HORIZONTAL, 4, Settings.defaultMaxCol, Settings.defaultColSize); lineSlider.setPreferredSize(new Dimension(30, 50)); colSlider.setPreferredSize(new Dimension(30, 30)); // JLabel bg = new JLabel(new ImageIcon("Img/menu.jpg")); // this.setContentPane(bg); this.setResizable(false); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); // Boites principales Box boiteTitre = Box.createHorizontalBox(); Box boiteTaille = Box.createHorizontalBox(); Box boiteBtnPlay = Box.createHorizontalBox(); Box boiteBtnHistory = Box.createHorizontalBox(); Box boiteBtnTheme = Box.createHorizontalBox(); Box boiteBtnQuit = Box.createHorizontalBox(); // Boites Secondaires Box boiteLabelSize = Box.createHorizontalBox(); Box boiteColSlider = Box.createVerticalBox(); // TITRE boiteTitre.add(Box.createGlue()); boiteTitre.add(titleLabel); boiteTitre.add(Box.createGlue()); // CHOIX DE LA TAILLE DE LA GRILLE boiteTaille.add(Box.createGlue()); boiteTaille.setPreferredSize(new Dimension(300, 80)); boiteTaille.add(lineSlider); boiteColSlider.add(Box.createGlue()); boiteLabelSize.add(gridSize); boiteColSlider.add(boiteLabelSize); boiteColSlider.add(Box.createGlue()); boiteColSlider.add(colSlider); boiteTaille.add(boiteColSlider); boiteTaille.add(Box.createGlue()); // placement des boutons dans le panneau boiteBtnPlay.add(Box.createGlue()); boiteBtnPlay.add(playBtn); boiteBtnPlay.add(Box.createGlue()); boiteBtnHistory.add(Box.createGlue()); boiteBtnHistory.add(historyBtn); boiteBtnHistory.add(Box.createGlue()); boiteBtnTheme.add(Box.createGlue()); boiteBtnTheme.add(themeBtn); boiteBtnTheme.add(Box.createGlue()); boiteBtnQuit.add(Box.createGlue()); boiteBtnQuit.add(quitBtn); boiteBtnQuit.add(Box.createGlue()); // AJOUT DES COMPOSANTS DANS LA FENETRE this.add(Box.createGlue()); this.add(boiteTitre); this.add(Box.createRigidArea(new Dimension(0, 30))); this.add(Box.createGlue()); this.add(boiteTaille); this.add(Box.createGlue()); this.add(boiteBtnPlay); this.add(Box.createGlue()); this.add(boiteBtnHistory); this.add(Box.createGlue()); this.add(boiteBtnTheme); this.add(Box.createGlue()); this.add(boiteBtnQuit); this.add(Box.createGlue()); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setPreferredSize(new Dimension(300, 400)); this.pack(); this.setLocationRelativeTo(null); // Ajout des ecouteurs aux differnts composants playBtn.addActionListener(new PlayAction()); historyBtn.addActionListener(new HistoryAction()); themeBtn.addActionListener(new ThemeAction()); quitBtn.addActionListener(new QuitAction()); colSlider.addChangeListener(this); lineSlider.addChangeListener(this); // Créer un lien dans le gestionnaire de vue vers le menu. ViewManager.initMenu(this); }
public DocumentPanel() { super(new BorderLayout()); JLabel lblDocument = new JLabel("Document: " + document.getTitle()); lblDocument.setBorder(new EtchedBorder()); textPane = new JTextPane(document); textPane.setEditable(false); textPane.setMargin(new Insets(5, 20, 5, 5)); textPane.setMaximumSize(new Dimension(364, 1000000000)); textPane.setPreferredSize(new Dimension(364, 400)); textPane.setMinimumSize(new Dimension(364, 10)); textPane.addCaretListener( new CaretListener() { public void caretUpdate(CaretEvent e) { int length = document.getLength(); int offset = e.getDot(); if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1); Paragraph p = lockManager.getParFromOffset(offset); int pOffset = p.getOffset(); lblCursor.setText( "Document Length=" + String.valueOf(length) + ", CaretOffset=" + String.valueOf(offset) + ", Paragraph=" + p.toString() + ", Offset in Paragraph=" + String.valueOf(offset - p.getOffset())); } }); Box box = new Box(BoxLayout.X_AXIS); box.add(textPane); box.add(Box.createGlue()); box.setBackground(Color.WHITE); box.setOpaque(true); box.setPreferredSize(new Dimension(600, 10000)); lblCursor = new JLabel("Cursor"); lblCursor.setBorder(new EtchedBorder()); JPanel boxText = new JPanel(new BorderLayout()); boxText.setBorder(new EmptyBorder(5, 5, 5, 5)); boxText.add(lblDocument, BorderLayout.NORTH); boxText.add(new JScrollPane(box), BorderLayout.CENTER); boxText.add(lblCursor, BorderLayout.SOUTH); JLabel lblPars = new JLabel("Paragraphs: "); lblPars.setBorder(new EtchedBorder()); parList = new JList(); parList.setPreferredSize(new Dimension(100, 300)); parList.setEnabled(false); JPanel boxPars = new JPanel(new BorderLayout()); boxPars.setBorder(new EmptyBorder(5, 5, 5, 5)); boxPars.add(lblPars, BorderLayout.NORTH); boxPars.add(new JScrollPane(parList), BorderLayout.CENTER); add(boxText, BorderLayout.CENTER); add(boxPars, BorderLayout.EAST); }