我正在看 Randel Schofer 的屏幕录像机,我喜欢它的 GUI。我试图自己设计一个而不看源代码。我知道这是最简单的方法,但我想自己解决问题。
我遇到了很多问题:
GradientPaint
可以做到这一点。我已经用它来填充矩形和圆形,但是我如何将它用于 JFrame
? JFrame
内。
run()
方法? public class ScreenRecorder extends JFrame{
protected class background extends JPanel{
@Override
public void paintComponent(Graphics g){
}
}
}
我仍然无法获取背景。请帮忙。
最佳答案
重写 JFrame 内 JPanel 的 PaintComponent 并以与绘制 Shape 相同的方式绘制渐变。
您必须在 Photoshop/GIMP 中创建该图像,然后将其添加到 JLabel 或 JButton(取决于交互性)。
是的 - 从技术上讲它仍然位于 JFrame 内部(设置在 JFrame 内的 JLabel/JButton 上)。只是它在外面绘制,因为 JFrame 太小了。
计时器可以这样实现:
ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { // Update the display with the time. } }; timer = new Timer(speed, listener); timer.setInitialDelay(pause); timer.start();
关于java - 为屏幕录像机创建 GUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13918830/