Ryan Kear
Ryan Kear

Reputation:

Checkboxes display?

JCheckBox special = new JCheckBox ("\nSpecial - $17.95" + "\nMeatball, Sausage, Mushroom, Onion, Pepperoni & Pepper");

In this line of code, how do you make the checkbox make the "..." into two lines?

Upvotes: 2

Views: 574

Answers (1)

McDowell
McDowell

Reputation: 108899

The easiest way is to format it with HTML 3.2:

    JCheckBox checkBox = new JCheckBox("<HTML>" + "Special - $17.95"
            + "<BR>"
            + "Meatball, Sausage, Mushroom, Onion, Pepperoni & Pepper"
            + "</HTML>");

The alternative is to set a custom ButtonUI, though that is a considerably more involved approach.

Upvotes: 6

Related Questions