乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      java – Timer正在嘗試轉(zhuǎn)換為String

       印度阿三17 2019-06-24

      有人可以告訴我為什么Timer試圖將int轉(zhuǎn)換為String.這是一直存在的錯(cuò)誤.

      CurrentTimePrinter.java:48: error: incompatible types: int cannot be
      converted to String
      time = new Timer(1000,listener);

      CurrentTimePrinter.java:49: error: cannot find symbol
      time.start();

      import javax.swing.*;
      import java.awt.*;
      import java.io.*;
      import java.util.Date;
      import java.util.Timer;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.Color;
      import java.awt.Font;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JTextField;
      import java.awt.BorderLayout;
      
      public class CurrentTimePrinter extends JFrame 
      {
         private JButton Exitbutton;
         private JTextField textField;
         private static final int FIELD_WIDTH = 10;
         private static final int FRAME_WIDTH = 600;
         private static final int FRAME_HEIGHT = 400;
         private ActionListener listener;
         public Timer time;
      
         public CurrentTimePrinter()
         {
            //listener = new CtpListener();
            createComponents();
            setSize(FRAME_WIDTH, FRAME_HEIGHT);
         }
         public void createComponents()
         {
            Color orange = new Color(255,165,0);
            Font font = new Font("Times New Roman", Font.BOLD, 14);      
            textField = new JTextField(FIELD_WIDTH);
            Exitbutton = new JButton("EXIT");
            class CtpListener implements ActionListener
            {   
               public void actionPerformed(ActionEvent event)
               {
                  textField.setText(""   new Date());
                  Date now = new Date();
                  System.out.println(now);
               }
            } 
            ActionListener listener = new CtpListener();
            time = new Timer(1000,listener);
            time.start();
      
      
            Exitbutton.setFont(font);
            Exitbutton.setForeground(Color.BLACK);
            ExitButtonListener exitListener = new ExitButtonListener();
            Exitbutton.addActionListener(exitListener);
            JPanel panel1 = new JPanel();
            time = new Timer(1000, listener); 
            time.start();
      
            JPanel panel2 = new JPanel();
            panel1.setBackground(orange);
            panel1.add(Exitbutton);
            panel2.add(textField);
            JPanel contentPane = new JPanel(new BorderLayout());
            contentPane.add(panel1, BorderLayout.SOUTH);
            contentPane.add(panel2, BorderLayout.CENTER);
            setContentPane(contentPane);
         }  
         class ExitButtonListener implements ActionListener
         {
            public void actionPerformed(ActionEvent event)
            {
               System.exit(0);
            }
         }            
      
         public static void main(String[] args)
         {     
            JFrame frame = new CurrentTimePrinter();
            frame.setTitle("Current Time");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
         }
      
      }
      

      解決方法:

      您正在使用java.util.Timer.你想要javax.swing.Timer.

      在導(dǎo)入中替換它,它應(yīng)該是:

       import javax.swing.Timer;
      
      來(lái)源:https://www./content-1-263501.html

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀(guān)點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多