Tag Archives: JPanel

JComboBox in Java swing

By | April 20, 2012

This shows you how to add JcomboBox to JPanel import java.awt.*; import java.awt.event.*; import java.text.DecimalFormat; import javax.imageio.ImageIO; import javax.swing.*; public class Example implements WindowListener { JFrame content_frame = new JFrame(); JPanel panel = new JPanel(); JComboBox Combonote; public Example() { content_frame.setTitle(“Contents”); content_frame.addWindowListener(this); content_frame.setSize(300, 300); content_frame.setVisible(true); content_frame.setLocationRelativeTo(null); content_frame.setResizable(false); ///cannot maximize content_frame.setVisible(true); showComboBox(); } private void showComboBox()… Read More »

Swing JPanel with background image

By | March 7, 2011

This code add an image to Jpanel. JPanel panel1 = new JPanel(); JFrame recursion_frame = new JFrame(); BackgroundPanel stack_image1 = new BackgroundPanel(“Recursion.jpg”); panel1.setLayout(null); panel1.setLayout(new BorderLayout()); panel1.setBackground(Color.lightGray); panel1.setVisible(true); recursion_frame.setContentPane(panel1); ///adding to panel… recursion_frame.getContentPane().add(stack_image1); //adding image to panel…