Category Archives: Swing


How to find your Google Plus ID

By | September 27, 2012

This is so simple 1. Go to your Google + account ( 2. Click on the Profile icon on the Left. 3. If you look at the URL in the address bar, it should look something like this: 4. The long numerical string in the URL is your Google+ ID. Here is CoderzHeaven’s from… Read More »

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…

Position swing window in center of the screen

By | March 7, 2011

In some case we need to position the window in the center of the screen . The same effect can be achieved by hard coding the center points .But in that case the window position change when the screen resolution changes This code will position the window in center irrespective of different screen resolutions public… Read More »

Creating a JMenubar in java swing

By | March 4, 2011

Creating a JMenubar is simple. JMenuBar menubar = new JMenuBar(); JMenu menu1 = new JMenu(“File”); JMenu menu2= new JMenu(“Help”); file = new JMenuItem(“Exit to menu”); edit = new JMenuItem(“Exit”); JMenuItem about = new JMenuItem(“About us”); f.setJMenuBar(menubar); menu1.add(file); menu1.add(edit); menu2.add(about); menubar.add(menu1); menubar.add(menu2); file.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { //Action…… } }); edit.addActionListener(new ActionListener() {… Read More »