SuperVCD管理系统 完整代码,带各种注释,可以拿这个项目入门。
c.insets = new Insets(10, 0, 2, 10); JLabel artistLabel = new JLabel("歌手: " + myRecording.getArtist()); artistLabel.setForeground(Color.black); infoPanel.add(artistLabel, c); c.gridy = GridBagConstraints.RELATIVE; c.insets = new Insets(2, 0, 10, 10); JLabel titleLabel = new JLabel("歌名: " + myRecording.getTitle()); titleLabel.setForeground(Color.black); infoPanel.add(titleLabel, c); JLabel categoryLabel = new JLabel("类别: " + myRecording.getCategory()); c.insets = new Insets(2, 0, 2, 0); categoryLabel.setForeground(Color.black); infoPanel.add(categoryLabel, c); Duration theDuration = myRecording.getDuration(); int runningTime = theDuration.getTotalSeconds() / 60; JLabel durationLabel = new JLabel("长度: " + runningTime + " 分."); durationLabel.setForeground(Color.black); infoPanel.add(durationLabel, c); JLabel priceLabel = new JLabel("价格: " + myRecording.getPrice() ); c.insets = new Insets(10, 0, 2, 0); priceLabel.setForeground(Color.black); infoPanel.add(priceLabel, c); c.gridx = 3; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 5; c.fill = GridBagConstraints.NONE; c.weightx = 1.0; c.weighty = 1.0; c.insets = new Insets(5, 5, 20, 0); String imageName = myRecording.getImageName(); ImageIcon recordingIcon = null; JLabel recordingLabel = null; // 读取图片 try { if (imageName.trim().length() == 0) { recordingLabel = new JLabel(" 图片不存在 ");