第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

書上的源代碼直接用cmd運(yùn)行沒(méi)有問(wèn)題但是eclipse卻報(bào)錯(cuò)是為什么

書上的源代碼直接用cmd運(yùn)行沒(méi)有問(wèn)題但是eclipse卻報(bào)錯(cuò)是為什么

人間的下午茶 2016-11-06 14:59:47
java代碼直接用命令行編譯運(yùn)行沒(méi)有錯(cuò)誤,但是導(dǎo)入項(xiàng)目后 eclipse卻顯示有錯(cuò)誤 ?代碼是java核心技術(shù)的源代碼import java.awt.*;import java.io.*;import javax.swing.*;/**?* A program for viewing images.?* @version 1.30 2014-02-27?* @author Cay Horstmann?*/public class ImageViewer{? ?public static void main(String[] args)? ?{? ? ? EventQueue.invokeLater(() -> {? ? ? ? ?JFrame frame = new ImageViewerFrame();? ? ? ? ?frame.setTitle("ImageViewer");? ? ? ? ?frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);? ? ? ? ?frame.setVisible(true);? ? ? });? ?}}/**?* A frame with a label to show an image.?*/class ImageViewerFrame extends JFrame{? ?private JLabel label;? ?private JFileChooser chooser;? ?private static final int DEFAULT_WIDTH = 300;? ?private static final int DEFAULT_HEIGHT = 400;? ?public ImageViewerFrame()? ?{? ? ? setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);? ? ? // use a label to display the images? ? ? label = new JLabel();? ? ? add(label);? ? ? // set up the file chooser? ? ? chooser = new JFileChooser();? ? ? chooser.setCurrentDirectory(new File("."));? ? ? // set up the menu bar? ? ? JMenuBar menuBar = new JMenuBar();? ? ? setJMenuBar(menuBar);? ? ? JMenu menu = new JMenu("File");? ? ? menuBar.add(menu);? ? ? JMenuItem openItem = new JMenuItem("Open");? ? ? menu.add(openItem);? ? ? openItem.addActionListener(event -> {? ? ? ? ?// show file chooser dialog? ? ? ? ? ? int result = chooser.showOpenDialog(null);? ? ? ? ? ? // if file selected, set it as icon of the label? ? ? ? ? ? if (result == JFileChooser.APPROVE_OPTION)? ? ? ? ? ? {? ? ? ? ? ? ? ?String name = chooser.getSelectedFile().getPath();? ? ? ? ? ? ? ?label.setIcon(new ImageIcon(name));? ? ? ? ? ? }? ? ? ? ?});? ? ? JMenuItem exitItem = new JMenuItem("Exit");? ? ? menu.add(exitItem);? ? ? exitItem.addActionListener(event -> System.exit(0));? ?}}
查看完整描述

4 回答

?
rookie2maven

TA貢獻(xiàn)278條經(jīng)驗(yàn) 獲得超76個(gè)贊

eclipse檢查 ->,語(yǔ)法上不支持


查看完整回答
反對(duì) 回復(fù) 2016-11-06
?
懶羊

TA貢獻(xiàn)7條經(jīng)驗(yàn) 獲得超0個(gè)贊

/**

*java中匿名類的創(chuàng)建 (參考下列,加粗,傾斜的代碼)

*/




import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class ImageViewer {

?? ? public static void main(String[] args)

?? ??? {

?? ?????? EventQueue.invokeLater(

???????????? new Runnable() {
?? ??? ??? ?public void run() {
?? ??? ??? ??? ?
?? ????????? JFrame frame = new ImageViewerFrame();

?? ????????? frame.setTitle("ImageViewer");

?? ????????? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

?? ????????? frame.setVisible(true);
?? ??? ??? ?}? }? ?? );

?? ??? }

}


class ImageViewerFrame extends JFrame

{

?? private JLabel label;

?? private JFileChooser chooser;

?? private static final int DEFAULT_WIDTH = 300;

?? private static final int DEFAULT_HEIGHT = 400;


?? public ImageViewerFrame()

?? {

????? setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);


????? // use a label to display the images

????? label = new JLabel();

????? add(label);


????? // set up the file chooser

????? chooser = new JFileChooser();

????? chooser.setCurrentDirectory(new File("."));


????? // set up the menu bar

????? JMenuBar menuBar = new JMenuBar();

????? setJMenuBar(menuBar);


????? JMenu menu = new JMenu("File");

????? menuBar.add(menu);


????? JMenuItem openItem = new JMenuItem("Open");

????? menu.add(openItem);

????? openItem.addActionListener(

new ActionListener() {?? ??? ?
?? ??? ?public void actionPerformed(ActionEvent e) {
?? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ?int result = chooser.showOpenDialog(null);

??????????? // if file selected, set it as icon of the label

?? ??? ??? ?if (result == JFileChooser.APPROVE_OPTION)
?? ??? ??? ?{
?? ??? ??? ??? ?String name = chooser.getSelectedFile().getPath();
?? ??? ??? ??? ?
?? ??? ??? ??? ?label.setIcon(new ImageIcon(name));
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ?}
???????? });
????? JMenuItem exitItem = new JMenuItem("Exit");

????? menu.add(exitItem);

????? exitItem.addActionListener(
?? ??? ??? ?? new ActionListener() {
?? ??? ?
?? ??? ?public void actionPerformed(ActionEvent e) {
?? ??? ??? ?
?? ??? ??? ?System.exit(0);
?? ??? ?}?? ??? ? ?
?? });

}



查看完整回答
反對(duì) 回復(fù) 2016-11-06
?
ewang1986

TA貢獻(xiàn)27條經(jīng)驗(yàn) 獲得超5個(gè)贊

可能是eclipse不識(shí)別Lambda語(yǔ)法

查看完整回答
反對(duì) 回復(fù) 2016-11-06
  • 4 回答
  • 0 關(guān)注
  • 2107 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)