Coders Packet

Creating Virtual Piano in Java

By Rayven Santosh Thakur

In this article, we will see how to make a virtual piano with some beautiful music notes. This Virtual piano is made up of with the core concept of Java, so it is very easy and fun to make.

1. Create New Project

2. Select New JFrame

3. Design The keys (As per your choice and Requirement) with the help of Jbuttons.

4. Download or Create your music notes.

5. Import this Audio and other packages

import*; import*; import javax.swing.JOptionPane;


6. Add this Code to Make Output Screen Visible 

 initComponents(); setSize(700,600); setLocationRelativeTo(null); 

(width , height size may change as per your requirement size)


7.Add this code to put music on single keys 

 InputStream iAudio;   try { iAudio = new FileInputStream(new File ("C:\\javapianonotes\\Music_Note\\F.wav")); AudioStream iMusic = new AudioStream(iAudio); AudioPlayer.player.start(iMusic); } catch (IOException ex) { JOptionPane.showMessageDialog(null, ex); } 

Download Complete Code


No comments yet

Download Packet

Reviews Report

Submitted by Rayven Santosh Thakur (rayventhakur52)

Download packets of source code on Coders Packet