Site Announcements

Register and Login to Sanjaal Board to get access to exclusive contents including guitar tabs, high quality arts, glamor and photography pictures. New Users will be manually validated against spam database and potential advertisers. So this might cause your account activation to delay from a couple of days to few weeks. If you have Nepali/Indian/Pakistani/Bangladeshi names in your username, the user activation will be quicker. SPAMMERS WILL BE DELETED WITH NO MERCY

Java Tag Generator [GUI Version] For Music Blogs, Youtube

Java Tag Generator [GUI Version] For Music Blogs, Youtube

Postby admin » Tue Aug 04, 2009 12:51 pm


I wrote a simple tag generator for music blogs sometimes back. I now have come up with a GUI. As mentioned before, this application will generate tags to be used for some music blogs or youtube etc. You have the flexibility to choose whether you want the tags to be generated for the lyrics of the song or for the music video.

One feature I have added in this feature is that when you generate tags using this aplication, the tags are automatically copied to system clipboard, so you can just paste them. I am avoiding a step you have to go through in copying the generated tags.

Code: Select all
package com.kushal.utils;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;

/**
* @author KushalP For those who maintain music blog, this simple program might
*         be useful for generating music tags.
*
* I developed this for my personal use for my following blog:
* http://www.sanjaal.com/nepalisongs
*/

public class SimpleTagGeneratorGUI extends JFrame {
   private static final long serialVersionUID = 2444120930689467400L;

   JTextField albumField, artistField, songField;

   JTextPane tagsPane;

   JCheckBox lyricsMode;

