UnderlinedLabel.java
     1: //========================================================================================
     2: //  UnderlinedLabel.java
     3: //    en:Underlined label
     4: //    ja:下線付きラベル
     5: //  Copyright (C) 2003-2019 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: package xeij;
    14: 
    15: import java.awt.*;  //BasicStroke,BorderLayout,BoxLayout,Color,Component,Container,Cursor,Desktop,Dimension,Font,Frame,Graphics,Graphics2D,GraphicsDevice,GraphicsEnvironment,GridLayout,Image,Insets,Paint,Point,Rectangle,RenderingHints,Robot,Shape,Stroke,TexturePaint,Toolkit
    16: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    17: import javax.swing.*;  //AbstractSpinnerModel,Box,ButtonGroup,DefaultListModel,ImageIcon,JApplet,JButton,JCheckBox,JCheckBoxMenuItem,JDialog,JFileChooser,JFrame,JLabel,JList,JMenu,JMenuBar,JMenuItem,JPanel,JRadioButton,JScrollPane,JSpinner,JTextArea,JTextField,JTextPane,JViewport,ScrollPaneConstants,SpinnerListModel,SpinnerNumberModel,SwingConstants,SwingUtilities,UIManager,UIDefaults,UnsupportedLookAndFeelException
    18: 
    19: public class UnderlinedLabel extends JLabel {
    20:   private Stroke stroke;
    21:   public UnderlinedLabel (String text) {
    22:     super (text);
    23:     stroke = new BasicStroke ();
    24:   }
    25:   @Override public void paintComponent (Graphics g) {
    26:     super.paintComponent (g);
    27:     Graphics2D g2 = (Graphics2D) g;
    28:     g2.setColor (getForeground ());
    29:     g2.setStroke (stroke);
    30:     g2.drawLine (0, getHeight () - 2, getWidth () - 1, getHeight () - 2);  //下線を描き足す。位置はてきとう
    31:   }
    32: }  //class UnderlinedLabel
    33: 
    34: 
    35: