Here is a function:
/**
* Creates an instance of a JLabel with the given arguments
* @param text The text to be displayed on the Label
* @param font The font of the label
* @param bold set to true if you want the label's text to be bold
* @param fontSize The size of the font to be rendered
* @param alignment An alignment (E.g. CENTER_ALIGNMENT)
* @param verticleAlignment an optional argument to allow one to choose the Y alignment
* **/
public JLabel createLabel(String text, String font, boolean bold, int fontSize, float alignment, float...verticleAlignment){
JLabel label = new JLabel(text);
label.setFont(new Font(font, bold ? Font.BOLD : Font.PLAIN, fontSize));
label.setAlignmentX(alignment);
if(verticleAlignment.length > 0){
label.setAlignmentY(verticleAlignment[0]);
}
return label;
}
For some reason, no matter what I enter in the varArg verticleAlignment, it doesn't actually apply?
add(createLabel("ChatBytes™ - Do not steal.", "Arial", false, 12, CENTER_ALIGNMENT, BOTTOM_ALIGNMENT));
Can anyone see a reason why it would ignore the setYAlignment part of my function?
use
to create a vertical space that pushes the component to the bottom of the JFrame