private void layoutBubble(){
  bubble.removeAll();
  constraints=new GridBagConstraints();
  Insets insetsLabel=new Insets(10,10,10,10);
  Insets insetsMainText=new Insets(0,10,10,10);
  int numberAdditionalComponents=this.componentsInBubble.length;
switch (realAlignment) {
case TOPLEFT:
    insetsLabel=new Insets(CORNER_RADIUS + 15,10,10,10);
  break;
case TOPRIGHT:
insetsLabel=new Insets(CORNER_RADIUS + 15,10,10,10);
break;
case INNERLEFT:
case LEFTTOP:
insetsLabel=new Insets(10,CORNER_RADIUS + 15,10,10);
insetsMainText=new Insets(0,CORNER_RADIUS + 15,10,10);
break;
case LEFTBOTTOM:
insetsLabel=new Insets(10,CORNER_RADIUS + 15,10,10);
insetsMainText=new Insets(0,CORNER_RADIUS + 15,10,10);
break;
case BOTTOMRIGHT:
insetsLabel=new Insets(10,10,10,10);
insetsMainText=new Insets(0,10,CORNER_RADIUS + 15,10);
break;
case BOTTOMLEFT:
insetsLabel=new Insets(10,10,10,10);
insetsMainText=new Insets(0,10,CORNER_RADIUS + 15,10);
break;
case INNERRIGHT:
case RIGHTTOP:
insetsLabel=new Insets(10,10,10,CORNER_RADIUS + 15);
insetsMainText=new Insets(0,10,10,CORNER_RADIUS + 15);
break;
case RIGHTBOTTOM:
insetsLabel=new Insets(10,10,10,CORNER_RADIUS + 15);
insetsMainText=new Insets(0,10,10,CORNER_RADIUS + 15);
break;
default :
}
constraints.gridx=0;
constraints.gridy=0;
constraints.insets=insetsLabel;
constraints.fill=GridBagConstraints.BOTH;
constraints.anchor=GridBagConstraints.WEST;
constraints.gridwidth=numberAdditionalComponents > 0 ? numberAdditionalComponents : 1;
constraints.weightx=1;
constraints.weighty=0;
bubble.add(headline,constraints);
constraints.gridx+=numberAdditionalComponents > 0 ? numberAdditionalComponents : 1;
constraints.weightx=0;
constraints.fill=GridBagConstraints.NONE;
constraints.anchor=GridBagConstraints.EAST;
constraints.insets=insetsLabel;
constraints.gridwidth=1;
if (showCloseButton) {
bubble.add(close,constraints);
}
 else {
bubble.add(new JLabel(),constraints);
}
constraints.gridx=0;
constraints.gridy+=1;
constraints.insets=insetsMainText;
constraints.gridwidth=numberAdditionalComponents > 0 ? numberAdditionalComponents + 1 : 2;
constraints.weightx=1;
constraints.weighty=1;
constraints.fill=GridBagConstraints.BOTH;
constraints.anchor=GridBagConstraints.WEST;
bubble.add(mainText,constraints);
int insetsLeft=10;
int insetsBottom=10;
if (realAlignment == Alignment.LEFTBOTTOM || realAlignment == Alignment.LEFTTOP || realAlignment == Alignment.INNERLEFT) {
insetsLeft+=CORNER_RADIUS;
}
if (realAlignment == Alignment.BOTTOMLEFT || realAlignment == Alignment.BOTTOMRIGHT) {
insetsBottom+=CORNER_RADIUS;
}
constraints.gridx=0;
constraints.gridy+=1;
constraints.insets=new Insets(10,insetsLeft,insetsBottom,0);
constraints.fill=GridBagConstraints.NONE;
constraints.gridwidth=1;
constraints.weightx=0;
constraints.weighty=0;
for (int i=0; i < this.componentsInBubble.length; i++) {
bubble.add(this.componentsInBubble[i],constraints);
constraints.gridx+=1;
}
bubble.revalidate();
bubble.repaint();
}

private void layoutBubble ( ) { bubble . removeAll ( ) ; constraints = new GridBagConstraints ( ) ; Insets insetsLabel = new Insets ( 10 , 10 , 10 , 10 ) ; Insets insetsMainText = new Insets ( 0 , 10 , 10 , 10 ) ; int numberAdditionalComponents = this . componentsInBubble . length ; switch ( realAlignment ) { case TOPLEFT : insetsLabel = new Insets ( CORNER_RADIUS + 15 , 10 , 10 , 10 ) ; break ; case TOPRIGHT : insetsLabel = new Insets ( CORNER_RADIUS + 15 , 10 , 10 , 10 ) ; break ; case INNERLEFT : case LEFTTOP : insetsLabel = new Insets ( 10 , CORNER_RADIUS + 15 , 10 , 10 ) ; insetsMainText = new Insets ( 0 , CORNER_RADIUS + 15 , 10 , 10 ) ; break ; case LEFTBOTTOM : insetsLabel = new Insets ( 10 , CORNER_RADIUS + 15 , 10 , 10 ) ; insetsMainText = new Insets ( 0 , CORNER_RADIUS + 15 , 10 , 10 ) ; break ; case BOTTOMRIGHT : insetsLabel = new Insets ( 10 , 10 , 10 , 10 ) ; insetsMainText = new Insets ( 0 , 10 , CORNER_RADIUS + 15 , 10 ) ; break ; case BOTTOMLEFT : insetsLabel = new Insets ( 10 , 10 , 10 , 10 ) ; insetsMainText = new Insets ( 0 , 10 , CORNER_RADIUS + 15 , 10 ) ; break ; case INNERRIGHT : case RIGHTTOP : insetsLabel = new Insets ( 10 , 10 , 10 , CORNER_RADIUS + 15 ) ; insetsMainText = new Insets ( 0 , 10 , 10 , CORNER_RADIUS + 15 ) ; break ; case RIGHTBOTTOM : insetsLabel = new Insets ( 10 , 10 , 10 , CORNER_RADIUS + 15 ) ; insetsMainText = new Insets ( 0 , 10 , 10 , CORNER_RADIUS + 15 ) ; break ; default : } constraints . gridx = 0 ; constraints . gridy = 0 ; constraints . insets = insetsLabel ; constraints . fill = GridBagConstraints . BOTH ; constraints . anchor = GridBagConstraints . WEST ; constraints . gridwidth = numberAdditionalComponents > 0 ? numberAdditionalComponents : 1 ; constraints . weightx = 1 ; constraints . weighty = 0 ; bubble . add ( headline , constraints ) ; constraints . gridx += numberAdditionalComponents > 0 ? numberAdditionalComponents : 1 ; constraints . weightx = 0 ; constraints . fill = GridBagConstraints . NONE ; constraints . anchor = GridBagConstraints . EAST ; constraints . insets = insetsLabel ; constraints . gridwidth = 1 ; if ( showCloseButton ) { bubble . add ( close , constraints ) ; } else { bubble . add ( new JLabel ( ) , constraints ) ; } constraints . gridx = 0 ; constraints . gridy += 1 ; constraints . insets = insetsMainText ; constraints . gridwidth = numberAdditionalComponents > 0 ? numberAdditionalComponents + 1 : 2 ; constraints . weightx = 1 ; constraints . weighty = 1 ; constraints . fill = GridBagConstraints . BOTH ; constraints . anchor = GridBagConstraints . WEST ; bubble . add ( mainText , constraints ) ; int insetsLeft = 10 ; int insetsBottom = 10 ; if ( realAlignment == Alignment . LEFTBOTTOM || realAlignment == Alignment . LEFTTOP || realAlignment == Alignment . INNERLEFT ) { insetsLeft += CORNER_RADIUS ; } if ( realAlignment == Alignment . BOTTOMLEFT || realAlignment == Alignment . BOTTOMRIGHT ) { insetsBottom += CORNER_RADIUS ; } constraints . gridx = 0 ; constraints . gridy += 1 ; constraints . insets = new Insets ( 10 , insetsLeft , insetsBottom , 0 ) ; constraints . fill = GridBagConstraints . NONE ; constraints . gridwidth = 1 ; constraints . weightx = 0 ; constraints . weighty = 0 ; for ( int i = 0 ; i < this . componentsInBubble . length ; i ++ ) { bubble . add ( this . componentsInBubble [ i ] , constraints ) ; constraints . gridx += 1 ; } bubble . revalidate ( ) ; bubble . repaint ( ) ; }
adds the components to the bubble .
