ImageIcon and Icon

本文详细介绍了Java Swing中Icon接口的应用及其实现类ImageIcon的使用方法,包括如何声明Icon对象数组并初始化,以及如何通过回调传递图片信息给ImageIcon对象。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Icon 是javax.swing包中的一个接口,一个小的固定大小图片,通常用于装饰组件。Icon Icon【】=new Icon【i】;用来声明I一个Icon对象数组并把Icon对象的引用返回给Icon数组,即初始化。有了一组存放Icon组件的一系列地址。

而,令icon[i]=new ImageIcon(imageName【i】)则是运用回调将图片信息传入类中,并赋值给类对象icon[i],当然也可以这样写imageIcon【i】=new ImageIcon(imageName[i]);直接该类对象获得该类的值,不回调。imageicon是Icon接口的一个实现。

能理解到这里我可是费了九牛二虎之力,还不知道对不对,还有一些模模糊糊的知识点不懂。也许再做一些题就会明白吧。

对我昨天问题的回答。

A random number of Rabbit images ranging from 1 to 10 are displayed for each operand and the user is expected to enter the values of the two operands and the result of adding the two operands, in the given text fields. When the user clicks on the button ‘Check!’, one of two things can happen: Case 1: all three input values are correct i) the text changes to ‘"Correct! Have another go?"’. ii) the number of Rabbit images displayed for each of the two operands changes. See Figure 2 for an example. iii) the three text fields are reset (i.e. they are made empty). 2/5 Case 2: at least one of the input values entered is incorrect i) the text changes to ‘Wrong! Try again!’. ii) the number of Rabbit images displayed does NOT change. iii) the text fields do NOT change.Implement SumItUp as a Java application. You application must satisfy ALL the specific requirements given below: a) The title of the top-level container must be ‘Welcome to SumItUp!’. b) The initial text should be ‘Enter two operands, result and click on 'Check!'’. See Figure 1. c) There should be no more than 4 Rabbit images per row. See Hint 1. d) The text fields should be wide enough to display at least TWO characters. e) The button ‘Check!’ must not resize when the GUI is resized. See Hint 2 and Figure 3. f) The ‘plus sign’ icon should appear vertically centered between the two sets of Rabbit images and must not resize when the GUI is resized. See Hint 2 and Figure 3. g) When first launched and whenever a correct answer is given, the number of displayed Rabbit images for each operand should change to any number between 1 and 10 (inclusive). See Hint 3 and Hint 4. Note: It is possible for the next number(s) to be the same as the current number(s). h) Nothing should happen if the user clicks the ‘Check!’ button while at least one of the text fields are empty, i.e. no errors should be thrown in this case. Note: You can assume that only a numeric value will be entered into the text fields.
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值