| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 659 人关注过本帖
标题:被控件折腾的够呛啊,大家帮我看一下
只看楼主 加入收藏
specilize
Rank: 4
等 级:业余侠客
帖 子:126
专家分:247
注 册:2011-2-20
结帖率:100%
收藏
 问题点数:0 回复次数:1 
被控件折腾的够呛啊,大家帮我看一下
下面是我用NetBean生成的控件代码,其中的JTextField变量TSearch没法输入,即使我显示光标并且获取输入焦点,找了好久,什么都试了,还是不行,还有JList变量LSongList显示出来后垂直滚动条都没法用,不知道为什么,我在相应部分做了注释,望大家帮我看一下,实在是搞不明白。


程序代码:
public class MP3Player extends javax.swing.JFrame {
    
    Player player;    //播放器
    String mediaLocation;
    String urlLocation;
    MediaTracker mediaTracker=new MediaTracker(this);
    boolean useDefaultImage=true;
    Image urlImage;
    boolean isFile=true;
    boolean playing=false;
    boolean pause=true;
    boolean stop=true;
    
    class TexPicPanel extends JPanel{
        
        public void setBackgroundImage(){
            repaint();
        }
        protected void paintComponent(Graphics g){
            if(useDefaultImage){
                ImageIcon imageIcon=new ImageIcon("src\\pic\\背景图片.jpg");
                Image image =new ImageIcon("src\\pic\\背景图片.jpg").getImage();
                g.drawImage((Image)image,0,0,PSelPlay.getSize().width,
                    PSelPlay.getSize().height,0,0,imageIcon.getIconWidth(),imageIcon.getIconHeight(),this);
                PSelPlay.setVisible(true);
                PSelPlay.setOpaque(false);
                String content=new String("正在为您搜索网络图片..........");
                JLabel lyric=new JLabel(content,null,JLabel.CENTER);
                lyric.setFont(new Font("仿宋_GB2312", 0, 30));
                lyric.setSize(PSelPlay.getSize().width,PSelPlay.getSize().height);
                lyric.setOpaque(false);
                lyric.setVisible(true);
                PSelPlay.add(lyric); 
            }
            else
            { 
                g.drawImage(urlImage,0,0,PSelPlay.getSize().width,PSelPlay.getSize().height,this);
                
            }
        } 
        
        
    /*    public void update(Graphics g){
            System.out.println("调用update");
            Image image=new ImageIcon("D:\\Java\\MP3Player\\MP3Player\\src\\pic\\酷我.jpg").getImage();
            g.drawImage(image,0,0, this);
        }  */
        
    }
    
    /** Creates new form MP3Player */
    public MP3Player() {
        getContentPane().setBackground(Color.WHITE);
        initComponents();
        player=new Player();
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PSelection = new javax.swing.JPanel();
        TPSelection = new javax.swing.JTabbedPane();
        PSelPlay = new TexPicPanel();
        PSelSearch = new javax.swing.JPanel();
        BSearch = new javax.swing.JButton();
        BTry = new javax.swing.JButton();
        BDownload = new javax.swing.JButton();
        LResult = new javax.swing.JLabel();
        LInfo = new javax.swing.JLabel();
        SPSongList = new javax.swing.JScrollPane();
        LSongList = new javax.swing.JList();
        TSearch = new javax.swing.JTextField(16);
        PSelDownload = new javax.swing.JPanel();
        PControl = new javax.swing.JPanel();
        BLastSong = new javax.swing.JButton();
        TBPlay = new javax.swing.JToggleButton();
        BNextSong = new javax.swing.JButton();
        BStop = new javax.swing.JButton();
        SProcess = new javax.swing.JSlider();
        LProcess = new javax.swing.JLabel();
        BOpenFile = new javax.swing.JButton();
        PPlayList = new javax.swing.JPanel();
        TPPlayList = new javax.swing.JTabbedPane();
        PDefaultList = new javax.swing.JPanel();
        SPDefaultList = new javax.swing.JScrollPane();
        LDefaultList = new javax.swing.JList();
        PMyList = new javax.swing.JPanel();
        SPMyList = new javax.swing.JScrollPane();
        LMyList = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("MP3播放器");
        setBackground(java.awt.Color.white);
        setResizable(false);
        setBounds(new java.awt.Rectangle(100, 100, 800, 600));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setFocusableWindowState(false);
        setFont(new java.awt.Font("仿宋_GB2312", 0, 10));
        addWindowStateListener(new java.awt.event.WindowStateListener() {
            public void windowStateChanged(java.awt.event.WindowEvent evt) {
                formWindowStateChanged(evt);
            }
        });

        PSelection.setBackground(new java.awt.Color(255, 255, 255));
        PSelection.setForeground(new java.awt.Color(255, 255, 255));
        PSelection.setPreferredSize(new java.awt.Dimension(445, 450));

        TPSelection.setBackground(new java.awt.Color(255, 255, 255));
        TPSelection.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(0, 188, 198), null));
        TPSelection.setForeground(new java.awt.Color(160, 204, 255));
        TPSelection.setFont(new java.awt.Font("宋体", 0, 14));
        TPSelection.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                TPSelectionStateChanged(evt);
            }
        });

        PSelPlay.setBackground(new java.awt.Color(255, 255, 255));
        PSelPlay.setForeground(new java.awt.Color(255, 255, 255));
        PSelPlay.setFont(new java.awt.Font("宋体", 0, 14));

        javax.swing.GroupLayout PSelPlayLayout = new javax.swing.GroupLayout(PSelPlay);
        PSelPlay.setLayout(PSelPlayLayout);
        PSelPlayLayout.setHorizontalGroup(
            PSelPlayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 436, Short.MAX_VALUE)
        );
        PSelPlayLayout.setVerticalGroup(
            PSelPlayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 416, Short.MAX_VALUE)
        );

        TPSelection.addTab("正在播放", PSelPlay);
        PSelPlay.getAccessibleContext().setAccessibleName("");
        PSelPlay.getAccessibleContext().setAccessibleParent(TPSelection);

        PSelSearch.setBackground(new java.awt.Color(255, 255, 255));
        PSelSearch.setForeground(new java.awt.Color(255, 255, 255));
        PSelSearch.setFont(new java.awt.Font("宋体", 0, 14));

        BSearch.setBackground(new java.awt.Color(255, 255, 255));
        BSearch.setForeground(new java.awt.Color(117, 143, 149));
        BSearch.setText("搜索");
        BSearch.setActionCommand("bSearch");
        BSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BSearchActionPerformed(evt);
            }
        });

        BTry.setBackground(new java.awt.Color(232, 244, 255));
        BTry.setForeground(new java.awt.Color(184, 191, 221));
        BTry.setIcon(new javax.swing.ImageIcon("src\\pic\\试听.jpg")); // NOI18N
        BTry.setText("试听");
        BTry.setRequestFocusEnabled(false);
        BTry.setRolloverEnabled(false);
        BTry.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTryActionPerformed(evt);
            }
        });

        BDownload.setForeground(new java.awt.Color(114, 137, 167));
        BDownload.setIcon(new javax.swing.ImageIcon("src\\pic\\下载.jpg")); // NOI18N
        BDownload.setText("下载");
        BDownload.setIconTextGap(8);
        BDownload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BDownloadActionPerformed(evt);
            }
        });

        LResult.setBackground(new java.awt.Color(255, 255, 255));
        LResult.setEnabled(false);
        LResult.setOpaque(true);

        LInfo.setBackground(new java.awt.Color(255, 255, 255));
        LInfo.setText("        歌名                 歌手              专辑               大小");
        LInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(140, 255, 219), null));

        SPSongList.setBackground(new java.awt.Color(255, 255, 255));
        SPSongList.setForeground(new java.awt.Color(0, 118, 244));

        //这里,LSongList在这里被加入,但是显示出来的垂直滚动条没法滚动
        LSongList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                LSongListValueChanged(evt);
            }
        });
        SPSongList.setViewportView(LSongList);
        
        
        //这里,TSearch在以下代码中被加入容器,但是没有光标给我输入,即使我显示显示光标,获取输入焦点,还是不能输入
        
        javax.swing.GroupLayout PSelSearchLayout = new javax.swing.GroupLayout(PSelSearch);
        PSelSearch.setLayout(PSelSearchLayout);
        PSelSearchLayout.setHorizontalGroup(
            PSelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PSelSearchLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(PSelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PSelSearchLayout.createSequentialGroup()
                        .addComponent(BTry)
                        .addPreferredGap(javax.swing.)
                        .addComponent(BDownload, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.)
                        .addComponent(LResult, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE))
                    .addGroup(PSelSearchLayout.createSequentialGroup()
                        .addComponent(TSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(BSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addComponent(LInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
            .addComponent(SPSongList, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
        );
        PSelSearchLayout.setVerticalGroup(
            PSelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PSelSearchLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PSelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BSearch))
                .addGap(18, 18, 18)
                .addGroup(PSelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PSelSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(LResult, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(BTry))
                    .addComponent(BDownload))
                .addPreferredGap(javax.swing.)
                .addComponent(LInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.)
                .addComponent(SPSongList, javax.swing.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE))
        );

        TPSelection.addTab("网络曲库", PSelSearch);
        PSelSearch.getAccessibleContext().setAccessibleParent(TPSelection);

        PSelDownload.setBackground(new java.awt.Color(255, 255, 255));
        PSelDownload.setForeground(new java.awt.Color(255, 255, 255));
        PSelDownload.setFont(new java.awt.Font("宋体", 0, 14));

        javax.swing.GroupLayout PSelDownloadLayout = new javax.swing.GroupLayout(PSelDownload);
        PSelDownload.setLayout(PSelDownloadLayout);
        PSelDownloadLayout.setHorizontalGroup(
            PSelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 436, Short.MAX_VALUE)
        );
        PSelDownloadLayout.setVerticalGroup(
            PSelDownloadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 416, Short.MAX_VALUE)
        );

        TPSelection.addTab("本地曲库", PSelDownload);
        PSelDownload.getAccessibleContext().setAccessibleParent(TPSelection);

        javax.swing.GroupLayout PSelectionLayout = new javax.swing.GroupLayout(PSelection);
        PSelection.setLayout(PSelectionLayout);
        PSelectionLayout.setHorizontalGroup(
            PSelectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TPSelection, javax.swing.GroupLayout.DEFAULT_SIZE, 445, Short.MAX_VALUE)
        );
        PSelectionLayout.setVerticalGroup(
            PSelectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TPSelection, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
        );

        PControl.setBackground(new java.awt.Color(144, 191, 255));

        BLastSong.setBackground(new java.awt.Color(144, 191, 255));
        BLastSong.setIcon(new javax.swing.ImageIcon("src\\pic\\上一首.jpg"));
        BLastSong.setActionCommand("bLastSong");
        BLastSong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BLastSongActionPerformed(evt);
            }
        });

        TBPlay.setBackground(new java.awt.Color(144, 191, 255));
        TBPlay.setIcon(new javax.swing.ImageIcon("src\\pic\\播放.jpg")); 
        TBPlay.setActionCommand("tbPlay");
        TBPlay.setSelectedIcon(new javax.swing.ImageIcon("src\\pic\\暂停.jpg")); 
        TBPlay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TBPlayActionPerformed(evt);
            }
        });

        BNextSong.setBackground(new java.awt.Color(144, 191, 255));
        BNextSong.setIcon(new javax.swing.ImageIcon("src\\pic\\后一首.jpg")); 
        BNextSong.setActionCommand("bNextSong");
        BNextSong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BNextSongActionPerformed(evt);
            }
        });

        BStop.setBackground(new java.awt.Color(144, 191, 255));
        BStop.setIcon(new javax.swing.ImageIcon("src\\pic\\停止.jpg")); // NOI18N
        BStop.setActionCommand("bStop");
        BStop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BStopActionPerformed(evt);
            }
        });

        SProcess.setBackground(new java.awt.Color(144, 191, 255));
        SProcess.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                SProcessStateChanged(evt);
            }
        });

        LProcess.setBackground(new java.awt.Color(144, 191, 255));
        LProcess.setText("显示进度");

        BOpenFile.setBackground(new java.awt.Color(144, 191, 255));
        BOpenFile.setText("打开文件");
        BOpenFile.setActionCommand("bOpenFile");
        BOpenFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BOpenFileActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout PControlLayout = new javax.swing.GroupLayout(PControl);
        PControl.setLayout(PControlLayout);
        PControlLayout.setHorizontalGroup(
            PControlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PControlLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(BLastSong, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.)
                .addComponent(TBPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.)
                .addComponent(BNextSong, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(BStop, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(PControlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(LProcess)
                    .addComponent(SProcess, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.)
                .addComponent(BOpenFile)
                .addContainerGap(110, Short.MAX_VALUE))
        );
        PControlLayout.setVerticalGroup(
            PControlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PControlLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BLastSong)
                .addContainerGap(14, Short.MAX_VALUE))
            .addComponent(TBPlay)
            .addGroup(PControlLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PControlLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BStop, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BNextSong, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap(14, Short.MAX_VALUE))
            .addGroup(PControlLayout.createSequentialGroup()
                .addComponent(SProcess, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.)
                .addComponent(LProcess)
                .addGap(1, 1, 1))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PControlLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BOpenFile, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        LProcess.getAccessibleContext().setAccessibleName("lProcess");

        PPlayList.setMaximumSize(new java.awt.Dimension(300, 800));
        PPlayList.setPreferredSize(new java.awt.Dimension(270, 449));

        TPPlayList.setBackground(new java.awt.Color(255, 255, 255));
        TPPlayList.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(180, 222, 255), null));
        TPPlayList.setForeground(new java.awt.Color(160, 204, 255));
        TPPlayList.setFont(new java.awt.Font("宋体", 0, 14));
        TPPlayList.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                TPPlayListStateChanged(evt);
            }
        });

        PDefaultList.setBackground(new java.awt.Color(255, 255, 255));

        SPDefaultList.setBackground(new java.awt.Color(255, 255, 255));
        SPDefaultList.setViewportView(LDefaultList);

        javax.swing.GroupLayout PDefaultListLayout = new javax.swing.GroupLayout(PDefaultList);
        PDefaultList.setLayout(PDefaultListLayout);
        PDefaultListLayout.setHorizontalGroup(
            PDefaultListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SPDefaultList, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
        );
        PDefaultListLayout.setVerticalGroup(
            PDefaultListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SPDefaultList, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
        );

        TPPlayList.addTab("默认播放列表", PDefaultList);

        PMyList.setBackground(new java.awt.Color(255, 255, 255));

        SPMyList.setViewportView(LMyList);

        javax.swing.GroupLayout PMyListLayout = new javax.swing.GroupLayout(PMyList);
        PMyList.setLayout(PMyListLayout);
        PMyListLayout.setHorizontalGroup(
            PMyListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SPMyList, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
        );
        PMyListLayout.setVerticalGroup(
            PMyListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SPMyList, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
        );

        TPPlayList.addTab("我的播放列表", PMyList);

        javax.swing.GroupLayout PPlayListLayout = new javax.swing.GroupLayout(PPlayList);
        PPlayList.setLayout(PPlayListLayout);
        PPlayListLayout.setHorizontalGroup(
            PPlayListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TPPlayList, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        PPlayListLayout.setVerticalGroup(
            PPlayListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TPPlayList, javax.swing.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PControl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(410, Short.MAX_VALUE)
                .addComponent(PPlayList, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(PSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(213, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(PPlayList, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.)
                .addComponent(PControl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(PSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(52, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged
        // TODO add your handling code here:
        //在此添加窗口改变时的代码
    }//GEN-LAST:event_formWindowStateChanged

    private void TPSelectionStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TPSelectionStateChanged
        // TODO add your handling code here:
        int index=TPSelection.getSelectedIndex();
        switch(index)
        {
            case 0:     
                PSelPlay.setBackgroundImage();
                break;
            case 1:              
                JTextField textfile=new JTextField(20);               
                break;
            case 2:
                break;
            default:
                break;
        }
    }//GEN-LAST:event_TPSelectionStateChanged

    private void TPPlayListStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TPPlayListStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_TPPlayListStateChanged

    private void BLastSongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BLastSongActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_BLastSongActionPerformed

    private void TBPlayActionPerformed(java.awt.event.ActionEvent evt) {
        playing=!playing;
        pause=!pause;      
        if(playing)
            player.resume();
        if(pause)
            player.pause();
    }

    private void BNextSongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BNextSongActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_BNextSongActionPerformed

    private void BStopActionPerformed(java.awt.event.ActionEvent evt) {
        stop=true;
        player.stop();
    }
    
    private void SProcessStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_SProcessStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_SProcessStateChanged

    private void BOpenFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BOpenFileActionPerformed
        // TODO add your handling code here:
        JFileChooser fileChooser=new JFileChooser();
        //设置文件打开模式为只读
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        int result = fileChooser.showOpenDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) { //得到用户行为   
            File mediaFile = fileChooser.getSelectedFile(); //得到选择的文件   
            mediaLocation=mediaFile.getAbsolutePath();
        }   
        if(mediaLocation!=null){
            player.open(new File(mediaLocation));
            player.play();
        }
        else
            JOptionPane.showMessageDialog(this,"打开文件时发生错误"); 
    }//GEN-LAST:event_BOpenFileActionPerformed
搜索更多相关主题的帖子: player 
2011-11-01 07:26
specilize
Rank: 4
等 级:业余侠客
帖 子:126
专家分:247
注 册:2011-2-20
收藏
得分:0 
顺便问一下,以前我发帖子都没人回得,是不是我发出论坛了
2011-11-01 07:28
快速回复:被控件折腾的够呛啊,大家帮我看一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.063223 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved