Results 1 to 9 of 9

Thread: Color of layout

  1. #1
    Sean2012 is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Color of layout

    Hello I have a flowlayout set up like this

    Java Code:
    		Layout = new FlowLayout();
    		Button1 = new JButton("Website");
    		Button2 = new JButton("Vote");
    		Button3 = new JButton("Donate");
    		Button4 = new JButton("Item List");
    		Button5 = new JButton("Screenshot");
    
    		menuBar.setLayout(Layout);
    		menuBar.add(Button1);
    		menuBar.add(Button2);
    		menuBar.add(Button3);
    		menuBar.add(Button4);
    		menuBar.add(Button5);
    		Button1.addActionListener(this);
    		Button2.addActionListener(this);
    		Button3.addActionListener(this);
    		Button4.addActionListener(this);
    		Button5.addActionListener(this);
    
    		Button1.setBackground(Color.black);
    		Button1.setForeground(Color.white);
    		Button1.setText("Website");
    		Button2.setBackground(Color.black);
    		Button2.setForeground(Color.white);
    		Button2.setText("Vote");
    How do i change the color of the actual layout?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    Sean2012 is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Re: Color of layout

    Sorry, I figured it out I meant the background color so I added

    Java Code:
    		menuBar.setBackground(Color.lightGray);
    But now that I changed the color there is a White line bordering the Layout (menuBar) how could I change the color of that?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Color of layout

    It's hard to tell without a small compilable and runnable, program just what your problem is. Perhaps you're seeing the component's border, but I'm not sure.

  5. #5
    Sean2012 is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Re: Color of layout

    Okay I uploaded a picture. Also how would I change the color of the button border?


  6. #6
    Amali is offline Member
    Join Date
    Apr 2012
    Location
    Gampaha, Sri Lanka
    Posts
    2
    Rep Power
    0

    Default Re: Color of layout

    set Border Property
    Java Code:
    Border border = new LineBorder(Color.GRAY, 15);
       yourcomponent.setBorder(border);
    Last edited by Amali; 04-20-2012 at 09:57 AM.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Color of layout

    Quote Originally Posted by Sean2012 View Post
    Okay I uploaded a picture.
    You were asked for a SSCCE, not a picture. Without seeing the code, the picture is meaningless and any advice given is sheer guesswork.

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

  8. #8
    Sean2012 is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Re: Color of layout

    Quote Originally Posted by DarrylBurke View Post
    You were asked for a SSCCE, not a picture. Without seeing the code, the picture is meaningless and any advice given is sheer guesswork.

    db
    Sorry

    Java Code:
    	void openFrame() {
    		try {
    		    UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceRavenLookAndFeel");
    	   		JFrame.setDefaultLookAndFeelDecorated(true);
    	   		JDialog.setDefaultLookAndFeelDecorated(true);
    		} catch (Throwable e) {
    			e.getStackTrace();
    		}
    		appletFrame = new JFrame(Settings.serverName);
    		Loader.webclient = false;
    		appletFrame.setLayout(new BorderLayout());
    		appletFrame.setDefaultCloseOperation(3);
    		appletPanel.setLayout(new BorderLayout());
    		//appletFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/resources/icon.png")));
    		appletPanel.add(this);
    		appletPanel.setPreferredSize(new Dimension(765, 545));
    		appletFrame.getContentPane().add(appletPanel, "Center");
    		appletFrame.pack();
    		appletFrame.setLocationRelativeTo(null);
    		appletFrame.setVisible(true);
    
    		JMenuBar menuBar = new JMenuBar();
    		appletFrame.setJMenuBar(menuBar);
    
    		Layout = new FlowLayout();
    		Button1 = new JButton("Website");
    		Button2 = new JButton("Vote");
    		Button3 = new JButton("Donate");
    		Button4 = new JButton("Item List");
    		Button5 = new JButton("Screenshot");
    
    		menuBar.setLayout(Layout);
    		menuBar.add(Button1);
    		menuBar.add(Button2);
    		menuBar.add(Button3);
    		menuBar.add(Button4);
    		menuBar.add(Button5);
    		Button1.addActionListener(this);
    		Button2.addActionListener(this);
    		Button3.addActionListener(this);
    		Button4.addActionListener(this);
    		Button5.addActionListener(this);
    
    		Border border = new LineBorder(Color.black, 15);
    			yourcomponent.setBorder(border);
    		menuBar.setBackground(Color.black);
    		Button1.setBackground(Color.black); //(new Color(128, 128, 128));
    		Button1.setForeground(Color.white);
    		Button1.setText("Website");
    		Button2.setBackground(Color.black);
    		Button2.setForeground(Color.white);
    		Button2.setText("Vote");
    		Button3.setBackground(Color.black);
    		Button3.setForeground(Color.white);
    		Button3.setText("Donate");
    		Button4.setBackground(Color.black);
    		Button4.setForeground(Color.white);
    		Button4.setText("Item List");
    		Button5.setBackground(Color.black);
    		Button5.setForeground(Color.white);
    		Button5.setText("Screenshot");
    	}

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Color of layout

    Did you so much as glance at the SSCCE page?

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

Similar Threads

  1. Grid Layout change layout alignment of control s
    By rellicott in forum SWT / JFace
    Replies: 1
    Last Post: 02-13-2012, 06:11 PM
  2. don't know the right layout
    By temyong in forum New To Java
    Replies: 4
    Last Post: 03-10-2011, 02:13 PM
  3. Please help me in this layout :(
    By orionorion in forum Java Applets
    Replies: 1
    Last Post: 02-09-2011, 03:47 PM
  4. [COLOR="Navy"]execute .bat file in mysql [/COLOR]
    By msankar.ravi in forum Networking
    Replies: 0
    Last Post: 02-24-2010, 05:27 AM
  5. Edit layout Layout please help me
    By manhtungtnk28@gmail.com in forum New To Java
    Replies: 4
    Last Post: 11-23-2009, 09:41 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
  •