-
-
Save halirutan/875bb442ed1fffb3a12c9b5ed63561a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jabref; | |
import java.awt.GridLayout; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.JPanel; | |
import javax.swing.SwingConstants; | |
import javax.swing.SwingUtilities; | |
import javax.swing.WindowConstants; | |
import org.jabref.model.strings.LatexToUnicodeAdapter; | |
public class SwingJLabelTester extends JPanel{ | |
private SwingJLabelTester() { | |
super(new GridLayout(3,1)); //3 rows, 1 column | |
final String latexString = LatexToUnicodeAdapter.format("This is a \\textit{test for italics} and \\textbf{a test for bold}"); | |
final JLabel label = new JLabel(latexString, SwingConstants.CENTER); | |
label.setVerticalTextPosition(SwingConstants.BOTTOM); | |
label.setHorizontalTextPosition(SwingConstants.CENTER); | |
add(label); | |
} | |
private static void createAndShowGUI() { | |
final JFrame frame = new JFrame("LabelDemo"); | |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |
frame.add(new SwingJLabelTester()); | |
frame.setSize(400,400); | |
frame.setVisible(true); | |
} | |
public static void main(final String[] args) { | |
SwingUtilities.invokeLater(SwingJLabelTester::createAndShowGUI); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment