protected void AddAndword(String Letter, String Andwoord, Color Kleur) { javax.swing.JLabel lbl; javax.swing.JPanel pnl; javax.swing.JToggleButton tcmd; pnl = new javax.swing.JPanel(); tcmd = new javax.swing.JToggleButton(); lbl = new javax.swing.JLabel(); pnl.setBackground(Kleur); pnl.setBorder(javax.swing.BorderFactory.createEtchedBorder()); tcmd.setFont(new java.awt.Font("DejaVu Sans", 1, 36)); lbl.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); tcmd.setText(Letter); tcmd.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); tcmd.setMaximumSize(new java.awt.Dimension(30, 30)); tcmd.setMinimumSize(new java.awt.Dimension(30, 30)); tcmd.setPreferredSize(new java.awt.Dimension(30, 30)); lbl.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); lbl.setVerticalAlignment(javax.swing.SwingConstants.TOP); lbl.setText(Andwoord); lbl.setBorder(null); javax.swing.GroupLayout pnlALayout = new javax.swing.GroupLayout(pnl); pnl.setLayout(pnlALayout); pnlALayout.setHorizontalGroup( pnlALayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( pnlALayout .createSequentialGroup() .addComponent( tcmd, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( lbl, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE))); pnlALayout.setVerticalGroup( pnlALayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( pnlALayout .createSequentialGroup() .addComponent( tcmd, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE)) .addComponent(lbl, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)); Antwoorde.add(pnl); }
private JToggleButton createButton(Container container, String tip) { final JToggleButton btn = new JToggleButton(); btn.setPreferredSize(new Dimension(40, 40)); btn.setBorder(new EmptyBorder(2, 2, 2, 2)); btn.setOpaque(true); btn.setToolTipText(tip); addMouseListener(btn); container.add(btn); return btn; }
public JToggleButton createButton(String name, ImageIcon icon) { JToggleButton button = new JToggleButton() { @Override public void paintComponent(Graphics g) { if (!isSelected()) { super.paintComponent(g); setForeground(Theme.TEXT_COLOR.darker()); return; } g.setColor(new Color(0x666666)); setForeground(Theme.TEXT_COLOR); g.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(g); } }; button.setIconTextGap(8); button.setContentAreaFilled(false); button.setFocusPainted(false); button.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(0x454545)), BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(0x333333)))); button.setHorizontalAlignment(SwingConstants.CENTER); button.setVerticalAlignment(SwingConstants.CENTER); button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setForeground(Theme.TEXT_COLOR.darker()); button.setMinimumSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); button.setMaximumSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); button.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); button.setAction( new AbstractAction(name, icon) { @Override public void actionPerformed(ActionEvent e) { switchToPage(e.getActionCommand()); } }); buttonGroup.add(button); return button; }
/** Updates the style of the given button to indicate that it is selected. */ protected void select(JToggleButton b) { b.setOpaque(true); b.setBackground( Platform.isOSX ? new Color(0xd8, 0xd8, 0xd8) : UIManager.getColor("List.selectionBackground")); b.setForeground(UIManager.getColor("List.selectionForeground")); b.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 1, 0, 1, new Color(160, 160, 160)), BorderFactory.createEmptyBorder(4, 3, 4, 3))); layout.show(panel, b.getText().intern()); page = getComponentIndex(b) - 1; if (Platform.isOSX) { PreferenceDialog.this.setTitle(b.getText()); } PreferenceDialog.this.pack(); panel.grabFocus(); }
private JToggleButton createDevCardButton(String text, String imageFile) { final int BUTTON_TEXT_SIZE = 24; BufferedImage image = loadDevCardImage(imageFile); JToggleButton button = new JToggleButton(text, new ImageIcon(image)) { @Override public void paintComponent(Graphics g) { g.setColor(Color.white); g.fillRect(0, 0, this.getWidth(), this.getHeight()); super.paintComponent(g); } }; FontUtils.setFont(button, BUTTON_TEXT_SIZE); button.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); button.setBackground(Color.white); button.setContentAreaFilled(false); button.setVerticalTextPosition(AbstractButton.BOTTOM); button.setHorizontalTextPosition(AbstractButton.CENTER); button.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg) { JToggleButton source = (JToggleButton) arg.getSource(); if (source.isSelected()) { source.setBorder(BorderFactory.createLineBorder(Color.black, 3)); } else { source.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); } } }); return button; }
/** <b> Constructor that create the frame. </b> */ public TicTacToeMenu(ImageIcon lab5, ImageIcon lab6) { this.lab5 = lab5; this.lab6 = lab6; setTitle("Tic Tac Toe Menu"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { JFrame frame = (JFrame) e.getSource(); int answer = JOptionPane.showConfirmDialog( frame, "Are you sure you want to exit the application ?", "Exit Application", JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); else frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); } }); setBounds(100, 100, 1000, 500); JPanelBackGround panel = new JPanelBackGround("Ressource/Games/TicTacToe/background.png"); panel.setBorder(new EmptyBorder(200, 200, 200, 200)); setContentPane(panel); panel.setLayout(null); setLocationRelativeTo(null); panel.setBorder(black); Border grey = BorderFactory.createLineBorder(Color.LIGHT_GRAY, 2); btnPlay = new JToggleButton(new ImageIcon("Ressource/Games/TicTacToe/btnPlay.png")); btnPlay.setBounds(200, 166, 165, 165); panel.add(btnPlay); btnPlay.addActionListener(this); btnPlay.addMouseListener(this); btnPlay.setRolloverIcon(new ImageIcon("Ressource/Games/TicTacToe/btnPlay2.png")); btnPlay.setBorder(grey); btnOptions = new JToggleButton(new ImageIcon("Ressource/Games/TicTacToe/btnOptions.png")); btnOptions.setBounds(417, 166, 165, 165); panel.add(btnOptions); btnOptions.addActionListener(this); btnOptions.addMouseListener(this); btnOptions.setRolloverIcon(new ImageIcon("Ressource/Games/TicTacToe/btnOptions2.png")); btnOptions.setBorder(grey); btnQuit = new JToggleButton(new ImageIcon("Ressource/Games/TicTacToe/btnQuit.png")); btnQuit.setBounds(635, 166, 165, 165); panel.add(btnQuit); btnQuit.addActionListener(this); btnQuit.addMouseListener(this); btnQuit.setRolloverIcon(new ImageIcon("Ressource/Games/TicTacToe/btnQuit2.png")); btnQuit.setBorder(grey); JLabel lab = new JLabel(new ImageIcon("Ressource/copyright.png")); lab.setBounds(220, 370, 517, 64); panel.add(lab); JLabel lab2 = new JLabel(new ImageIcon("Ressource/Games/TicTacToe/header.png")); lab2.setBounds(313, 34, 447, 98); panel.add(lab2); JLabel lab3 = new JLabel(new ImageIcon("Ressource/me.png")); lab3.setBounds(200, 350, 100, 100); panel.add(lab3); JLabel lab4 = new JLabel(new ImageIcon("Ressource/me.png")); lab4.setBounds(650, 350, 100, 100); panel.add(lab4); if (OS.indexOf("win") >= 0) this.setIconImage(Toolkit.getDefaultToolkit().getImage("Ressource\\logo.png")); if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0 || OS.indexOf("mac") >= 0 || OS.indexOf("sunos") >= 0) this.setIconImage(Toolkit.getDefaultToolkit().getImage("Ressource\\logo.png")); }
/** Updates the style of the given button to indicate that it is unselected. */ protected void unselect(JToggleButton b) { b.setOpaque(false); b.setBackground(null); b.setForeground(UIManager.getColor("Button.foreground")); b.setBorder(BorderFactory.createEmptyBorder(5, 4, 5, 4)); }
public JMovieControlAqua() { // Set the background color to the border color of the buttons. // This way the toolbar won't look too ugly when the buttons // are displayed before they have been loaded completely. // setBackground(new Color(118, 118, 118)); setBackground(Color.WHITE); Dimension buttonSize = new Dimension(16, 16); GridBagLayout gridbag = new GridBagLayout(); Insets margin = new Insets(0, 0, 0, 0); setLayout(gridbag); GridBagConstraints c; ResourceBundle labels = ResourceBundle.getBundle("org.monte.media.Labels"); colorCyclingButton = new JToggleButton(); colorCyclingButton.setToolTipText(labels.getString("colorCycling.toolTipText")); colorCyclingButton.addActionListener(this); colorCyclingButton.setPreferredSize(buttonSize); colorCyclingButton.setMinimumSize(buttonSize); colorCyclingButton.setVisible(false); colorCyclingButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 0; // c.gridy = 0; gridbag.setConstraints(colorCyclingButton, c); add(colorCyclingButton); audioButton = new JToggleButton(); audioButton.setToolTipText(labels.getString("audio.toolTipText")); audioButton.addActionListener(this); audioButton.setPreferredSize(buttonSize); audioButton.setMinimumSize(buttonSize); audioButton.setVisible(false); audioButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 0; // c.gridy = 0; gridbag.setConstraints(audioButton, c); add(audioButton); startButton = new JToggleButton(); startButton.setToolTipText(labels.getString("play.toolTipText")); startButton.addActionListener(this); startButton.setPreferredSize(buttonSize); startButton.setMinimumSize(buttonSize); startButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 1; // c.gridy = 0; gridbag.setConstraints(startButton, c); add(startButton); slider = new JMovieSliderAqua(); c = new GridBagConstraints(); // c.gridx = 2; // c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; gridbag.setConstraints(slider, c); add(slider); rewindButton = new JButton(); rewindButton.setToolTipText(labels.getString("previous.toolTipText")); rewindButton.setPreferredSize(buttonSize); rewindButton.setMinimumSize(buttonSize); rewindButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 3; // c.gridy = 0; gridbag.setConstraints(rewindButton, c); add(rewindButton); rewindButton.addActionListener(this); forwardButton = new JButton(); forwardButton.setToolTipText(labels.getString("next.toolTipText")); buttonSize = new Dimension(17, 16); forwardButton.setPreferredSize(buttonSize); forwardButton.setMinimumSize(buttonSize); forwardButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 4; // c.gridy = 0; gridbag.setConstraints(forwardButton, c); add(forwardButton); forwardButton.addActionListener(this); // The spacer is used when the play controls are hidden spacer = new JPanel(new BorderLayout()); spacer.setVisible(false); spacer.setPreferredSize(new Dimension(16, 16)); spacer.setMinimumSize(new Dimension(16, 16)); spacer.setOpaque(false); c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; gridbag.setConstraints(spacer, c); add(spacer); Border border = new BackdropBorder( new ButtonStateBorder( new ImageBevelBorder( Images.createImage(getClass(), "images/Player.border.png"), new Insets(1, 1, 1, 1), new Insets(0, 4, 1, 4)), new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderP.png"), new Insets(1, 1, 1, 1), new Insets(0, 4, 1, 4)))); Border westBorder = new BackdropBorder( new ButtonStateBorder( new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderWest.png"), new Insets(1, 1, 1, 0), new Insets(0, 4, 1, 4)), new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderWestP.png"), new Insets(1, 1, 1, 0), new Insets(0, 4, 1, 4)))); startButton.setBorder(westBorder); colorCyclingButton.setBorder(westBorder); audioButton.setBorder(westBorder); rewindButton.setBorder(westBorder); forwardButton.setBorder(border); startButton.setUI((ButtonUI) CustomButtonUI.createUI(startButton)); colorCyclingButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton)); audioButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton)); rewindButton.setUI((ButtonUI) CustomButtonUI.createUI(rewindButton)); forwardButton.setUI((ButtonUI) CustomButtonUI.createUI(forwardButton)); colorCyclingButton.setIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png"))); colorCyclingButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png"))); colorCyclingButton.setDisabledIcon( new ImageIcon( Images.createImage(getClass(), "images/PlayerStartColorCycling.disabled.png"))); audioButton.setIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.png"))); audioButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStopAudio.png"))); audioButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.disabled.png"))); startButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.png"))); startButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStop.png"))); startButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.disabled.png"))); rewindButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.png"))); rewindButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.disabled.png"))); forwardButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.png"))); forwardButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.disabled.png"))); // Automatic scrolling scrollHandler = new ScrollHandler(); scrollTimer = new Timer(60, scrollHandler); scrollTimer.setInitialDelay(300); // default InitialDelay? forwardButton.addMouseListener(scrollHandler); rewindButton.addMouseListener(scrollHandler); }
public Whiteboard() { setTitle("Distributed Whiteboard"); setResizable(false); btnIcon = new ImageIcon(); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(802, 607); JSplitPane splitPane = new JSplitPane(); splitPane.setAutoscrolls(true); splitPane.setDividerSize(0); getContentPane().add(splitPane, BorderLayout.CENTER); Container drawingCanvas = new Container(); drawingCanvas.setBackground(_bgColor); drawingCanvas.setForeground(_bgColor); splitPane.setRightComponent(drawingCanvas); canvas = new DrawingCanvas(); canvas.setAutoscrolls(true); canvas.setBounds(0, 0, 679, 494); drawingCanvas.add(canvas); JPanel pnlTools = new JPanel(); splitPane.setLeftComponent(pnlTools); GridBagLayout gbl_pnlTools = new GridBagLayout(); gbl_pnlTools.columnWidths = new int[] {45, 30, 0, 0}; gbl_pnlTools.rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gbl_pnlTools.columnWeights = new double[] {1.0, 0.0, 0.0, Double.MIN_VALUE}; gbl_pnlTools.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE}; pnlTools.setLayout(gbl_pnlTools); btnIcon = new ImageIcon("images/free_a.jpg"); btnFreedraw = new JToggleButton(btnIcon); btnFreedraw.setToolTipText("Freedraw"); btnIcon = new ImageIcon("images/free_b.jpg"); btnFreedraw.setSelectedIcon(btnIcon); btnFreedraw.setActionCommand("Freedraw"); btnFreedraw.addActionListener(this); btnFreedraw.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); GridBagConstraints gbc_tglbtnFreedraw = new GridBagConstraints(); gbc_tglbtnFreedraw.insets = new Insets(0, 0, 5, 5); gbc_tglbtnFreedraw.gridx = 0; gbc_tglbtnFreedraw.gridy = 0; pnlTools.add(btnFreedraw, gbc_tglbtnFreedraw); btnIcon = new ImageIcon("images/line_a.jpg"); btnLine = new JToggleButton(btnIcon); btnLine.setToolTipText("Draw line"); btnIcon = new ImageIcon("images/line_b.jpg"); btnLine.setSelectedIcon(btnIcon); btnLine.setActionCommand("Line"); btnLine.addActionListener(this); btnLine.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); GridBagConstraints gbc_btnLine = new GridBagConstraints(); gbc_btnLine.insets = new Insets(0, 0, 5, 5); gbc_btnLine.gridx = 1; gbc_btnLine.gridy = 0; pnlTools.add(btnLine, gbc_btnLine); btnIcon = new ImageIcon("images/circle_a.jpg"); btnCircle = new JToggleButton(btnIcon); btnCircle.setToolTipText("Draw circle"); btnIcon = new ImageIcon("images/circle_b.jpg"); btnCircle.setSelectedIcon(btnIcon); btnCircle.setActionCommand("Circle"); btnCircle.addActionListener(this); btnCircle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); GridBagConstraints gbc_btnCircle = new GridBagConstraints(); gbc_btnCircle.insets = new Insets(0, 0, 5, 5); gbc_btnCircle.gridx = 0; gbc_btnCircle.gridy = 1; pnlTools.add(btnCircle, gbc_btnCircle); btnIcon = new ImageIcon("images/ellipse_a.jpg"); btnOval = new JToggleButton(btnIcon); btnOval.setToolTipText("Draw ellipse"); btnIcon = new ImageIcon("images/ellipse_b.jpg"); btnOval.setSelectedIcon(btnIcon); btnOval.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); btnOval.setActionCommand("Oval"); btnOval.addActionListener(this); GridBagConstraints gbc_btnOval = new GridBagConstraints(); gbc_btnOval.insets = new Insets(0, 0, 5, 5); gbc_btnOval.gridx = 1; gbc_btnOval.gridy = 1; pnlTools.add(btnOval, gbc_btnOval); btnIcon = new ImageIcon("images/square_a.jpg"); btnSquare = new JToggleButton(btnIcon); btnSquare.setToolTipText("Square"); btnIcon = new ImageIcon("images/square_b.jpg"); btnSquare.setSelectedIcon(btnIcon); btnSquare.setActionCommand("Square"); btnSquare.addActionListener(this); btnSquare.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); GridBagConstraints gbc_btnSquare = new GridBagConstraints(); gbc_btnSquare.insets = new Insets(0, 0, 5, 5); gbc_btnSquare.gridx = 0; gbc_btnSquare.gridy = 2; pnlTools.add(btnSquare, gbc_btnSquare); btnIcon = new ImageIcon("images/rectangle_a.jpg"); btnRectangle = new JToggleButton(btnIcon); btnRectangle.setToolTipText("Draw rectangle"); btnIcon = new ImageIcon("images/rectangle_b.jpg"); btnRectangle.setSelectedIcon(btnIcon); btnRectangle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); btnRectangle.setActionCommand("Rectangle"); btnRectangle.addActionListener(this); GridBagConstraints gbc_btnRectangle = new GridBagConstraints(); gbc_btnRectangle.insets = new Insets(0, 0, 5, 5); gbc_btnRectangle.gridx = 1; gbc_btnRectangle.gridy = 2; pnlTools.add(btnRectangle, gbc_btnRectangle); btnIcon = new ImageIcon("images/text_a.jpg"); btnText = new JToggleButton(btnIcon); btnText.setToolTipText("Insert text"); btnIcon = new ImageIcon("images/text_b.jpg"); btnText.setSelectedIcon(btnIcon); btnText.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); btnText.setActionCommand("Text"); btnText.addActionListener(this); GridBagConstraints gbc_btnText = new GridBagConstraints(); gbc_btnText.insets = new Insets(0, 0, 5, 5); gbc_btnText.gridx = 0; gbc_btnText.gridy = 3; pnlTools.add(btnText, gbc_btnText); btnIcon = new ImageIcon("images/fill_a.jpg"); btnFill = new JToggleButton(btnIcon); btnFill.setToolTipText("Fill"); btnIcon = new ImageIcon("images/fill_b.jpg"); btnFill.setSelectedIcon(btnIcon); btnFill.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); btnFill.setActionCommand("Fill"); btnFill.addActionListener(this); GridBagConstraints gbc_btnFill = new GridBagConstraints(); gbc_btnFill.insets = new Insets(0, 0, 5, 5); gbc_btnFill.gridx = 1; gbc_btnFill.gridy = 3; pnlTools.add(btnFill, gbc_btnFill); btnIcon = new ImageIcon("images/erase_a.jpg"); btnErase = new JToggleButton(btnIcon); btnErase.setToolTipText("Erase"); btnIcon = new ImageIcon("images/erase_b.jpg"); btnErase.setSelectedIcon(btnIcon); btnErase.setActionCommand("Erase"); btnErase.addActionListener(this); btnErase.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); GridBagConstraints gbc_btnErase = new GridBagConstraints(); gbc_btnErase.insets = new Insets(0, 0, 5, 5); gbc_btnErase.gridx = 0; gbc_btnErase.gridy = 4; pnlTools.add(btnErase, gbc_btnErase); ButtonGroup group = new ButtonGroup(); group.add(btnFreedraw); group.add(btnLine); group.add(btnCircle); group.add(btnOval); group.add(btnSquare); group.add(btnRectangle); group.add(btnText); group.add(btnErase); JPanel pnlPreviews = new JPanel(); GridBagConstraints gbc_pnlPreviews = new GridBagConstraints(); gbc_pnlPreviews.gridwidth = 3; gbc_pnlPreviews.fill = GridBagConstraints.BOTH; gbc_pnlPreviews.gridx = 0; gbc_pnlPreviews.gridy = 8; pnlTools.add(pnlPreviews, gbc_pnlPreviews); GridBagLayout gbl_pnlPreviews = new GridBagLayout(); gbl_pnlPreviews.columnWidths = new int[] {0, 0}; gbl_pnlPreviews.rowHeights = new int[] {0, 0, 0, 0, 0, 0, 0}; gbl_pnlPreviews.columnWeights = new double[] {1.0, Double.MIN_VALUE}; gbl_pnlPreviews.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; pnlPreviews.setLayout(gbl_pnlPreviews); JSeparator separator_2 = new JSeparator(); GridBagConstraints gbc_separator_2 = new GridBagConstraints(); gbc_separator_2.insets = new Insets(0, 0, 5, 0); gbc_separator_2.gridx = 0; gbc_separator_2.gridy = 1; pnlPreviews.add(separator_2, gbc_separator_2); JLabel label = new JLabel(""); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 0); gbc_label.gridx = 0; gbc_label.gridy = 2; pnlPreviews.add(label, gbc_label); lblPenSize = new JLabel("Pen Size"); lblPenSize.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); GridBagConstraints gbc_lblPenSize = new GridBagConstraints(); gbc_lblPenSize.insets = new Insets(0, 0, 5, 0); gbc_lblPenSize.gridx = 0; gbc_lblPenSize.gridy = 3; pnlPreviews.add(lblPenSize, gbc_lblPenSize); cboPenSize = new JComboBox<String>(); cboPenSize.setModel( new DefaultComboBoxModel<String>( new String[] {"1", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20"})); cboPenSize.setSelectedIndex(1); cboPenSize.setToolTipText("Pen and Eraser Size"); GridBagConstraints gbc_cboPenSize = new GridBagConstraints(); gbc_cboPenSize.insets = new Insets(0, 0, 5, 0); gbc_cboPenSize.fill = GridBagConstraints.HORIZONTAL; gbc_cboPenSize.gridx = 0; gbc_cboPenSize.gridy = 4; pnlPreviews.add(cboPenSize, gbc_cboPenSize); cboPenSize.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent ie) { _penWidth = Integer.parseInt(cboPenSize.getSelectedItem().toString()); pen.setPen(_penWidth, pen.getPen().getEndCap(), pen.getPen().getLineJoin()); canvas.setPen(pen); revalidate(); } }); pnlColorChooser = new JPanel(); getContentPane().add(pnlColorChooser, BorderLayout.SOUTH); GridBagLayout gbl_pnlColorChooser = new GridBagLayout(); gbl_pnlColorChooser.columnWidths = new int[] {0, 62, 0, 36, 0}; gbl_pnlColorChooser.rowHeights = new int[] {0, 0, 0}; gbl_pnlColorChooser.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; gbl_pnlColorChooser.rowWeights = new double[] {0.0, 0.0, Double.MIN_VALUE}; pnlColorChooser.setLayout(gbl_pnlColorChooser); btnColor = new JButton("Pen Color"); btnColor.setActionCommand("PenColor"); btnColor.addActionListener(this); GridBagConstraints gbc_btnColor = new GridBagConstraints(); gbc_btnColor.insets = new Insets(0, 0, 5, 5); gbc_btnColor.gridx = 0; gbc_btnColor.gridy = 0; pnlColorChooser.add(btnColor, gbc_btnColor); lblColor = new JLabel(""); lblColor.setPreferredSize(new Dimension(79, 23)); lblColor.setMinimumSize(new Dimension(79, 23)); lblColor.setMaximumSize(new Dimension(79, 23)); lblColor.setOpaque(true); lblColor.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, Color.BLACK)); lblColor.setBackground(Color.BLACK); GridBagConstraints gbc_lblColor = new GridBagConstraints(); gbc_lblColor.insets = new Insets(0, 0, 0, 5); gbc_lblColor.gridx = 0; gbc_lblColor.gridy = 1; pnlColorChooser.add(lblColor, gbc_lblColor); JLabel lblSelectedTool = new JLabel("Selected Tool:"); lblSelectedTool.setFont(new Font("Tahoma", Font.ITALIC, 10)); GridBagConstraints gbc_lblSelectedTool = new GridBagConstraints(); gbc_lblSelectedTool.insets = new Insets(0, 0, 0, 5); gbc_lblSelectedTool.gridx = 2; gbc_lblSelectedTool.gridy = 1; pnlColorChooser.add(lblSelectedTool, gbc_lblSelectedTool); lblTool = new JLabel(""); lblTool.setHorizontalAlignment(SwingConstants.LEFT); lblTool.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 12)); GridBagConstraints gbc_lblTool = new GridBagConstraints(); gbc_lblTool.gridx = 3; gbc_lblTool.gridy = 1; pnlColorChooser.add(lblTool, gbc_lblTool); pnlColorChooser.setVisible(true); JMenuBar menuMainMenu = new JMenuBar(); menuMainMenu.setName(""); setJMenuBar(menuMainMenu); JMenu mnFile = new JMenu("File"); mnFile.setActionCommand("File"); menuMainMenu.add(mnFile); mntmNew = new JMenuItem("New"); mntmNew.setMnemonic(KeyEvent.VK_N); mntmNew.setActionCommand("New"); mntmNew.addActionListener(this); mnFile.add(mntmNew); mntmOpen = new JMenuItem("Open"); mntmOpen.setMnemonic(KeyEvent.VK_O); mntmOpen.setActionCommand("Open"); mntmOpen.addActionListener(this); mnFile.add(mntmOpen); JSeparator separator = new JSeparator(); mnFile.add(separator); mntmSave = new JMenuItem("Save"); mntmSave.setMnemonic(KeyEvent.VK_S); mntmSave.setActionCommand("Save"); mntmSave.addActionListener(this); mnFile.add(mntmSave); mntmSaveAs = new JMenuItem("Save As"); mntmSaveAs.setActionCommand("SaveAs"); mntmSaveAs.addActionListener(this); mnFile.add(mntmSaveAs); JSeparator separator_1 = new JSeparator(); mnFile.add(separator_1); mntmExit = new JMenuItem("Exit"); mntmExit.setMnemonic(KeyEvent.VK_E); mntmExit.setActionCommand("Exit"); mntmExit.addActionListener(this); mnFile.add(mntmExit); JMenu mnNetwork = new JMenu("Network"); mnNetwork.setActionCommand("Network"); menuMainMenu.add(mnNetwork); mntmConnect = new JMenuItem("Connect"); mntmConnect.setMnemonic(KeyEvent.VK_C); mntmConnect.setActionCommand("Connect"); mntmConnect.addActionListener(this); mnNetwork.add(mntmConnect); mntmDisconnect = new JMenuItem("Disconnect"); mntmDisconnect.setMnemonic(KeyEvent.VK_D); mntmDisconnect.setActionCommand("Disconnect"); mntmDisconnect.addActionListener(this); mntmDisconnect.setEnabled(false); mnNetwork.add(mntmDisconnect); JSeparator separator_3 = new JSeparator(); mnNetwork.add(separator_3); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { closeOperation(); } }); }
public PanelSpec(SmedAction dia) { dlg = dia; setLayout(null); add(getShapeButton(pillarButton, 0, 0, 34, 32, "Pillar", Shp.PILLAR, Obj.BOYSPP)); add(getShapeButton(sparButton, 34, 0, 34, 32, "Spar", Shp.SPAR, Obj.BOYSPP)); add(getShapeButton(canButton, 68, 0, 34, 32, "Can", Shp.CAN, Obj.BOYSPP)); add(getShapeButton(coneButton, 102, 0, 34, 32, "Cone", Shp.CONI, Obj.BOYSPP)); add(getShapeButton(sphereButton, 0, 32, 34, 32, "Sphere", Shp.SPHERI, Obj.BOYSPP)); add(getShapeButton(barrelButton, 34, 32, 34, 32, "Barrel", Shp.BARREL, Obj.BOYSPP)); add(getShapeButton(superButton, 68, 32, 34, 32, "Super", Shp.SUPER, Obj.BOYSPP)); add(getShapeButton(floatButton, 102, 32, 34, 32, "Float", Shp.FLOAT, Obj.LITFLT)); add(getShapeButton(beaconButton, 0, 64, 34, 32, "Beacon", Shp.BEACON, Obj.BCNSPP)); add(getShapeButton(towerButton, 34, 64, 34, 32, "TowerB", Shp.TOWER, Obj.BCNSPP)); add(getShapeButton(stakeButton, 68, 64, 34, 32, "Stake", Shp.STAKE, Obj.BCNSPP)); add(getShapeButton(cairnButton, 102, 64, 34, 32, "CairnB", Shp.CAIRN, Obj.BCNSPP)); categoryLabel = new JLabel(Messages.getString("Category"), SwingConstants.CENTER); categoryLabel.setBounds(new Rectangle(5, 125, 160, 18)); add(categoryLabel); categoryBox = new JComboBox(); categoryBox.setBounds(new Rectangle(5, 142, 160, 18)); add(categoryBox); categoryBox.setVisible(true); categoryBox.addActionListener(alCategoryBox); addCatItem("", Cat.NOCAT); addCatItem(Messages.getString("UKPurpose"), Cat.SPM_UNKN); addCatItem(Messages.getString("Warning"), Cat.SPM_WARN); addCatItem(Messages.getString("ChanSeparation"), Cat.SPM_CHBF); addCatItem(Messages.getString("Yachting"), Cat.SPM_YCHT); addCatItem(Messages.getString("Cable"), Cat.SPM_CABL); addCatItem(Messages.getString("Outfall"), Cat.SPM_OFAL); addCatItem(Messages.getString("ODAS"), Cat.SPM_ODAS); addCatItem(Messages.getString("RecreationZone"), Cat.SPM_RECN); addCatItem(Messages.getString("Mooring"), Cat.SPM_MOOR); addCatItem(Messages.getString("LANBY"), Cat.SPM_LNBY); addCatItem(Messages.getString("Leading"), Cat.SPM_LDNG); addCatItem(Messages.getString("Notice"), Cat.SPM_NOTC); addCatItem(Messages.getString("TSS"), Cat.SPM_TSS); addCatItem(Messages.getString("FoulGround"), Cat.SPM_FOUL); addCatItem(Messages.getString("Diving"), Cat.SPM_DIVE); addCatItem(Messages.getString("FerryCross"), Cat.SPM_FRRY); addCatItem(Messages.getString("Anchorage"), Cat.SPM_ANCH); mooringBox = new JComboBox(); mooringBox.setBounds(new Rectangle(5, 142, 160, 18)); add(mooringBox); mooringBox.setVisible(false); mooringBox.addActionListener(alMooringBox); addMorItem("", Cat.NOCAT); addMorItem(Messages.getString("Dolphin"), Cat.MOR_DLPN); addMorItem(Messages.getString("DevDolphin"), Cat.MOR_DDPN); addMorItem(Messages.getString("Bollard"), Cat.MOR_BLRD); addMorItem(Messages.getString("Wall"), Cat.MOR_WALL); addMorItem(Messages.getString("Post"), Cat.MOR_POST); addMorItem(Messages.getString("Chain"), Cat.MOR_CHWR); addMorItem(Messages.getString("Rope"), Cat.MOR_ROPE); addMorItem(Messages.getString("Automatic"), Cat.MOR_AUTO); addMorItem(Messages.getString("MooringBuoy"), Cat.MOR_BUOY); addMorItem(Messages.getString("CALM"), Cat.INB_CALM); addMorItem(Messages.getString("SBM"), Cat.INB_SBM); topmarkButton.setBounds(new Rectangle(136, 0, 34, 32)); topmarkButton.setToolTipText(Messages.getString("Topmark")); topmarkButton.setBorder(BorderFactory.createLoweredBevelBorder()); topmarkButton.addActionListener(alTop); add(topmarkButton); // noticeButton.setBounds(new Rectangle(136, 32, 34, 32)); // noticeButton.setToolTipText(Messages.getString("Notice")); // noticeButton.setBorder(BorderFactory.createLoweredBevelBorder()); // noticeButton.addActionListener(alNotice); // add(noticeButton); mooringButton.setBounds(new Rectangle(136, 64, 34, 32)); mooringButton.setToolTipText(Messages.getString("Mooring")); mooringButton.setBorder(BorderFactory.createLoweredBevelBorder()); mooringButton.addActionListener(alMooring); add(mooringButton); }
public void jbInit() throws Exception { this.setLayout(null); fContractPriceTextField.setFont(new java.awt.Font("Dialog", 1, 11)); fContractPriceTextField.setDisabledTextColor(Color.black); fContractPriceTextField.setEditable(false); fContractPriceTextField.setHorizontalAlignment(SwingConstants.RIGHT); fContractPriceTextField.setBounds(new java.awt.Rectangle(285, 182, 55, 21)); fContractVolumeTextField.setFont(new java.awt.Font("Dialog", 1, 11)); fContractVolumeTextField.setDisabledTextColor(Color.black); fContractVolumeTextField.setEditable(false); fContractVolumeTextField.setHorizontalAlignment(SwingConstants.RIGHT); fContractVolumeTextField.setBounds(new java.awt.Rectangle(285, 238, 55, 21)); fContractVolumeLabel.setText(fRb.getString("CONTRACT_VOLUME")); fContractVolumeLabel.setForeground(Color.black); fContractVolumeLabel.setBounds(new java.awt.Rectangle(272, 218, 99, 17)); fContractPriceLabel.setBounds(new java.awt.Rectangle(272, 160, 92, 17)); fContractPriceLabel.setText(fRb.getString("CONTRACT_PRICE")); fContractPriceLabel.setForeground(Color.black); fBoardGraph.setLayout(borderLayout1); fDay.setBounds(new java.awt.Rectangle(337, 87, 42, 21)); fDayLabel.setText(fRb.getString("DAY") + ":"); fDayLabel.setForeground(Color.black); fDayLabel.setBounds(new java.awt.Rectangle(267, 89, 67, 17)); fBoardLabel.setText(fRb.getString("SESSION") + ":"); fBoardLabel.setForeground(Color.black); fBoardLabel.setBounds(new java.awt.Rectangle(267, 121, 68, 17)); fBoard.setBounds(new java.awt.Rectangle(337, 119, 42, 22)); fPreviousBoardLabel.setFont(new java.awt.Font("Dialog", 1, 12)); fPreviousBoardLabel.setText(fRb.getString("PREVIOUS_PRICING")); fPreviousBoardLabel.setForeground(Color.black); fPreviousBoardLabel.setBounds(new java.awt.Rectangle(85, 4, 99, 17)); fXYToggleButton.setBorder(BorderFactory.createRaisedBevelBorder()); fXYToggleButton.setText("Exchange X-Y"); fXYToggleButton.setBounds(new java.awt.Rectangle(268, 43, 114, 25)); fXYToggleButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { fIsExchangeXY = fXYToggleButton.isSelected(); fIsUpdated = true; gUpdate(); } }); this.setBorder(BorderFactory.createEtchedBorder()); this.setBounds(new java.awt.Rectangle(325, 7, 387, 283)); this.setLayout(null); fBoardGraph.setBorder(BorderFactory.createEtchedBorder()); fBoardGraph.setBounds(new java.awt.Rectangle(5, 26, 257, 243)); fBoardGraph.getGraph().add(new UGraphData(fSellName, fSellColor)); fBoardGraph.getGraph().add(new UGraphData(fBuyName, fBuyColor)); fBoardGraph.setLeftMargin(60); this.add(fBoardGraph, null); this.add(fContractVolumeTextField, null); this.add(fContractVolumeLabel, null); this.add(fContractPriceTextField, null); this.add(fContractPriceLabel, null); this.add(fBoardLabel, null); this.add(fDayLabel, null); this.add(fXYToggleButton, null); this.add(fPreviousBoardLabel, null); this.add(fDay, null); this.add(fBoard, null); fBoardGraph.setBackground(Color.white); fBoardGraph.setNumOfHorizontalLine(0); fBoardGraph.setNumOfVerticalLine(0); fBoardGraph.setFixedMaxX(1); fBoardGraph.setFixedMinX(0); fBoardGraph.setFixedMaxY(1); fBoardGraph.setFixedMinY(0); addComponentListener( new ComponentAdapter() { public void componentShown(ComponentEvent ce) { gUpdate(); } }); }
/** * Creates a new instance of <code>Channel</code> using the specified non-<code>null</code> * channel model. * * @param model The model to be used by this channel. * @throws IllegalArgumentException If the model is <code>null</code>. */ public Channel(SamplerChannelModel model) { super(model); setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3)); // setToolTipText(" Channel: " + String.valueOf(getChannelID()) + " "); Dimension d = btnInstr.getPreferredSize(); btnInstr.setMaximumSize(new Dimension(Short.MAX_VALUE, d.height)); p.add(btnInstr); p.add(Box.createRigidArea(new Dimension(6, 0))); lStreams.setHorizontalAlignment(JLabel.CENTER); lVoices.setHorizontalAlignment(JLabel.CENTER); JPanel statPane = new JPanel(); statPane.setBorder(BorderFactory.createLoweredBevelBorder()); statPane.setLayout(new BoxLayout(statPane, BoxLayout.X_AXIS)); statPane.add(Box.createRigidArea(new Dimension(6, 0))); statPane.add(lStreams); statPane.add(new JLabel("/")); statPane.add(lVoices); statPane.add(Box.createRigidArea(new Dimension(6, 0))); p.add(statPane); p.add(Box.createRigidArea(new Dimension(6, 0))); btnMute.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); p.add(btnMute); p.add(Box.createRigidArea(new Dimension(6, 0))); btnSolo.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); p.add(btnSolo); p.add(Box.createRigidArea(new Dimension(6, 0))); JPanel volumePane = new JPanel(); volumePane.setBorder(BorderFactory.createLoweredBevelBorder()); volumePane.setLayout(new BoxLayout(volumePane, BoxLayout.X_AXIS)); volumePane.add(Box.createRigidArea(new Dimension(6, 0))); d = slVolume.getPreferredSize(); slVolume.setMaximumSize(new Dimension(d.width > 300 ? d.width : 300, d.height)); volumePane.add(slVolume); lVolume.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 6)); lVolume.setHorizontalAlignment(lVolume.RIGHT); // We use this to set the size of the lVolume that will be used in setVolume() // to prevent the frequent resizing of lVolume lVolume.setText("100%"); volumePane.add(lVolume); p.add(volumePane); p.add(Box.createRigidArea(new Dimension(6, 0))); btnProperties.setContentAreaFilled(false); btnProperties.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); btnProperties.setIcon(iconShowProperties); btnProperties.setSelectedIcon(iconHideProperties); p.add(btnProperties); mainPane.add(p); propertiesPane = new ChannelProperties(model); propertiesPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 3)); propertiesPane.setVisible(false); mainPane.add(propertiesPane); add(mainPane); d = getPreferredSize(); setMaximumSize(new Dimension(getMaximumSize().width, d.height)); getModel().addSamplerChannelListener(getHandler()); actInstr = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (actInstr.isEnabled()) loadInstrument(); } }; btnInstr.addActionListener(actInstr); btnMute.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changeMute(); } }); btnSolo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changeSolo(); } }); slVolume.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { setVolume(); } }); btnProperties.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { showProperties(btnProperties.isSelected()); String s; if (btnProperties.isSelected()) { s = i18n.getButtonLabel("Channel.ttHideProps"); } else { s = i18n.getButtonLabel("Channel.ttShowProps"); } btnProperties.setToolTipText(s); } }); btnProperties.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); String s; if (btnProperties.isSelected()) s = i18n.getButtonLabel("Channel.ttHideProps"); else s = i18n.getButtonLabel("Channel.ttShowProps"); btnProperties.setToolTipText(s); addPropertyChangeListener(getHandler()); updateChannelInfo(); }