jframe

杨玲 201771010133《面向对象程序设计(java)》第十六周学习总结

ぃ、小莉子 提交于 2021-02-17 22:23:51
《面向对象程序设计( java )》第十六周学习总结 第一部分:理论知识学习部分 1、程序是一段静态的代码,它是应用程序执行的蓝本。进程是程序的一次动态执行,它对应了从代码加载、执行至执行完毕的一个完整过程。操作系统为每个进程分配一段独立的内存空间和系统资源,包括:代码数据以及堆栈等资源。每一个进程的内部数据和状态都是完全独立的。多任务操作系统中,进程切换对CPU资源消耗较大。 2、多线程是进程执行过程中产生的多条执行线索。线程是比进程执行更小的单位。线程不能独立存在,必须存在于进程中,同一进程的各线程间共享进程空间的数据。每个线程有它自身的产生、存在和消亡的过程,是一个动态的概念。多线程意味着一个程序的多行语句可以看上去几乎在同一时间内同时运行。线程创建、销毁和切换的负荷远小于进程,又称为轻量级进程。 3、Java实现多线程有两种途径:创建Thread类的子类;在程序中定义实现Runnable接口的类。 4、用Thread类的子类创建线程:首先需从Thread类派生出一个子类,在该子类中重写run()方法。然后用创建该子类的对象Lefthand left=new Lefthand(); Righthand right=new Righthand();最后用start()方法启动线程 left.start(); right.start(); 5

Why does this while loop prevent paint method from working correctly?

大城市里の小女人 提交于 2021-02-17 03:39:10
问题 Here's my code: package javaapplication2; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class JavaApplication2 extends JPanel { public static void main(String[] args) { JFrame frame = new JFrame("Simple Sketching Program"); frame.getContentPane().add(new JavaApplication2()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setVisible(true); } @Override public void paint(Graphics g) { g.setColor

Keyboard input in Java Applet

好久不见. 提交于 2021-02-16 18:07:14
问题 What is the best way to listen for keyboard input in a Java Applet? I have an applet which opens a JFrame and I am using a KeyListener to listen for keyboard input. This works fine in my development environment (eclipse), but when I run the applet through a browser (I have tried Firefox and IE) it does not respond to keyboard events. However, if I run the applet and then minimize and maximize the frame, it works. I have tried setting focus to the JFrame in many different ways and also

Keyboard input in Java Applet

為{幸葍}努か 提交于 2021-02-16 18:06:53
问题 What is the best way to listen for keyboard input in a Java Applet? I have an applet which opens a JFrame and I am using a KeyListener to listen for keyboard input. This works fine in my development environment (eclipse), but when I run the applet through a browser (I have tried Firefox and IE) it does not respond to keyboard events. However, if I run the applet and then minimize and maximize the frame, it works. I have tried setting focus to the JFrame in many different ways and also

Keyboard input in Java Applet

三世轮回 提交于 2021-02-16 18:06:49
问题 What is the best way to listen for keyboard input in a Java Applet? I have an applet which opens a JFrame and I am using a KeyListener to listen for keyboard input. This works fine in my development environment (eclipse), but when I run the applet through a browser (I have tried Firefox and IE) it does not respond to keyboard events. However, if I run the applet and then minimize and maximize the frame, it works. I have tried setting focus to the JFrame in many different ways and also

Keyboard input in Java Applet

China☆狼群 提交于 2021-02-16 18:05:44
问题 What is the best way to listen for keyboard input in a Java Applet? I have an applet which opens a JFrame and I am using a KeyListener to listen for keyboard input. This works fine in my development environment (eclipse), but when I run the applet through a browser (I have tried Firefox and IE) it does not respond to keyboard events. However, if I run the applet and then minimize and maximize the frame, it works. I have tried setting focus to the JFrame in many different ways and also

Click a button to open a new JFrame / GUI,

时光怂恿深爱的人放手 提交于 2021-02-13 17:34:25
问题 I seem to not be able to find a way to get my code to work. I am making a program and until now everything was working, i have some buttons and they do what they should. But now i added a button that when a user click it, it should close the current GUI and open a new one. I also want to point out that i created a new class for this new GUI. The other GUI class that i want to call is the GuiCrafting , in that class the GUI is also all coded, and works if i call it on the Main . My question is

Click a button to open a new JFrame / GUI,

走远了吗. 提交于 2021-02-13 17:32:33
问题 I seem to not be able to find a way to get my code to work. I am making a program and until now everything was working, i have some buttons and they do what they should. But now i added a button that when a user click it, it should close the current GUI and open a new one. I also want to point out that i created a new class for this new GUI. The other GUI class that i want to call is the GuiCrafting , in that class the GUI is also all coded, and works if i call it on the Main . My question is

Eclipse进行可视化插件——WindowBuilder的安装

泄露秘密 提交于 2021-02-12 19:25:57
https://blog.csdn.net/yerenyuan_pku/article/details/82861589 WindowBuilder插件的简单介绍 大家都知道在做窗体程序的开发中,传统的Java语言在开发窗体应用程序中仅靠代码语句来实现对控件的控制显得不够灵活和准确,难以高效的开发具有良好用户界面的应用程序,所以我们应该寻找Java中可以拖拽控件来实现窗体绘制的插件。所幸的是找到了一种还算好用的插件——WindowBuilder,它是一款基于Eclipse平台的双向Java的GUI设计插件式的软件,它具备SWT/JFACE开发、Swing开发及GWT开发三大功能,是一款不可多得的Java体系中的WYSIWYG工具。 下载 打开浏览器,在地址栏中输入网址:http://www.eclipse.org/windowbuilder/。 单击Download按钮。 在打开的网站中单击如下link。 接着跳到一个下载页面,点击Download按钮进行下载即可。最后下载到的zip压缩包为repository.zip。 WindowBuilder离线安装 由于下载到本地之后是一个zip压缩文件,所以可离线安装WindowBuilder插件了。安装步骤如下: 打开Eclipse,Help→Install New Software...,出现如下图所示界面。 点击Add按钮

使用WindowBuilder设计Swing程序

早过忘川 提交于 2021-02-12 18:53:40
Swing程序表示Java的客户端窗体程序,除了通过手动编写代码的方式设计Swing程序之外,Eclipse中还提供了一种WindowBuilder工具,该工具是一种非常好用的Swing可视化开发工具,有了它,开发人员就可以像Visual Studio一样通过拖放组件的方式编写Swing程序了,下面对如何使用WindowBuilder开发工具设计Swing程序进行详细介绍。 A.1 下载WindowBuilder工具 下载WindowBuilder工具有两种方法,一种方法是直接下载集成WindowBuilder工具的Eclipse,另外一种是通过Install New Software安装,下面分别介绍。 þ 下载集成WindowBuilder工具的Eclipse 在Eclipse官方网站的Eclipse下载页面提供了多种Eclipse工具,其中有一个“Eclipse IDE for Java Developers”选项,该项即集成了WindowBuilder工具,用户只需要根据自己的操作系统位数下载相应的版本即可,如图A.1所示。 图A.1下载集成WindowBuilder工具的Eclipse þ 通过Install New Software安装WindowBuilder工具 如果用户下载的Eclipse版本不是“Eclipse IDE for Java Developers”