🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #7863

Strikethrough JLabel text

#7863
From: Laurent
Date: Wed, 09 May 2001 13:28
56 lines
2198 bytes
Hi, I'm trying to put a strike through some text displayed in a JLabel. Any
ideas why the below code does not work ?

Thank you

// ********************************************************************
import java.awt.*;
import java.awt.font.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

public class StrikeT extends JFrame {
public StrikeT() {
//Create hashtable with desired font attributes
Hashtable hFontAttributes = new Hashtable();

//Set desired attributes
//hFontAttributes.put(TextAttribute.STRIKETHROUGH, new Boolean(true));
hFontAttributes.put(TextAttribute.STRIKETHROUGH,
TextAttribute.STRIKETHROUGH_ON);
//I've tried both of the above & neither works

//Create font with hFontAttributes
Font f = new Font(hFontAttributes);

//Create label containing text to be display
JLabel jLabel = new JLabel();
jLabel.setFont(f);
jLabel.setText("Hello");

//Add label to pane
getContentPane().add(jLabel);

//Output name of font used (Just wondering which one...)
System.out.println(jLabel.getFont().getFontName());

//Set size & visible
setSize(100,100);
setVisible(true);

//Add Window listener
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent winEvent) {
System.exit(0);
}
}
);
};

public static void main(String[] args) {
StrikeT s = new StrikeT();
};

};
Technical Details
Message-ID: <3af94559$1_2@dnews>
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!feeds.vnews.net!nntp.cifnet.net!newsfeed.gamma.ru!Gamma.RU!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,8bbc3e8551afaf17,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-09 07:14:05 PST
From: "Laurent" <lsmadja@hotmail.com>
Newsgroups: borland.public.jbuilder.java.language
Subject: Strikethrough JLabel text
Date: Wed, 9 May 2001 15:28:54 +0200
Lines: 60
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
NNTP-Posting-Host: 212.208.140.161
Message-ID: <3af94559$1_2@dnews>
X-Trace: dnews 989414745 212.208.140.161 (9 May 2001 06:25:45 -0700)
Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!feeds.vnews.net!nntp.cifnet.net!newsfeed.gamma.ru!Gamma.RU!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews