import java.util.logging.Level; 
import java.util.logging.Logger; 
import javax.swing.BoxLayout; 
import javax.swing.JButton; 
import javax.swing.JFrame; 
import javax.swing.JToggleButton; 
import javax.swing.UIManager; 
import javax.swing.UnsupportedLookAndFeelException; 
import javax.swing.WindowConstants; 

public class WindowsToggleButtonTextTruncation { 
    private static final String LABEL = "x"; 

    public static void main(String... args) { 
        try { 
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { 
            Logger.getLogger(WindowsToggleButtonTextTruncation.class.getName()).log(Level.SEVERE, null, ex); 
        } 

        JFrame frame = new JFrame("Toggle Button Text Truncation"); 
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 
        frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS)); 

        frame.add(new JToggleButton(LABEL)); // Toggle button label will be truncated 
        frame.add(new JButton(LABEL)); 

        frame.pack(); 
        frame.setVisible(true); 
    } 
} 