76261

Problems to linebreak with an int in JLabel

I'm having problems with a linebreak in a JLabel. I want to have a text(name) at the top and beneith the text I want to have an int(to keep score). I have tried this but the int does not show. It shows without the html code but on the same line.

JLabel p1 = new JLabel(<html>Player 1<br> " " </html> + pointPlayer1);

Suggestions?

Answer1:

new JLabel("<html>Player 1<br>" + pointPlayer1 + "</html>");

The whole string must be inside the html opening and closing tags.

Answer2:

Try something like this :

JLabel p1 = new JLabel("Player 1 \n "+ pointPlayer1);

Recommend

  • Parse and return a list of doubles using ANTLR4
  • New lines in a string with GD library
  • How to transfer HTML text into an attributed string without losing line breaks in Swift 3 [duplicate
  • HTML Tag in Java Swing Components
  • create images clickable on jpanel
  • How to create vertical TitledBorder in JPanel (javax swing)
  • Add Special Case to Power BI Query (M)
  • How do i do the following curl command in Java
  • Failed to read schema document 'http://www.springframework.org/schema/tool/spring-tool-4.1.xsd&
  • Remove “\\n” from a string, but leave the actual linebreaks?
  • DNS Lookup failed - Error with all browsers [closed]
  • Mapping two workspace folders to the same working directory
  • Is mp4 stream able with ffserver?
  • Find longest path less than or equal to given value of an acyclic, directed graph in Python
  • Are there any issues with placing image as background on an extended JFrame?
  • Django model inheritance, filtering models
  • How can I set a binding to a Combox in a UserControl?
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Problems to linebreak with an int in JLabel
  • Controls, properties, events and timers running in design time
  • Sending data from AppleScript to FileMaker records
  • Updated Ionic CLI but shows previous version (Windows)
  • ORA-29908: missing primary invocation for ancillary operator
  • jquery mobile loadPage not working
  • How to get icons for entities from eclipse?
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • Load html files in TinyMce
  • Acquiring multiple attributes from .xml file in c#
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • JaxB to read class hierarchy
  • Sorting a 2D array using the second column C++
  • java string with new operator and a literal