AWT is a bit different from Swing.
There’s no constructor button(image)
, hence your “not working”.
Take a look at Learn how to extend the AWT with your own image buttons to see how to make that image on a AWT button.
More Related Contents:
- Java and GUI – Where do ActionListeners belong according to MVC pattern?
- Java GUI frameworks. What to choose? Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot? [closed]
- “Always on Top” Windows with Java
- Is it safe to construct Swing/AWT widgets NOT on the Event Dispatch Thread?
- How to define multiple JButton actions from a different class
- paintComponent() vs paint() and JPanel vs Canvas in a paintbrush-type GUI
- A rotated square panel in Java GUI
- Why are my items not showing up in JFrame?
- Java rotating non-square JPanel component
- How can I make this JButton visible? When I have progressive scan background JWindow()?
- Loading resources like images while running project distributed as JAR archive
- Creating a custom button in Java with JButton
- Multiple row selection in JTable
- Re-paint on translucent frame/panel/component.
- Simple popup java form with at least two fields
- How to wire one pane to another
- How can I scroll more than one object at the same time?
- Sending messages between two JPanel objects
- Getting RGB value from under mouse cursor
- how to drag and drop files from a directory in java
- How to implement draggable tab using Java Swing?
- Problems with Java’s Paint method, ridiculous refresh velocity
- make a JLabel wrap it’s text by setting a max width
- Drawing a Component to BufferedImage causes display corruption
- Porting a Java app that uses AWT and Swing for drawing movies to the server-side
- How MVC work with java swing GUI
- How do I draw on a JPanel from multiple outside classes?
- How to focus a JFrame?
- CardLayout showing two panels, flashing
- Can I add a component to a specific grid cell when a GridLayout is used?