   public SimpleTagGeneratorGUI() {
      super("Simple Tag Generator - Generate Tags For Your Music Blog");
      setLayout(new FlowLayout());
      Box verticalBox = Box.createVerticalBox();

      Box lyricsHB = Box.createHorizontalBox();
      JPanel lyricsPanel = new JPanel();
      JLabel lyricsLabel = new JLabel("Lyrics Mode");
      lyricsMode = new JCheckBox();
      lyricsPanel.add(lyricsLabel);
      lyricsPanel.add(lyricsMode);
      lyricsHB.add(lyricsPanel);

      Box artistHB = Box.createHorizontalBox();
      JPanel artistPanel = new JPanel();
      JLabel artistLabel = new JLabel("Artist");
      artistField = new JTextField(20);
      artistPanel.add(artistLabel);
      artistPanel.add(artistField);
      artistHB.add(artistPanel);

      Box songHB = Box.createHorizontalBox();
      JPanel songPanel = new JPanel();
      JLabel songLabel = new JLabel("Song");
      songField = new JTextField(20);
      songPanel.add(songLabel);
      songPanel.add(songField);
      songHB.add(songPanel);

      Box albumHB = Box.createHorizontalBox();
      JPanel albumPanel = new JPanel();
      JLabel albumLabel = new JLabel("Album");
      albumField = new JTextField(20);
      albumPanel.add(albumLabel);
      albumPanel.add(albumField);
      albumHB.add(albumPanel);

      Box generateHB = Box.createHorizontalBox();
      JPanel generatePanel = new JPanel();
      JButton generateButton = new JButton(
            "Generate Tags & Copy To Clipboard");
      generatePanel.add(generateButton);
      generateHB.add(generatePanel);
      generateButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            if ("Generate Tags & Copy To Clipboard".equalsIgnoreCase(e
                  .getActionCommand())) {
               String tags = SimpleTagGeneratorGUI.this.generateTag(
                     albumField.getText(), artistField.getText(),
                     songField.getText(), lyricsMode.isSelected());
               tagsPane.setText(tags);
               /*
                * Set the data to system clipboard So that you don't need
                * to copy it.
                */
               setClipboardData(tags);

            }

         }

      });

      Box tagsHB = Box.createHorizontalBox();
      tagsPane = new JTextPane();
      tagsPane.setEditable(true);
      // tagsPane.setLineWrap(true);
      // tagsHB.add(tagsArea);
      JScrollPane scrollpane = new JScrollPane(tagsPane,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      // scrollpane.add(tagsArea);
      scrollpane.setPreferredSize(new Dimension(300, 200));
      tagsHB.add(scrollpane);

      verticalBox.add(lyricsHB);
      verticalBox.add(artistHB);
      verticalBox.add(songHB);
      verticalBox.add(albumHB);
      verticalBox.add(generateHB);
      verticalBox.add(tagsHB);

      getContentPane().add(verticalBox);
      setVisible(true);
      setLocation(200, 200);
      setSize(500, 450);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   }

   public static void main(String args[]) {
      new SimpleTagGeneratorGUI().show();
   }

   /**
    * Param 1 : Album Name Param 2 : Artist Name Param 3 : Song Name Param 4 :
    * Lyrics Mode
    */
   public static String generateTag(String album, String artist, String song,
         boolean lyricsMode) {
      String artistTags = "";
      String albumTags = "";
      String songTags = "";

      if (artist != null && artist.length() > 0) {
         artistTags += artist + " Guitar Tabs, " + artist
               + " Latest Songs, "
               + (lyricsMode ? "" : artist + " MP3 Downloads,") + artist
               + " Latest Albums, "
               + (lyricsMode ? "" : artist + " Songs Download, ") + artist
               + " Lyrics Download, "
               + (lyricsMode ? "" : artist + " MP3 Songs,")
               + (lyricsMode ? artist + " Lyrics Collection," : "");
      }

      if (album != null && album.length() > 0) {
         albumTags += artist + " " + album + " " + "Songs Download, "
               + artist + " " + album + " " + "MP3 Download," + artist
               + " " + album + " " + "Lyrics Download, " + artist + " "
               + album + " " + "Guitar Tabs," + artist + " " + album + " "
               + "Guitar Chords,";

      }

      if (song != null && song.length() > 0) {
         songTags += artist
               + " "
               + song
               + " "
               + "Guitar Tabs, "
               + (lyricsMode ? "" : artist + " " + song + " "
                     + "MP3 Downloads,")
               + (lyricsMode ? "" : artist + " " + song + " "
                     + "Songs Download,")
               + artist
               + " "
               + song
               + " "
               + "Guitar Chords,"
               + (lyricsMode ? "" : artist + " " + song + " "
                     + "MP3 Song,")
               + artist
               + " "
               + song
               + " "
               + "Lyrics Download,"
               + (lyricsMode ? "" : artist + " " + song + " "
                     + "Music Video");

      }

      String tags = artistTags + "," + albumTags + "," + songTags;
      System.out.println(tags);

      return tags;

   }

   /*
    * This method sets the input parameter string
    * into the sytem clipboard, so you can paste it.
    */
   public static void setClipboardData(String string) {
      StringSelection stringSelection = new StringSelection(string);
      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
            stringSelection, null);
   }

}



The snapshots of this application are available below:

Image

Image


Sanjaal.com is owned and maintained by Sanjaal Corps, Nepal. The company offers Webhosting and Domain Registration Services, IT Solutions and Business Analysis. Sanjaal.com website features H1B Visa Information, Entertainment Portal, Link Directory Service, Free Articles, Free Open Source Tutorials on Java and J2EE Platform, Digital Photography, High Resolution Picture Gallery and Free Reliable Image Hosting Services. Future plan includes Open Source Software Development Portal, Technical Solutions and Customizable Movie and Music Arena. We would be introducing data backup, data recovery, data hosting and voip solutions. Stay free from phishing - our website does not ask for your credit card and banking information. Happy Surfing!
admin
The Bell Ringer
 
Posts: 831
Joined: Sun Feb 22, 2009 9:08 pm


Similar topics


Return to Java Programming Discussions

Who is online

Users browsing this forum: No registered users and 1 guest

cron