0
      textPane.setText(text);
      textPane.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
       
      Color darkyellow = new Color(238,185,57);
       
      titleBar = new JLabel();           
      titleBar.setFont(new Font("sansserif", Font.BOLD, 14));
      titleBar.setBackground(darkyellow);
      titleBar.setOpaque(true);
      titleBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5));
      titleBar.setSize(titleBar.getPreferredSize());
      titleBar.setVisible(false);                  
       
      buttons = new Box(BoxLayout.X_AXIS); 
      defaultButton = new Button("Close");
      buttons.add(defaultButton);
      buttons.setBorder(BorderFactory.createEmptyBorder(15,5,5,5));
       
      content.add(titleBar);
      content.add(textPane);
      content.add(buttons);
 
      // this allows the title bar to take the whole width of the dialog box 
      titleBar.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
      buttons.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
      textPane.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE));
       
      // these allow all the parts to left aligned 
      titleBar.setAlignmentX(Component.LEFT_ALIGNMENT);
      textPane.setAlignmentX(Component.LEFT_ALIGNMENT);
      buttons.setAlignmentX(Component.LEFT_ALIGNMENT);
             
      // these are meant to prevent the message box from stealing 
      // focus when it's clicked, but they don't seem to work 
Contextual code suggestions in your IDE  Get Codota for Java