Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add a listener to the checkbox which will add/remove the from the label. Here is an example of box and label maybe helpful:</p> <pre><code>import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class check { public static void main(String args[]) { JFrame frame = new JFrame("for bsm"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JCheckBox box = new JCheckBox("check me"); final JLabel label = new JLabel("&lt;html&gt;text&lt;/html&gt;"); label.setFont(new Font("helvetica", Font.PLAIN, 12)); label.setForeground(new Color(50, 50, 25)); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); if(abstractButton.getModel().isSelected()) label.setText(label.getText().replace("&lt;html&gt;", "&lt;html&gt;&lt;strike&gt;").replace("&lt;/html&gt;", "&lt;/strike&gt;&lt;/html&gt;")); else label.setText(label.getText().replace("&lt;html&gt;&lt;strike&gt;", "&lt;html&gt;").replace("&lt;/strike&gt;&lt;/html&gt;", "&lt;/html&gt;")); } }; box.addActionListener(actionListener); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(10, 10)); panel.add(label, BorderLayout.NORTH); panel.add(box, BorderLayout.SOUTH); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); frame.add(panel); frame.setSize(300, 200); frame.setVisible(true); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload