我有一个java applet的作业,需要包括一个下拉菜单,一个按钮,和其他一些非常基本的东西,最最简单的就行
我做了一些,希望有谁可以帮我加一些东西importjava.applet.Applet;importjava.awt.*;importjava.awt.event.*;i...
我做了一些,希望有谁可以帮我加一些东西
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.Array;
public class myapplet extends Applet
implements ActionListener {
private Choice rgb;
public void init() {
Button beeper = new Button("Beep me");
add(beeper);
beeper.addActionListener(new myactuallistener());
rgb = new Choice();
rgb.add("Red");
rgb.add("Green");
rgb.add("Blue");
rgb.add("MysteryColor");
// rgb.select(2);
add(rgb);
}
public void paint(Graphics g) {
g.drawString("Howdy there", 5, 50);
g.draw3DRect(90, 60, 55, 25, true);
g.fillOval(10, 80, 20, 60);
g.setPaintMode();
g.drawOval(100, 90, 70, 30);
}
public void repaint() {
Graphics g = this.getGraphics();
g.clearRect(0, 0, 300, 250);
String outString = "";
g.drawString(outString, 5, 50);
g.draw3DRect(90, 60, 55, 25, true);
Color myColor = null;
String choice = rgb.getSelectedItem();
if (choice == "Red")
myColor = Color.red;
if (choice == "Green")
myColor = Color.green;
if (choice == "Blue")
myColor = Color.blue;
if (choice == "MysteryColor")
myColor = new Color(0.8F, 0.7F, 0.3F);
g.setColor(myColor);
// g.setColor(Color.red);
g.fillOval(10, 80, 20, 60);
g.setPaintMode();
g.drawOval(100, 90, 70, 30);
}
public void actionPerformed(ActionEvent thisEvent) {
Component comp = (Component)thisEvent.getSource();
comp.getToolkit().beep();
comp.getParent().repaint();
}
}
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class myactuallistener implements ActionListener {
@Override
public void actionPerformed(ActionEvent thisEvent) {
Component comp = (Component)thisEvent.getSource();
comp.getToolkit().beep();
comp.getParent().repaint();
}
}
我想加一个按钮,可以根据下拉菜单的选项,画出不同的图形,或颜色。
和几个checkbox。
然后要有一个 MouseListener interface,
by using a class like BasicComboPopup.ListMouseHandler
不知有没有人会做 展开
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.Array;
public class myapplet extends Applet
implements ActionListener {
private Choice rgb;
public void init() {
Button beeper = new Button("Beep me");
add(beeper);
beeper.addActionListener(new myactuallistener());
rgb = new Choice();
rgb.add("Red");
rgb.add("Green");
rgb.add("Blue");
rgb.add("MysteryColor");
// rgb.select(2);
add(rgb);
}
public void paint(Graphics g) {
g.drawString("Howdy there", 5, 50);
g.draw3DRect(90, 60, 55, 25, true);
g.fillOval(10, 80, 20, 60);
g.setPaintMode();
g.drawOval(100, 90, 70, 30);
}
public void repaint() {
Graphics g = this.getGraphics();
g.clearRect(0, 0, 300, 250);
String outString = "";
g.drawString(outString, 5, 50);
g.draw3DRect(90, 60, 55, 25, true);
Color myColor = null;
String choice = rgb.getSelectedItem();
if (choice == "Red")
myColor = Color.red;
if (choice == "Green")
myColor = Color.green;
if (choice == "Blue")
myColor = Color.blue;
if (choice == "MysteryColor")
myColor = new Color(0.8F, 0.7F, 0.3F);
g.setColor(myColor);
// g.setColor(Color.red);
g.fillOval(10, 80, 20, 60);
g.setPaintMode();
g.drawOval(100, 90, 70, 30);
}
public void actionPerformed(ActionEvent thisEvent) {
Component comp = (Component)thisEvent.getSource();
comp.getToolkit().beep();
comp.getParent().repaint();
}
}
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class myactuallistener implements ActionListener {
@Override
public void actionPerformed(ActionEvent thisEvent) {
Component comp = (Component)thisEvent.getSource();
comp.getToolkit().beep();
comp.getParent().repaint();
}
}
我想加一个按钮,可以根据下拉菜单的选项,画出不同的图形,或颜色。
和几个checkbox。
然后要有一个 MouseListener interface,
by using a class like BasicComboPopup.ListMouseHandler
不知有没有人会做 展开
4个回答
展开全部
同学.你这不都写的这么多了吗?自己想出来的印象深刻
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
的确蛮有味!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询