Changing JFrame Color

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Primo
    New Member
    • Jul 2007
    • 8

    #1

    Changing JFrame Color

    Hello ........

    I Have an Application(JFr ame) With several panels in its content pane at different times. I changes the background colors of all the panels say (blue).

    I have also used frame.setbackgr ound(Color.blue );

    But that doesnt change that color.
    What can I do cause its kind of visible and doesnt look so nice when everything else is in another color.
  • blazedaces
    Contributor
    • May 2007
    • 284

    #2
    Originally posted by Primo
    Hello ........

    I Have an Application(JFr ame) With several panels in its content pane at different times. I changes the background colors of all the panels say (blue).

    I have also used frame.setbackgr ound(Color.blue );

    But that doesnt change that color.
    What can I do cause its kind of visible and doesnt look so nice when everything else is in another color.
    How much code is this? I don't like asking, but perhaps you should post the code? It might help to answer questions, but here are some:

    Are you absolutely sure you're setting all the backgrounds of all the jpanels AND components (tables, buttons, textfields, etc.)?

    What is the background color? Do you see blue anywhere at all?

    Good luck,

    -blazed

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by Primo
      Hello ........

      I Have an Application(JFr ame) With several panels in its content pane at different times. I changes the background colors of all the panels say (blue).

      I have also used frame.setbackgr ound(Color.blue );

      But that doesnt change that color.
      What can I do cause its kind of visible and doesnt look so nice when everything else is in another color.
      After updating the interface, you need to repaint the whole thing so that the changes are visible.

      Comment

      • Primo
        New Member
        • Jul 2007
        • 8

        #4
        Originally posted by r035198x
        After updating the interface, you need to repaint the whole thing so that the changes are visible.
        how do i repaint everything?

        @ blazedaces

        this is the whole code:

        public void showTaems(Taems t) {
        JFrame frame;

        taemsFrame = new JFrame("Taems") ;

        taemsFrame.setS ize(INITIAL_WID TH, INITIAL_HEIGHT) ;
        Dimension screenSize = Toolkit.getDefa ultToolkit().ge tScreenSize();
        taemsFrame.setS ize(screenSize. width, (int)(screenSiz e.height * .95));
        taemsFrame.setL ocation(screenS ize.width/2 - INITIAL_WIDTH/2,
        screenSize.heig ht/2 - INITIAL_HEIGHT/2);
        taemsFrame.setL ocation(0, 0);
        taemsFrame.setD efaultCloseOper ation(JFrame.DI SPOSE_ON_CLOSE) ;
        taemsFrame.getC ontentPane().ad d(t, BorderLayout.CE NTER);

        //AR taemsFrame.setB ackground(Color .white);
        taemsFrame.setB ackground(Color .green);
        taemsFrame.setV isible(true);
        taemsFrame.setF ont(new Font("Palatino" , Font.BOLD, 16));
        //Jayasri 06/15
        taemsFrame.setR esizable(true);

        Container c = taemsFrame.getC ontentPane();
        c.setBackground (Color.white);
        c.setFont(new Font("Palatino" , Font.BOLD, 16));
        t.setBackground (Color.black);
        t.setForeground (Color.red);
        taemsFrame.show ();
        }

        Comment

        • Primo
          New Member
          • Jul 2007
          • 8

          #5
          i still need help people

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by Primo
            i still need help people
            getContentPane( ).validate()
            Look it up in the docs.

            Sometimes you may need to call the repaint method as well.

            Comment

            Working...