public MainPanel() { super(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.add( makePanel( "Look&Feel Default", new JButton( new AbstractAction("showMessageDialog1") { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(panel, "showMessageDialog1"); } }))); panel.add( makePanel( "notice2.wav", new JButton( new AbstractAction("showMessageDialog2") { @Override public void actionPerformed(ActionEvent e) { UIManager.put( "AuditoryCues.playList", UIManager.get("AuditoryCues.noAuditoryCues")); loadAndPlayAudio("notice2.wav"); JOptionPane.showMessageDialog(panel, "showMessageDialog2"); UIManager.put("AuditoryCues.playList", OPTION_PANE_AUDITORY_CUES); } }))); JMenuBar mb = new JMenuBar(); mb.add(LookAndFeelUtil.createLookAndFeelMenu()); add(mb, BorderLayout.NORTH); add(panel); setPreferredSize(new Dimension(320, 240)); }
private JPanel getMixerOptionsPanel() { if (mixerOptionsPanel == null) { mixerOptionsPanel = new JPanel(); mixerOptionsPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Mixer")); mixerOptionsPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.NONE; c.weightx = 1; c.insets = new Insets(8, 4, 0, 0); mixerOptionsPanel.add(new JLabel("Select mixer:"), c); c.gridy = 1; mixerOptionsPanel.add(getMixerComboBox(), c); c.gridy = 2; mixerOptionsPanel.add(getMixerDefaultButton(), c); c.insets = new Insets(16, 4, 0, 0); c.gridy = 3; mixerOptionsPanel.add(new JLabel("Enable mixer features:"), c); c.insets = new Insets(6, 0, 0, 0); c.gridy = 4; mixerOptionsPanel.add(getEnableMixerVolumeCheckBox(), c); c.insets = new Insets(0, 0, 0, 0); c.gridy = 5; mixerOptionsPanel.add(getEnableMixerPanCheckBox(), c); if (AudioSystem.getMixerInfo().length == 0) { for (Component child : mixerOptionsPanel.getComponents()) { child.setEnabled(false); } } } return mixerOptionsPanel; }
private JPanel getSoundOptionsPanel() { if (soundOptionsPanel == null) { soundOptionsPanel = new JPanel(); soundOptionsPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Sound Effects")); soundOptionsPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = 1; c.weightx = 1; c.anchor = GridBagConstraints.NORTHWEST; c.gridwidth = GridBagConstraints.REMAINDER; soundOptionsPanel.add(getEnableSoundCheckBox(), c); soundOptionsPanel.add(getEnableGunshotCheckBox(), c); soundOptionsPanel.add(getEnableBulletHitCheckBox(), c); soundOptionsPanel.add(getEnableRobotDeathCheckBox(), c); soundOptionsPanel.add(getEnableWallCollisionCheckBox(), c); soundOptionsPanel.add(getEnableRobotCollisionCheckBox(), c); c.insets = new Insets(10, 0, 0, 10); c.gridwidth = 1; c.fill = 0; c.weighty = 1; c.weightx = 0; soundOptionsPanel.add(getEnableAllSoundsButton(), c); c.weightx = 1; c.gridwidth = GridBagConstraints.REMAINDER; soundOptionsPanel.add(getDisableAllSoundsButton(), c); if (AudioSystem.getMixerInfo().length == 0) { for (Component child : soundOptionsPanel.getComponents()) { child.setEnabled(false); } } } return soundOptionsPanel; }
private static JPanel makePanel(String title, JComponent c) { JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createTitledBorder(title)); p.add(c); return p; }