如何将MouseEvent置于控制台中,或使Frame隐藏但功能正常? [英] How do I put MouseEvent into Console, or make Frame hidden but functional?
本文介绍了如何将MouseEvent置于控制台中,或使Frame隐藏但功能正常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Holtsoft的Ready To Program Java中的Console类。 我不允许使用javax.swing或将其作为applet。
我不知道如何制作节目,但需要制作:
a)仅限运行控制台窗口或
b)隐藏框架窗口但仍然可用
I''m using the Console class in Holtsoft''s Ready To Program Java for this. I''m not allowed to use javax.swing or make this an applet.
I don''t know how to make the program, but need to make it:
a) Run only in the console window or
b) Make the Frame window hidden, but still functional
import java.awt.event.*;
import java.awt.*;
import hsa.*;
public class MouseTest extends Frame
{
int startX, startY, endX, endY;
Console c = new Console ();
public MouseTest ()
{
super ();
MouseListener start = new MouseListener ()
{
public void mouseClicked (MouseEvent e)
{
}
public void mouseEntered (MouseEvent e)
{
}
public void mouseExited (MouseEvent e)
{
}
public void mousePressed (MouseEvent e)
{
startX = endX = e.getX ();
startY = endY = e.getY ();
repaint ();
}
public void mouseReleased (MouseEvent e)
{
}
}
;
addMouseListener (start);
MouseMotionListener end = new MouseMotionListener ()
{
public void mouseDragged (MouseEvent e)
{
endX = e.getX ();
endY = e.getY ();
repaint ();
}
public void mouseMoved (MouseEvent e)
{
}
}
;
addMouseMotionListener (end);
}
public void paint (Graphics g)
{
super.paint (g);
c.clear ();
c.setColor (Color.black);
c.drawLine (startX, startY, endX, endY);
}
public static void main (String args[])
{
Frame frame = new MouseTest ();
frame.setLocation (950, 100);
frame.setSize (400, 400);
frame.enable ();
frame.show ();
}
}
推荐答案
没有可见框架有什么好处?
无论如何,你可以设置Frame setVisible(false)
要查看某些控制台输出,请使用 System.out.println(creativetext)
What would be the benefit of not having a visible Frame?
Anyway, you can set the Frame setVisible(false)
To see some console output you use System.out.println("creativetext")
这篇关于如何将MouseEvent置于控制台中,或使Frame隐藏但功能正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文