我有点卡住了.当我按下按钮时,提交应该重新显示JLabel图像在同一位置的另一张图片,所以如果有人有任何想法我会很感激他们我正在使用eclipse并且该程序正在编译和运行.这是代码
/** Here is the GUI of the program
* class name SlideShowGui.java
* @author Kiril Anastasov
* @date 07/03/2012
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class SlideShowGui extends JPanel implements ActionListener
{
JLabel name, comments, images;
JTextField namejtf, commentsjtf, captionjtf;
JButton submit;
ImageIcon pictures;
SlideShowGui()
{
name = new JLabel("Name:");
this.add(name);
namejtf = new JTextField(15);
this.add(namejtf);
comments = new JLabel("Comments:");
this.add(comments);
commentsjtf = new JTextField(15);
this.add(commentsjtf);
submit = new JButton("Submit");
this.add(submit);
submit.addActionListener(this);
pictures = new …Run Code Online (Sandbox Code Playgroud) 我正在尝试重置JLabel数组.标签顶部有图像,所以当我按下按钮时,标签应该被重置.我试着这样做
for(int i=0; i<desks.length; i++)
{
desks[i].setText("");
rightPanel.add(desks[i]);
}
Run Code Online (Sandbox Code Playgroud)
所以,如果有人有一个想法,那将是伟大的.
大家好,我在这里有点堆叠.当我运行程序并按下提交按钮时,它应该每2秒更换4张图片.但是它不会重新显示图像.如果有人能帮我一把,那就太好了.我正在使用eclipse,程序正在编译和运行.这是代码.
/** Here is the GUI of the program
* class name SlideShowGui.java
* @author Kiril Anastasov
* @date 07/03/2012
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class SlideShowGui extends JPanel implements ActionListener, Runnable
{
JLabel name, comments, images;
JTextField namejtf, commentsjtf, captionjtf;
JButton submit;
ImageIcon pictures1, pictures2, pictures3, pictures4;
//ImageIcon []pictures2 = {galileo1.jpg};
SlideShowGui()
{
name = new JLabel("Name:");
this.add(name);
namejtf = new JTextField(15);
this.add(namejtf);
comments = new JLabel("Comments:");
this.add(comments);
commentsjtf = new JTextField(15);
this.add(commentsjtf);
submit …Run Code Online (Sandbox Code Playgroud) 按下勾选按钮时出现运行错误.我正在尝试使用javax.swing.Timer按下勾选按钮来触发事件所以如果有人有任何建议我会很感激他们.我目前正在使用Eclipse,按下勾选按钮时会出现运行时错误.
线程"AWT-EventQueue-0"中的异常java.lang.Error:未解决的编译问题:类型ClockPanel必须在ClockPanel.actionPerformed(ClockPanel.java:10)实现继承的抽象方法ActionListener.actionPerformed(ActionEvent)
这是我正在使用的代码(3个类).
import java.util.Calendar;
import java.util.GregorianCalendar;
class Clock
{
int hour;
int minute;
int second;
Calendar gregcal = new GregorianCalendar();
int h = gregcal.get(Calendar.HOUR_OF_DAY);
int m = gregcal.get(Calendar.MINUTE);
int s = gregcal.get(Calendar.SECOND);
//default constructor
Clock()
{
hour = h;
minute = m;
second = s;
}
//parameterized constructor
Clock(int hour, int minute, int second)
{
this.hour = hour;
this.minute = minute;
this.second = second;
}
public int getHour()
{
return hour;
}
public int getMinute()
{
return minute;
} …Run Code Online (Sandbox Code Playgroud) 嗨伙计们,当点击提交按钮时,我开始增加,当它是2时,我希望它改变图片,当我是4我想要改变到另一张图片但它没有这样做,所以如果有人有想法它会是大.我正在使用eclipse,程序正在编译和运行.这是代码
/** Here is the GUI of the program
* class name SlideShowGui.java
* @author Kiril Anastasov
* @date 07/03/2012
*/
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class SlideShowGui extends JPanel implements ActionListener, Runnable
{
JLabel name, comments, images;
JTextField namejtf, commentsjtf, captionjtf;
JButton submit;
ImageIcon pictures;
SlideShowGui()
{
name = new JLabel("Name:");
this.add(name);
namejtf = new JTextField(15);
this.add(namejtf);
comments = new JLabel("Comments:");
this.add(comments);
commentsjtf = new JTextField(15);
this.add(commentsjtf);
submit = new JButton("Submit");
this.add(submit);
submit.addActionListener(this);
pictures = …Run Code Online (Sandbox Code Playgroud) 我通过SimpleDateFormat得到当前时间,我希望返回6小时30分钟前的新时间.我尝试用Calendar做它,但是如果它们小于30,它会返回负值.所以我的问题是,如果可以在需要从小时或天数借用时返回正确的数字.这是代码.我使用eclipse,程序正在编译和运行.
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class DifferenceInHours_04
{
public static void main(String[] args)
{
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy hh:mm:ss zzz" );
System.out.println(sdf.format(date));
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR);
int minute = cal.get(Calendar.MINUTE );
int second = cal.get(Calendar.SECOND);
System.out.println("Current time: " + hour + ":" + minute +":" + second);
int newHour = hour - 6;
int newMinute = minute …Run Code Online (Sandbox Code Playgroud)