/** * Specifies the menu bar value. * * @deprecated As of Swing version 1.0.3 replaced by <code>setJMenuBar(JMenuBar menu)</code>. * @param menu the <code>JMenuBar</code> to add. */ @Deprecated public void setMenuBar(JMenuBar menu) { if (menuBar != null && menuBar.getParent() == layeredPane) layeredPane.remove(menuBar); menuBar = menu; if (menuBar != null) layeredPane.add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER); }
void eliminarDelContenedor() { for (int r = 0; r < layer.getComponentCount(); r++) { if (((Component) layer.getComponent(r)).hashCode() == this.glass.hashCode()) { layer.remove(r); } } }
private static boolean fitsLayeredPane( JLayeredPane pane, JComponent component, RelativePoint desiredLocation, HintHint hintHint) { if (hintHint.isAwtTooltip()) { Dimension size = component.getPreferredSize(); Dimension paneSize = pane.getSize(); Point target = desiredLocation.getPointOn(pane).getPoint(); Balloon.Position pos = hintHint.getPreferredPosition(); int pointer = BalloonImpl.getPointerLength(pos, false) + BalloonImpl.getNormalInset(); if (pos == Balloon.Position.above || pos == Balloon.Position.below) { boolean heightFit = target.y - size.height - pointer > 0 || target.y + size.height + pointer < paneSize.height; return heightFit && size.width + pointer < paneSize.width; } else { boolean widthFit = target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width; return widthFit && size.height + pointer < paneSize.height; } } else { final Rectangle lpRect = new Rectangle( pane.getLocationOnScreen().x, pane.getLocationOnScreen().y, pane.getWidth(), pane.getHeight()); Rectangle componentRect = new Rectangle( desiredLocation.getScreenPoint().x, desiredLocation.getScreenPoint().y, component.getPreferredSize().width, component.getPreferredSize().height); return lpRect.contains(componentRect); } }
public FenetrePrincipale(PlanSalle modele) { super(); this.modele = modele; this.setTitle(modele.getNom() + " - OSE"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.creerBarreMenus(); this.creerMenuContextuel(); JLayeredPane lp = new JLayeredPane(); lp.setPreferredSize( new Dimension( Parametres.NB_TRAVEES * Parametres.LARGEUR_TRAVEE, Parametres.NB_RANGEES * Parametres.HAUTEUR_RANGEE)); lePlan = new Plan(modele); lePlan.setBounds( 0, 0, Parametres.NB_TRAVEES * Parametres.LARGEUR_TRAVEE, Parametres.NB_RANGEES * Parametres.HAUTEUR_RANGEE); lp.add(lePlan, new Integer(0)); Container conteneur = this.getContentPane(); conteneur.setLayout(new FlowLayout()); conteneur.add(lp); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); }
/** @return Point in layered pane coordinate system */ static Pair<Point, Short> chooseBestHintPosition( Project project, Editor editor, int line, int col, LightweightHint hint, boolean awtTooltip, short preferredPosition) { HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); Dimension hintSize = hint.getComponent().getPreferredSize(); JComponent editorComponent = editor.getComponent(); JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane(); Point p1; Point p2; boolean isLookupShown = LookupManager.getInstance(project).getActiveLookup() != null; if (isLookupShown) { p1 = hintManager.getHintPosition(hint, editor, HintManager.UNDER); p2 = hintManager.getHintPosition(hint, editor, HintManager.ABOVE); } else { LogicalPosition pos = new LogicalPosition(line, col); p1 = HintManagerImpl.getHintPosition(hint, editor, pos, HintManager.UNDER); p2 = HintManagerImpl.getHintPosition(hint, editor, pos, HintManager.ABOVE); } if (!awtTooltip) { p1.x = Math.min(p1.x, layeredPane.getWidth() - hintSize.width); p1.x = Math.max(p1.x, 0); p2.x = Math.min(p2.x, layeredPane.getWidth() - hintSize.width); p2.x = Math.max(p2.x, 0); } boolean p1Ok = p1.y + hintSize.height < layeredPane.getHeight(); boolean p2Ok = p2.y >= 0; if (isLookupShown) { if (p1Ok) return new Pair<Point, Short>(p1, HintManager.UNDER); if (p2Ok) return new Pair<Point, Short>(p2, HintManager.ABOVE); } else { if (preferredPosition != HintManager.DEFAULT) { if (preferredPosition == HintManager.ABOVE) { if (p2Ok) return new Pair<Point, Short>(p2, HintManager.ABOVE); } else if (preferredPosition == HintManager.UNDER) { if (p1Ok) return new Pair<Point, Short>(p1, HintManager.UNDER); } } if (p1Ok) return new Pair<Point, Short>(p1, HintManager.UNDER); if (p2Ok) return new Pair<Point, Short>(p2, HintManager.ABOVE); } int underSpace = layeredPane.getHeight() - p1.y; int aboveSpace = p2.y; return aboveSpace > underSpace ? new Pair<Point, Short>(new Point(p2.x, 0), HintManager.UNDER) : new Pair<Point, Short>(p1, HintManager.ABOVE); }
protected final void showProgress(String message) { myProgressMessage.setText(message); if (myProgressPanel.getParent() == null) { myGlassLayer.setEnabled(false); myProgressIcon.resume(); myLayeredPane.add(myProgressPanel, LAYER_PROGRESS); myLayeredPane.repaint(); } }
/** * Sets the content pane -- the container that holds the components parented by the root pane. * * <p>Swing's painting architecture requires an opaque <code>JComponent</code> in the containment * hierarchy. This is typically provided by the content pane. If you replace the content pane it * is recommended you replace it with an opaque <code>JComponent</code>. * * @param content the <code>Container</code> to use for component-contents * @exception java.awt.IllegalComponentStateException (a runtime exception) if the content pane * parameter is <code>null</code> */ public void setContentPane(Container content) { if (content == null) throw new IllegalComponentStateException("contentPane cannot be set to null."); if (contentPane != null && contentPane.getParent() == layeredPane) layeredPane.remove(contentPane); contentPane = content; layeredPane.add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER); }
ParameterInfoComponent( Object[] objects, Editor editor, @NotNull ParameterInfoHandler handler, boolean requestFocus) { super(new BorderLayout()); myRequestFocus = requestFocus; if (!ApplicationManager.getApplication().isUnitTestMode()) { JComponent editorComponent = editor.getComponent(); JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane(); myWidthLimit = layeredPane.getWidth(); } NORMAL_FONT = UIUtil.getLabelFont(); BOLD_FONT = NORMAL_FONT.deriveFont(Font.BOLD); myObjects = objects; setBackground(BACKGROUND_COLOR); myHandler = handler; myPanels = new OneElementComponent[myObjects.length]; final JPanel panel = new JPanel(new GridBagLayout()); for (int i = 0; i < myObjects.length; i++) { myPanels[i] = new OneElementComponent(); panel.add( myPanels[i], new GridBagConstraints( 0, i, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); } if (myRequestFocus) { AccessibleContextUtil.setName( this, "Parameter Info. Press TAB to navigate through each element. Press ESC to close."); } final JScrollPane pane = ScrollPaneFactory.createScrollPane(panel); pane.setBorder(null); pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); add(pane, BorderLayout.CENTER); myCurrentParameterIndex = -1; }
private static boolean hasMnemonicInBalloons(Container container, int code) { final Component parent = UIUtil.findUltimateParent(container); if (parent instanceof RootPaneContainer) { final JLayeredPane pane = ((RootPaneContainer) parent).getLayeredPane(); for (Component component : pane.getComponents()) { if (component instanceof ComponentWithMnemonics && component instanceof Container && hasMnemonic((Container) component, code)) { return true; } } } return false; }
/** * 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 content the <code>JComponent</code> to use for the window 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; }
/** * Default constructor * * @param playerName The player name * @param isReplay If true, this is a replay */ public PlayerInfoView(Player player, boolean isReplay) { _player = player; this.setPreferredSize(new Dimension(COMPONENT_WIDTH, COMPONENT_HEIGHT)); _isBlack = player.getColor(); _playerNameLabel = new JLabel(player.getPlayer().getPseudo()); _timerLabel = new JLabel(normalizeTime(player.getTimer())); JLayeredPane layeredPane = new JLayeredPane(); // Background JLabel background = new JLabel( new ImageIcon(LobbyConstant.chargeFichier("fr/utc/ressources/player_info_bg.png"))); background.setBounds(0, 0, COMPONENT_WIDTH, COMPONENT_HEIGHT); // Player label _playerNameLabel.setFont(new Font("Georgia", Font.BOLD, 33)); _playerNameLabel.setForeground(_isBlack ? Color.black : Color.white); _playerNameLabel.setHorizontalAlignment(JLabel.CENTER); // 0 = no timer if (player.getTimer() == -1 || isReplay) { _playerNameLabel.setVerticalAlignment(JLabel.CENTER); _playerNameLabel.setBounds(15, 0, COMPONENT_WIDTH - 30, COMPONENT_HEIGHT); } else { _playerNameLabel.setVerticalAlignment(JLabel.TOP); _playerNameLabel.setBounds(15, 35, COMPONENT_WIDTH - 30, COMPONENT_HEIGHT); _timerLabel.setVerticalAlignment(JLabel.TOP); _timerLabel.setHorizontalAlignment(JLabel.CENTER); _timerLabel.setFont(new Font("Georgia", Font.BOLD, 28)); _timerLabel.setForeground(new Color(137, 78, 33)); _timerLabel.setBounds(0, 80, COMPONENT_WIDTH, COMPONENT_HEIGHT); layeredPane.add(_timerLabel, JLayeredPane.DEFAULT_LAYER); this.initTimer(); } layeredPane.add(_playerNameLabel, JLayeredPane.DEFAULT_LAYER); layeredPane.add(background, JLayeredPane.DEFAULT_LAYER); GroupLayout layout = new GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(layeredPane, GroupLayout.DEFAULT_SIZE, COMPONENT_WIDTH, Short.MAX_VALUE)); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent( layeredPane, GroupLayout.DEFAULT_SIZE, COMPONENT_HEIGHT, Short.MAX_VALUE)); }
private void finishDragging() { if (!isDraggingNow()) return; myDragPane.remove(myDragButtonImage); myDragButtonImage = null; myPane.stopDrag(); myDragPane.repaint(); setVisible(true); if (myLastStripe != null) { myLastStripe.finishDrop(); myLastStripe = null; } if (myDragKeyEventDispatcher != null) { KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(myDragKeyEventDispatcher); myDragKeyEventDispatcher = null; } }
protected final void showDesignerCard() { myErrorMessages.removeAll(); myErrorStack.setText(null); myLayeredPane.revalidate(); myHorizontalCaption.update(); myVerticalCaption.update(); myLayout.show(this, DESIGNER_CARD); }
/** * Sets the layered pane for the root pane. The layered pane typically holds a content pane and an * optional <code>JMenuBar</code>. * * @param layered the <code>JLayeredPane</code> to use * @exception java.awt.IllegalComponentStateException (a runtime exception) if the layered pane * parameter is <code>null</code> */ public void setLayeredPane(JLayeredPane layered) { if (layered == null) throw new IllegalComponentStateException("layeredPane cannot be set to null."); if (layeredPane != null && layeredPane.getParent() == this) this.remove(layeredPane); layeredPane = layered; this.add(layeredPane, -1); }
private void construct() { setTitle("JPokemon (ver 0.1)"); setIconImage(Tools.findImage("main-icon")); setSize(720, 457); // WIDTH, HEIGHT setUndecorated(true); setDefaultCloseOperation(DISPOSE_ON_CLOSE); // Using JLayeredPane so my buttons can sit on the picture p = new JLayeredPane(); ImageIcon bg; // Add Splash if (pref.getBoolean("beat", false)) bg = new ImageIcon(Tools.findImage("splashalt")); else bg = new ImageIcon(Tools.findImage("splash")); s.setIcon(bg); s.setBounds(10, 10, 700, 437); p.add(s, new Integer(-1)); // Load Button LoadButton l = new LoadButton(this); l.setBounds(550, 100, 110, 30); // 10px border on all sides p.add(l, new Integer(0)); // New Game Button NewButton n = new NewButton(this); n.setBounds(550, 60, 110, 30); p.add(n, new Integer(0)); // Exit Game Button QuitButton q = new QuitButton(this); q.setBounds(550, 140, 110, 30); p.add(q, new Integer(0)); // OPTIONAL: Reset Splash logon if (pref.getBoolean("beat", false)) { r = new ResetButton(); r.setBounds(550, 180, 110, 30); p.add(r, new Integer(0)); } add(p); setLocationRelativeTo(null); }
public void hide(boolean ok) { if (isVisible()) { if (myIsRealPopup) { if (ok) { myPopup.closeOk(null); } else { myPopup.cancel(); } myPopup = null; } else { if (myCurrentIdeTooltip != null) { IdeTooltip tooltip = myCurrentIdeTooltip; myCurrentIdeTooltip = null; tooltip.hide(); } else { final JRootPane rootPane = myComponent.getRootPane(); if (rootPane != null) { final Rectangle bounds = myComponent.getBounds(); final JLayeredPane layeredPane = rootPane.getLayeredPane(); try { if (myFocusBackComponent != null) { LayoutFocusTraversalPolicyExt.setOverridenDefaultComponent(myFocusBackComponent); } layeredPane.remove(myComponent); } finally { LayoutFocusTraversalPolicyExt.setOverridenDefaultComponent(null); } layeredPane.paintImmediately(bounds.x, bounds.y, bounds.width, bounds.height); } } } } if (myEscListener != null) { myComponent.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); } TooltipController.getInstance().hide(this); fireHintHidden(); }
/** Sets the image to the panel */ public void setImage() { try { imgLbl.setIcon(newImage); imgLbl.setBounds(120, 40, 134, 150); imgLbl.setOpaque(false); lpane.add(imgLbl, new Integer(0), 0); imgLbl.setVisible(true); } catch (NullPointerException ex) { System.err.println("Cannot find image"); } }
/** Set and add the speech bubble image */ public void setSpeechImg() { try { speechLbl.setIcon(speechIcon); speechLbl.setBounds(3, 10, 150, 113); speechLbl.setOpaque(false); lpane.add(speechLbl, new Integer(1), 0); speechLbl.setVisible(true); } catch (NullPointerException ex) { System.err.println("Cannot find image"); } }
public void setVisible(boolean visible) { if (!visible && myView != null) { disposeAndUpdate(false); } else if (visible && myView == null) { Window owner = UIUtil.getWindow(myOwner); if (owner != null) { if (myHeavyWeight) { Window view = pop(owner); if (view == null) { view = new JWindow(owner); setPopupType(view); } setAlwaysOnTop(view, myAlwaysOnTop); setWindowFocusable(view, myWindowFocusable); setWindowShadow(view, myWindowShadow); myView = view; } else if (owner instanceof RootPaneContainer) { JLayeredPane parent = ((RootPaneContainer) owner).getLayeredPane(); if (parent != null) { JPanel view = new JPanel(new BorderLayout()); view.setVisible(false); parent.add(view, JLayeredPane.POPUP_LAYER, 0); myView = view; } } } if (myView != null) { myView.add(myContent); Component parent = myView instanceof Window ? null : myView.getParent(); if (parent != null) { Point location = myViewBounds.getLocation(); SwingUtilities.convertPointFromScreen(location, parent); myViewBounds.setLocation(location); } myView.setBackground(UIUtil.getLabelBackground()); myView.setBounds(myViewBounds); myView.setVisible(true); myViewBounds = null; } } }
/** Creates exit button and set the action event */ private void setExitBtn() { exitBtn.setBounds(265, 1, 21, 21); exitBtn.setVisible(false); exitBtn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exitClippy(); } }); lpane.add(exitBtn, new Integer(2), 0); }
/** * Removes the frame from its parent and adds its <code>desktopIcon</code> to the parent. * * @param f the <code>JInternalFrame</code> to be iconified */ public void iconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon; Container c = f.getParent(); JDesktopPane d = f.getDesktopPane(); boolean findNext = f.isSelected(); desktopIcon = f.getDesktopIcon(); if (!wasIcon(f)) { Rectangle r = getBoundsForIconOf(f); desktopIcon.setBounds(r.x, r.y, r.width, r.height); setWasIcon(f, Boolean.TRUE); } if (c == null || d == null) { return; } if (c instanceof JLayeredPane) { JLayeredPane lp = (JLayeredPane) c; int layer = lp.getLayer(f); lp.putLayer(desktopIcon, layer); } // If we are maximized we already have the normal bounds recorded // don't try to re-record them, otherwise we incorrectly set the // normal bounds to maximized state. if (!f.isMaximum()) { f.setNormalBounds(f.getBounds()); } d.setComponentOrderCheckingEnabled(false); c.remove(f); c.add(desktopIcon); d.setComponentOrderCheckingEnabled(true); c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); if (findNext) { if (d.selectFrame(true) == null) { // The icon is the last frame. f.restoreSubcomponentFocus(); } } }
private void processDrag(final MouseEvent e) { if (myDragCancelled) return; if (!isDraggingNow()) { if (myPressedPoint == null) return; if (isWithinDeadZone(e)) return; myDragPane = findLayeredPane(e); if (myDragPane == null) return; final BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); paint(image.getGraphics()); myDragButtonImage = new JLabel(new ImageIcon(image)) { public String toString() { return "Image for: " + StripeButton.this.toString(); } }; myDragPane.add(myDragButtonImage, JLayeredPane.POPUP_LAYER); myDragButtonImage.setSize(myDragButtonImage.getPreferredSize()); setVisible(false); myPane.startDrag(); myDragKeyEventDispatcher = new DragKeyEventDispatcher(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .addKeyEventDispatcher(myDragKeyEventDispatcher); } if (!isDraggingNow()) return; Point xy = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), myDragPane); if (myPressedPoint != null) { xy.x -= myPressedPoint.x; xy.y -= myPressedPoint.y; } myDragButtonImage.setLocation(xy); SwingUtilities.convertPointToScreen(xy, myDragPane); final Stripe stripe = myPane.getStripeFor(new Rectangle(xy, myDragButtonImage.getSize()), (Stripe) getParent()); if (stripe == null) { if (myLastStripe != null) { myLastStripe.resetDrop(); } } else { if (myLastStripe != null && myLastStripe != stripe) { myLastStripe.resetDrop(); } stripe.processDropButton(this, myDragButtonImage, xy); } myLastStripe = stripe; }
public ifAccountTool(ImageIcon head, String name, int usingsp, int totalsp) { super("AccountTool", false, false, false, false); setLayout(null); lp_layer = this.getLayeredPane(); head = ImageProcess.scaleImage(head, 230, ImageProcess.Auto); head = ImageProcess.cutImage(head, 0, 0, 230, 230); ifAT_iclblHead = new JLabel(head); ifAT_iclblHead.setBorder(BorderFactory.createLineBorder(Color.BLUE)); ifAT_iclblHead.setBounds(20, 20, 230, 230); ifAT_iclblHead.setBackground(Color.BLACK); getContentPane().add(ifAT_iclblHead); lblName_ftName = new Font("微軟正黑體", Font.BOLD, 20); ifAT_lblName = new JLabel(name, JLabel.CENTER); ifAT_lblName.setFont(lblName_ftName); ifAT_lblName.setBounds(20, 210, 230, 130); getContentPane().add(ifAT_lblName); ifAT_pbSpace = new JProgressBar(); ifAT_pbSpace.setMaximum(totalsp); ifAT_pbSpace.setMinimum(0); ifAT_pbSpace.setValue(usingsp); ifAT_pbSpace.setBorderPainted(true); ifAT_pbSpace.setStringPainted(true); ifAT_pbSpace.setBounds(20, 300, 230, 20); getContentPane().add(ifAT_pbSpace); ifAT_toolbar = new ToolBar(); ifAT_toolbar.AddTool("aEdit", null); ifAT_toolbar.AddTool("Plus", null); ifAT_toolbar.AddTool("Logout", null); lp_layer.setLayout(new BorderLayout()); lp_layer.add(ifAT_toolbar, BorderLayout.SOUTH, new Integer(2550)); setVisible(true); getContentPane().setBackground(Color.WHITE); }
/** Create and add Clippy's output text */ public void addClippyTxt() { clippyTxt.setLineWrap(true); clippyTxt.setWrapStyleWord(true); clippyTxt.setEditable(false); clippyTxt.setFont(txtFont); clippyTxt.setAlignmentX(JTextArea.CENTER_ALIGNMENT); clippyTxt.setAlignmentY(JTextArea.CENTER_ALIGNMENT); clippyTxt.setBorder(null); clippyTxt.setSize(105, 35); clippyTxt.setLocation(25, 45); clippyTxt.setOpaque(false); lpane.add(clippyTxt, new Integer(1), 0); }
public void init(Object parent) { glass = new BlurGlass(); glass.setLayout(null); this.setLayout(null); setOpaque(false); // getContentPane().setOpaque(false); this.getLayeredPane().setOpaque(false); this.getRootPane().setOpaque(false); // putClientProperty("Synthetica.opaque", Boolean.FALSE); JParent = parent; glass.setOpaque(false); MouseInputAdapter adapter = new MouseInputAdapter() {}; glass.addMouseListener(adapter); glass.addMouseMotionListener(adapter); try { if (parent instanceof JFrame) { layer = ((JFrame) parent).getLayeredPane(); } else if (parent instanceof JInternalFrame) { layer = ((JInternalFrame) parent).getLayeredPane(); } glass.setBounds(layer.getBounds()); } catch (NullPointerException err) { Dialogos.error("Error interno en Dialogo interno modal", err); } try { glass.add(this); layer.add(glass, JLayeredPane.DEFAULT_LAYER); } catch (NullPointerException err) { Dialogos.error("Error interno en dialogo modal interno", err); } }
/** * This method adds the panels to the window and organises them using a GridBagLayout and a * JLayeredPane. */ private void populateFrame(Container frame) { frame.setLayout(new GridBagLayout()); GridBagConstraints layoutConstraints = new GridBagConstraints(); JLayeredPane dungeonArea = new JLayeredPane(); dungeonArea.setPreferredSize(new Dimension(448, 448)); dungeonArea.add(dungeonPanel, JLayeredPane.DEFAULT_LAYER); // the DungeonPanel is added underneath dungeonArea.add(dungeonPanelOverlay, JLayeredPane.PALETTE_LAYER); // the mostly transparent DungeonPanelOverlay is added on top in the same position layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 7; layoutConstraints.gridheight = 7; frame.add(dungeonArea, layoutConstraints); layoutConstraints.gridx = 7; layoutConstraints.gridwidth = 1; frame.add(serverSettings, layoutConstraints); layoutConstraints.gridx = 0; layoutConstraints.gridy = 7; layoutConstraints.gridwidth = 8; layoutConstraints.gridheight = 1; frame.add(chatPanel, layoutConstraints); }
/** * The constructor for the class It's going to set the dimension of the program to 600x600, the * background is going to be white (in order to blend in with the vor image), and it is going to * add in the VOR radar and a radial indicator that will let the user know which radial he/she is * on */ public finalVORGUI(int r) { deg = r; this.vor = new VorReceiver(deg, ".- -... -.-."); this.vor.setOBS(90); // set the OBS to 30 JLayeredPane lp = new JLayeredPane(); lp.setPreferredSize(new Dimension(WIDTH, HEIGHT)); setBackground(Color.white); lp.setLayout(null); lp.setFocusable(true); degrees = deg; // r is intended radial CurrentRadial = new JLabel( "Intended Radial: " + deg); // A string that is always going to be above the radar. it's going to let // the user know the current radial CurrentRadial.setBounds(220, 18, 200, 200); MorseCode = new JLabel("Station: TO ENTER HERE"); MorseCode.setBounds(200, 500, 200, 50); MorseCode.setText("Station: " + this.vor.getMorse()); // vor.printVorStatus_v1(); rotationPanel = new JPanel(); rotationPanel = new TurningCanvas(); rotationPanel.setBounds( 157, 125, rotationPanel.getPreferredSize().width, rotationPanel.getPreferredSize().height); needle = new JPanel(); needle = new DrawAttributes(); needle.setBounds(100, 0, needle.getPreferredSize().width, needle.getPreferredSize().height); OBS = new JPanel(); OBS = new AddButtons(); OBS.setBounds(110, 350, 200, 100); lp.add(rotationPanel, Integer.valueOf(1)); lp.add(needle, Integer.valueOf(2)); lp.add(OBS, Integer.valueOf(3)); lp.add(CurrentRadial, Integer.valueOf(4)); lp.add(MorseCode, Integer.valueOf(5)); add(lp); x = 172; // x is the location of the needle y1 = 155; y2 = 330; }
/** Creates voice button and set the action event */ private void setVoiceBtn() { voiceBtn.setBounds(235, 145, 45, 45); voiceBtn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { isIdle = false; if (voiceBtn.isEnabled()) { voiceBtn.setEnabled(false); startListening(); } } }); lpane.add(voiceBtn, new Integer(2), 0); }
/** Creates edit button and set the action event */ private void setEditBtn() { editBtn.setEnabled(true); editBtn.setBounds(235, 40, 45, 45); editBtn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (voiceMenu.isVisible()) { voiceMenu.setVisible(false); } else { voiceMenu.setVisible(true); } } }); lpane.add(editBtn, new Integer(2), 0); }
/** Creates a panel for the components of the interface */ private void createPnl() throws InterruptedException { clipPnl = new JPanel(); setPnl(lpane); setImage(); setSpeechImg(); addBtn(); addClippyTxt(); lpane.setOpaque(false); voiceMenu = new VoiceMenu(currentBehavior); voiceMenu.pack(); voiceMenu.setVisible(true); setExitBtn(); try { setup(); } catch (IOException ex) { System.err.println(ex.getMessage()); } }