@Override public void windowClosing(WindowEvent arg0) { acervo.fechaDB(); }
/** Initialize the contents of the frame. */ private void inicializarAcervo() { acervo.addArtista("Pink Floyd"); acervo.addArtista("Led Zeppelin"); acervo.addArtista("Jethro Tull"); acervo.addArtista("Kansas"); acervo.addArtista("Queen"); acervo.addArtista("Charlie Brown Jr."); acervo.addArtista("João Neto e Frederico"); acervo.addMusica("Wish You Were Here", "Pink Floyd"); acervo.addMusica("Aqualung", "Jethro Tull"); acervo.addMusica("One White Duck", "Jethro Tull"); acervo.addMusica("Song for America", "Kansas"); acervo.addMusica("Love of my Life", "Queen"); acervo.addMusica("Não é serio", "Charlie Brown Jr."); acervo.addMusica("O Preço", "Charlie Brown Jr."); acervo.addMusica("Delegada", "João Neto e Frederico"); acervo.addMusica("Have a Cigar", "Pink Floyd"); }
private void initialize() { this.inicializarAcervo(); frmSadsa = new JFrame(); frmSadsa.setTitle("Acervo de M\u00FAsicas"); frmSadsa.setIconImage(Toolkit.getDefaultToolkit().getImage("img\\fundo1.png")); frmSadsa.setBounds(100, 100, 764, 643); frmSadsa.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktopPane = new JDesktopPane(); frmSadsa.getContentPane().add(desktopPane, BorderLayout.CENTER); txtNomeTrecho = new JTextField(); acervo.registerObserver(view); // inicializarAcervo(); txtNomeTrecho.addFocusListener( new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { if (txtNomeTrecho.getText().equals("")) txtNomeTrecho.setText("Digite o nome ou trecho da música..."); } }); txtNomeTrecho.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { txtNomeTrecho.setText(""); } }); txtNomeTrecho.setBounds(250, 64, 266, 20); desktopPane.add(txtNomeTrecho); txtNomeTrecho.setHorizontalAlignment(SwingConstants.CENTER); txtNomeTrecho.setText("Digite o nome ou trecho da m\u00FAsica ..."); txtNomeTrecho.setColumns(10); lblNewLabel = new JLabel(""); desktopPane.setLayer(lblNewLabel, 0); lblNewLabel.setIcon(new ImageIcon("img\\fundo1.png")); lblNewLabel.setBounds(0, 0, 907, 633); desktopPane.add(lblNewLabel); radioTrecho.setBounds(389, 33, 140, 23); desktopPane.add(radioTrecho); buttonGroup.add(radioTrecho); desktopPane.setLayer(radioTrecho, 1); radioNome.setBounds(250, 33, 124, 23); desktopPane.add(radioNome); buttonGroup.add(radioNome); desktopPane.setLayer(radioNome, 1); radioNome.setSelected(true); desktopPane.setLayer(scrollPane, 1); scrollPane.setBounds(127, 95, 500, 481); desktopPane.add(scrollPane); panel = new JPanel(); scrollPane.setViewportView(panel); desktopPane.setLayer(panel, 1); letraNaView.setBackground(Color.WHITE); letraNaView.setVerticalAlignment(SwingConstants.TOP); letraNaView.setHorizontalAlignment(SwingConstants.LEFT); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup( gl_panel .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel .createSequentialGroup() .addContainerGap() .addComponent( letraNaView, GroupLayout.PREFERRED_SIZE, 463, GroupLayout.PREFERRED_SIZE) .addContainerGap(25, Short.MAX_VALUE))); gl_panel.setVerticalGroup( gl_panel .createParallelGroup(Alignment.LEADING) .addGroup( gl_panel .createSequentialGroup() .addGap(20) .addComponent( letraNaView, GroupLayout.PREFERRED_SIZE, 1868, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel.setLayout(gl_panel); btnFecharLetra = new JLabel("New label"); btnFecharLetra.setVisible(false); btnFecharLetra.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { scrollPane.setVisible(false); btnFecharLetra.setVisible(false); } }); btnFecharLetra.setBounds(626, 95, 24, 14); desktopPane.add(btnFecharLetra); btnFecharLetra.setIcon(new ImageIcon("img\\fecharLetra.png")); desktopPane.setLayer(btnFecharLetra, 2); scrollPane.setVisible(false); txtNomeTrecho.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent arg0) { if (arg0.getKeyCode() == KeyEvent.VK_ENTER) { // TODO , QUANDO USER APERTAR ENTER PRA BUSCAR if (txtNomeTrecho.getText().equals("") && radioTrecho.isSelected()) return; if (radioNome.isSelected()) view.setBusca(bnm); else view.setBusca(btm); acervo.buscarMusica(txtNomeTrecho.getText()); } } }); }