Results 1 to 2 of 2
  1. #1
    badass708 is offline Member
    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0

    Default Setting position of JButton

    Setting position of JButton-untitled.jpg

    How can I put button marked with red square, at the bottom left corner of JFrame?

    Code is
    Java Code:
    import java.awt.*;
    import javax.swing.*;
    
    public class SettingsWindow 
    {
    	
    	JFrame f;
    	JButton b1, b2, b3; 
    	
    	public SettingsWindow() 
    	{
    		f = new JFrame ("Settings") ;
    		f.setSize(400, 400) ;
    		
    		ImageIcon TempuratureIc = new ImageIcon("heat.png");
    		b1 = new JButton(TempuratureIc);
    		b1.setFocusPainted(false);
    		//b1.setBorderPainted(false);
    		b1.setContentAreaFilled(false);
    		
    		ImageIcon TimeIc = new ImageIcon("timetable.png");
    		b2 = new JButton(TimeIc);
    		b2.setFocusPainted(false);
    		//b2.setBorderPainted(false);
    		b2.setContentAreaFilled(false);
    		
    		ImageIcon ProfileIc = new ImageIcon("graph.png");
    		b3 = new JButton(ProfileIc);
    		b3.setFocusPainted(false);
    		//b3.setBorderPainted(false);
    		b3.setContentAreaFilled(false);
    		
    		f.add(b1);
    		f.add(b2);
    		f.add(b3);
    		
    		b1.setToolTipText("Temperature Settings");
    		b2.setToolTipText("Time Settings");
    		b3.setToolTipText("Profile Settings");
    		
    		System.out.println(System.getProperty("user.dir"));
    		
    		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		f.setLayout(new FlowLayout());
    		f.setVisible(true);
    		
    	}
    	
    	public static void main(String[] arg)
    	{
    		SettingsWindow w = new SettingsWindow() ;
    	}
    
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default Re: Setting position of JButton

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Setting JButton's mousedown state
    By 0026sd in forum AWT / Swing
    Replies: 6
    Last Post: 12-14-2011, 08:06 PM
  2. ActionListener for JButton after changing Button to JButton
    By ravi.joshi53 in forum Java Applets
    Replies: 2
    Last Post: 10-07-2011, 07:35 AM
  3. setting JButton setEnabled() outside of main class
    By danborgir in forum New To Java
    Replies: 11
    Last Post: 05-07-2011, 04:03 PM
  4. Replies: 3
    Last Post: 05-25-2009, 03:33 AM
  5. get position in string from caret position
    By helloworld111 in forum AWT / Swing
    Replies: 5
    Last Post: 02-19-2009, 01:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •