Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JCheckBox special = new JCheckBox ("\nSpecial - $17.95" + "\nMeatball, Sausage, Mushroom, Onion, Pepperoni & Pepper");
在这行代码中,如何使复选框使“...”变成两行?
最简单的方法是使用HTML 3.2对其进行格式化:
JCheckBox checkBox = new JCheckBox("<HTML>" + "Special - $17.95" + "<BR>" + "Meatball, Sausage, Mushroom, Onion, Pepperoni & Pepper" + "</HTML>");
另一种方法是设置自定义ButtonUI,尽管这是一种相当复杂的方法。