public GLDemo() { super(VNMRFrame.getVNMRFrame(), "Jogl Demo", false); DisplayOptions.addChangeListener(this); contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); gradientPanel = createGradientPanel(); contentPane.add(gradientPanel, BorderLayout.CENTER); checkBox = new JCheckBox("Transparent", true); checkBox.setActionCommand("transparancy"); checkBox.addActionListener(this); optionsPan = new JPanel(); optionsPan.setLayout(new SimpleH2Layout(SimpleH2Layout.LEFT, 5, 0, true, false)); optionsPan.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); optionsPan.add(checkBox); runButton = new JToggleButton("Run"); runButton.setActionCommand("run"); runButton.setSelected(false); runButton.addActionListener(this); optionsPan.add(runButton); getContentPane().add(optionsPan, BorderLayout.SOUTH); setSize(300, 300); setLocation(300, 300); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { stop(); } }) .start(); } }); setVisible(false); }
@Override public void chatLinkClicked(URI url) { String action = url.getPath(); if (action.equals("/SHOWPREVIEW")) { enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true)); enableReplacementProposal.setSelected( cfg.getBoolean(ReplacementProperty.REPLACEMENT_PROPOSAL, true)); currentMessageID = url.getQuery(); currentLinkPosition = url.getFragment(); this.setVisible(true); this.setLocationRelativeTo(chatPanel); } }
/** handle button events. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("run")) { if (animator.isAnimating()) stop(); else start(); } else if (cmd.equals("transparancy")) { if (drawable != null) drawable.setOpaque(!checkBox.isSelected()); } }
private void audioSetup() { if (musicCB.isSelected()) { try { if (mp3 == null) { mp3 = new MP3(); } } catch (Exception e) { } mp3.play(); } }
/** * Creates an instance of <tt>ShowPreviewDialog</tt> * * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog. */ ShowPreviewDialog(final ChatConversationPanel chatPanel) { this.chatPanel = chatPanel; this.setTitle( GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE")); okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL")); JPanel mainPanel = new TransparentPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // mainPanel.setPreferredSize(new Dimension(200, 150)); this.getContentPane().add(mainPanel); JTextPane descriptionMsg = new JTextPane(); descriptionMsg.setEditable(false); descriptionMsg.setOpaque(false); descriptionMsg.setText( GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION")); Icon warningIcon = null; try { warningIcon = new ImageIcon( ImageIO.read( GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON"))); } catch (IOException e) { logger.debug("failed to load the warning icon"); } JLabel warningSign = new JLabel(warningIcon); JPanel warningPanel = new TransparentPanel(); warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS)); warningPanel.add(warningSign); warningPanel.add(Box.createHorizontalStrut(10)); warningPanel.add(descriptionMsg); enableReplacement = new JCheckBox( GuiActivator.getResources() .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS")); enableReplacement.setOpaque(false); enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true)); enableReplacementProposal = new JCheckBox( GuiActivator.getResources() .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL")); enableReplacementProposal.setOpaque(false); JPanel checkBoxPanel = new TransparentPanel(); checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS)); checkBoxPanel.add(enableReplacement); checkBoxPanel.add(enableReplacementProposal); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); mainPanel.add(warningPanel); mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(checkBoxPanel); mainPanel.add(buttonsPanel); okButton.addActionListener(this); cancelButton.addActionListener(this); this.setPreferredSize(new Dimension(390, 230)); }
@Override public void actionPerformed(ActionEvent arg0) { if (arg0.getSource().equals(okButton)) { cfg.setProperty(ReplacementProperty.REPLACEMENT_ENABLE, enableReplacement.isSelected()); cfg.setProperty( ReplacementProperty.REPLACEMENT_PROPOSAL, enableReplacementProposal.isSelected()); SwingWorker worker = new SwingWorker() { /** * Called on the event dispatching thread (not on the worker thread) after the <code> * construct</code> method has returned. */ @Override public void finished() { String newChatString = (String) get(); if (newChatString != null) { try { Element elem = chatPanel.document.getElement(currentMessageID); chatPanel.document.setOuterHTML(elem, newChatString); msgIDToChatString.put(currentMessageID, newChatString); } catch (BadLocationException ex) { logger.error("Could not replace chat message", ex); } catch (IOException ex) { logger.error("Could not replace chat message", ex); } } } @Override protected Object construct() throws Exception { String newChatString = msgIDToChatString.get(currentMessageID); try { String originalLink = msgIDandPositionToLink.get(currentMessageID + "#" + currentLinkPosition); String replacementLink = linkToReplacement.get(originalLink); String replacement; DirectImageReplacementService source = GuiActivator.getDirectImageReplacementSource(); if (originalLink.equals(replacementLink) && (!source.isDirectImage(originalLink) || source.getImageSize(originalLink) == -1)) { replacement = originalLink; } else { replacement = "<IMG HEIGHT=\"90\" WIDTH=\"120\" SRC=\"" + replacementLink + "\" BORDER=\"0\" ALT=\"" + originalLink + "\"></IMG>"; } String old = originalLink + "</A> <A href=\"jitsi://" + ShowPreviewDialog.this.getClass().getName() + "/SHOWPREVIEW?" + currentMessageID + "#" + currentLinkPosition + "\">" + GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW"); newChatString = newChatString.replace(old, replacement); } catch (Exception ex) { logger.error("Could not replace chat message", ex); } return newChatString; } }; worker.start(); this.setVisible(false); } else if (arg0.getSource().equals(cancelButton)) { this.setVisible(false); } }
/** * Print in black and white * * @param l if true, print in black and white, if false respect the colors associated to the * layers. */ public void setBW(boolean l) { bw_CB.setSelected(l); }
/** * Set the landscape mode * * @param l true if the output should be in landscape mode. It will be in portrait orientation * otherwise. */ public void setLandscape(boolean l) { landscape_CB.setSelected(l); }
/** * Set the resize to fit option * * @param f true if the drawing should be stretched in order to fit the page. */ public void setFit(boolean f) { fit_CB.setSelected(f); }
/** * Set the mirror attribute * * @param m true if the printout should be done in mirroring mode. */ public void setMirror(boolean m) { mirror_CB.setSelected(m); }
/** * Check if the black and white checkbox is selected. * * @return true if the checkbox is active. */ public boolean getBW() { return bw_CB.isSelected(); }
/** * Check if the page orientation should be landscape * * @return true wether the orientation is landscape. */ public boolean getLandscape() { return landscape_CB.isSelected(); }
/** * Check if the drawing should be fit to the page * * @return true wether the fitting should be done. */ public boolean getFit() { return fit_CB.isSelected(); }
/** * Check if the drawing should be mirrored. * * @return true wether the mirroring should be done. */ public boolean getMirror() { return mirror_CB.isSelected(); }
private void makeMenuScreen() { menu = new JPanel(); menu.setBackground(Color.BLACK); menu.setLayout(null); menu.setBounds(0, 0, width, height); try { BufferedImage menuIMG = ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png")); // BufferedImage menuIMG = ImageIO.read(new // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png")); menuIMGL = new JLabel( new ImageIcon( menuIMG.getScaledInstance( (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH))); menuIMGL.setBounds(0, 0, width, height); } catch (Exception e) { } highscoreL = new JLabel(String.valueOf(highscore)); highscoreL.setBackground(Color.darkGray); highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100); highscoreL.setForeground(Color.white); easy = new JButton("Easy"); hard = new JButton("Hard"); easy.addActionListener(this); hard.addActionListener(this); easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20); hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20); onePlayerRB = new JRadioButton("One Player"); twoPlayerRB = new JRadioButton("Two Player"); mouseRB = new JRadioButton("Mouse (Player 1)"); keyboardRB = new JRadioButton("Keyboard (Player 1)"); keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50); keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50); musicCB = new JCheckBox("Music"); onePlayerRB.setBackground(null); twoPlayerRB.setBackground(null); mouseRB.setBackground(null); keyboardRB.setBackground(null); keyboardSpeedS1.setBackground(null); keyboardSpeedS2.setBackground(null); musicCB.setBackground(null); onePlayerRB.setForeground(Color.WHITE); twoPlayerRB.setForeground(Color.WHITE); mouseRB.setForeground(Color.WHITE); keyboardRB.setForeground(Color.WHITE); keyboardSpeedS1.setForeground(Color.WHITE); keyboardSpeedS2.setForeground(Color.WHITE); musicCB.setForeground(Color.WHITE); ButtonGroup playerChoice = new ButtonGroup(); playerChoice.add(onePlayerRB); playerChoice.add(twoPlayerRB); onePlayerRB.setSelected(true); ButtonGroup peripheralChoice = new ButtonGroup(); peripheralChoice.add(mouseRB); peripheralChoice.add(keyboardRB); mouseRB.setSelected(true); musicCB.setSelected(true); onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20); twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20); mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20); keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20); keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50); keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50); musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20); keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)"); keyboardSpeedL1.setForeground(Color.WHITE); keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50); keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)"); keyboardSpeedL2.setForeground(Color.WHITE); keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50); howTo = new JButton("How To Play"); howTo.addActionListener(this); howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20); try { BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png")); // BufferedImage howToIMG = ImageIO.read(new // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png")); howToIMGL = new JLabel(new ImageIcon(howToIMG)); howToIMGL.setBounds( width / 2 - howToIMG.getWidth() / 2, height / 2 - howToIMG.getHeight() / 2, howToIMG.getWidth(), howToIMG.getHeight()); } catch (Exception e) { } howToBack = new JButton("X"); howToBack.setBounds( (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50); howToBack.setBackground(Color.BLACK); howToBack.setForeground(Color.WHITE); howToBack.addActionListener(this); menu.add(easy); menu.add(hard); menu.add(howTo); menu.add(highscoreL); menu.add(onePlayerRB); menu.add(twoPlayerRB); menu.add(mouseRB); menu.add(keyboardRB); menu.add(keyboardSpeedL1); menu.add(keyboardSpeedL2); menu.add(keyboardSpeedS1); menu.add(keyboardSpeedS2); menu.add(musicCB); menu.add(menuIMGL); back = new JButton("Back"); back.setBounds(width / 2 - 40, height / 2, 100, 20); back.addActionListener(this); back.setVisible(false); this.add(back); }