Use Swing rather than AWT for this. Either is capable of doing it, but Swing is more modern and supports components (JTree
, JTable
..) and functionality (double-buffering built-in, key bindings, PLAFs, support for rich text) that is missing from the AWT APIs.
Another advantage of using Swing is that it seems you are at a stage where you need to ask further questions. Most people who program GUIs using Java SE have never used AWT components, and the rest of us have mostly forgotten how! (There are also many more people who can help with Swing than JavaFX, at this point.)
In AWT you might use a Canvas
for drawing the waveform, but in Swing you would use either of the following:
- A
JPanel
(or sometimes a JComponent
) where to paint we override paintComponent(Graphics)
- A
BufferedImage
display in a JLabel
.
You can see examples of the first technique at DrewTubeish - here is Leftover Wine.