drawLine使用AWT(drawLine using AWT)
我刚开始使用AWT进行GUI。 框架正在打开,但未显示Line。
import java.awt.*; import java.awt.event.*; class A extends Frame { public static void main(String args[]) { Frame f= new Frame(); f.setTitle("New Frame"); f.setSize(1000,1000); f.setVisible(true); f.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent we){System.exit(0);}}); } public void paint(Graphics g) { g.setColor(Color.blue); g.drawLine(60,500,230,5); } }
I just started with GUI using AWT. The frame is opening but the Line is not being displayed.
import java.awt.*; import java.awt.event.*; class A extends Frame { public static void main(String args[]) { Frame f= new Frame(); f.setTitle("New Frame"); f.setSize(1000,1000); f.setVisible(true); f.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent we){System.exit(0);}}); } public void paint(Graphics g) { g.setColor(Color.blue); g.drawLine(60,500,230,5); } }
原文:
最满意答案
这里有三件事需要考虑:
- 数据的性质是什么:设置或文档 - 或者每个的一些?
- 是按用户还是按机器安装应用程序?
- 设置数据是否应该与用户一起漫游?
有时很难确定数据的性质。 为简单起见,将数据分为两类:设置和文档。 它们通常存储在不同的地方,如The New Old Thing博客中所讨论的
“我的文档”和“应用程序数据”之间最重要的区别是“我的文档”是用户存储文件的位置,而“应用程序数据”是程序存储文件的位置。
如果每台计算机都安装了该应用程序,则“app installer”对用户数据没有任何影响。 (否则,那么用户的数据是什么?)用户使用应用程序(设置)时应由用户创建用户数据,或者用户通过应用程序(文档)创建用户数据。 现在,当用户第一次启动应用程序时,它可以为用户提供管理每用户数据的方法,以便用户可以在卸载应用程序之后或在用户决定不再使用它之后进行清理。
手段可以是应用程序使用UninstallString创建的用户ARP条目,该条目运行复制到用户的AppData文件夹的内容。 或者,它可以是用户执行相同的快捷方式。 或者,如果您需要用户不触发的内容,则用户运行注册表项以启动检测应用程序是否已卸载的实用程序(这可能是一个挑战)。
如果按用户安装应用程序,那么“app install”可以删除应用程序,设置和文档,但应该只删除应用程序。
文档是用户的,但根据应用程序,如果用户无意再次运行应用程序,则文档可能毫无价值。 你应该离开他们或者问他们。
至于设置,正如您所指出的,如果用户将来运行任何版本的应用程序,它们将非常有用。 应用程序应该能够升级或忽略新版本或旧版本的设置。
有关应用数据的更多观看,请参阅此其他New Old Thing 帖子 。
那么,回答你的问题:
- 两者,取决于文件是什么。
- 设置:可能(但如果每个用户安装了应用程序,则无法)。 文件:没有。
- 通常,应用程序应该创建应用程序数据,但如果您希望用户知道其文档的“所有用户”位置,则会出现例外情况。
只有设计应用程序和安装程序才能产生最佳的用户体验。
There are three things to consider here:
- What is the nature of the data: settings or documents—or some of each?
- Is the app installed per user or per machine?
- Should settings data roam with the user or not?
Sometimes it is hard to determine the nature of the data. For simplicity, divide the data into two categories: settings and documents. They are typically stored in different places as discussed in the The New Old Thing blog
The most important difference between My Documents and Application Data is that My Documents is where users store their files, whereas Application Data is where programs store their files.
If the app is installed per machine then the "app installer" can have nothing to with user data. (If otherwise, then which users' data?) User data should be created by the app when the user uses the app (settings) or by the user through the app (documents). Now, when a user starts the app the first time, it can provide a means for the user to manage the per user data so the user can clean up after the app is uninstalled or after that user decides to not use it anymore.
The means could be a user ARP entry that the app creates with an UninstallString that runs something it copies to the user's AppData folder. Or, it could be a user shortcut to do the same. Or, if you want something the user doesn't trigger, a user Run registry entry to launch a utility that detects if the app has been uninstalled (which could be a challenge).
If the app is installed per user then the "app install" could remove the app, settings and documents but should only remove the app.
Documents are the user's but depending on the app, if a user has no intention of running the app again, the documents might be worthless. You should either leave them or ask.
As for settings, as you point out, they would be useful if the user runs any version of the app in the future. An app should be able to upgrade or ignore settings for a newer or older version.
See this other New Old Thing post for more views on app data.
So, to answer your questions:
- Both, depending on what the files are.
- Settings: maybe (but can't if the app installed per user). Documents: No.
- Usually the app should create app data, but an exception would be if you want users to know of an "all users" location for their documents.
Only designing the app and installer together produce the best user experience.
相关问答
更多-
我同意Alex Coplan的一个重要补充。 将所有常量放在一个名为“Constants.h”的文件中(或者你想要的) 编辑: 当我三年前回答这个问题时,我在#define频道里,检查下面的修订。 Constants.h #define kFilterDate @"date" #define kFilterRadius @"radius" #define kFilterSort @"sort" //Global Strings #define kDividingString @" / " //Strin ...
-
在动态AJAX负载上存储支持JSON的最佳位置在哪里?(Where is the best place to store supporting JSON on dynamic AJAX load?)[2023-05-03]
将JSON放入页面的最佳位置在哪里,如果它加载了模态内容? 让我们说我不希望它在需要之前加载; 如果它被应用于第一个模态对话框中的页面并且它被所有其他对话框使用,那么它是宏的,但它也可以仅包含在对话框中并且仅在该对话框打开时使用。 那么JSON在哪里呢? 好吧,将JSON数据保存在网页上很容易。 没有必要将HTML元素视为数据的承载者。 你可以把它放在全局对象window 。 假设你叫这个地方保存你的数据VAULT : // So, we have the JSON come from the se ... -
实际上你在这里问了两个问题: 存储和操作数据的位置? 何时以及如何使用$ rootScope(与$ scope相比)? 1)我将参考这篇文章 :每当数据和方法需要重用时,我会编写一个这样的服务。 angular.module('modelDemo').service("myModel", [function() { this.list = [what, ever, items, you, have]; this.property= null; this.setProperty = ...
-
在应用首次启动时,您可以允许用户根据选择选择他/她的文件夹,然后在将来的访问列表中添加该文件夹。 所以你可以随时访问该文件夹。 请查看下面给出的链接。 如何保存StorageFile以便以后使用? 探索WinRT:Storage.AccessCache Windows.Storage.AccessCache类 On app's first launch, you can allow the user to choose his/her folder as per choice, and then add t ...
-
嵌入式资源是优选的,因为OS更优化以读取那些而不是独立文件。 但是速度的差异可以忽略不计,所以我建议你试着看看它是否对你有任何影响,尤其是在像诺基亚Lumia 520这样的低端设备上。 Embedded resource is preferable since OS is more optimized to read those rather than standalone files. But the difference in speed may be negligible, so I suggest ...
-
需要一个持久的位置来存储我的Core Data存储的备份(Need a persistent place to store a backup of my Core Data store)[2022-05-08]
Library / ApplicationSupport将完成我需要的工作......(以防万一其他人需要相同的信息)。 SD Library/ApplicationSupport will do what I need... (just in case someone else needs the same info). SD -
在线读取/写入/存储少量数据的最佳位置是什么?(What is the best place to read/write/store a small amount of data online?)[2022-01-06]
试用Google Spreadsheets( Java API参考 )。 您可以上传CSV文件,然后将其自动转换为电子表格,然后您可以通过编程方式查询或编辑它,或者在线操作它 ,然后如果需要将其作为CSV文件导出,可以将其导出 。 Try Google Spreadsheets (Java API Reference). You can upload a CSV which gets automatically converted to a spreadsheet, then you can query o ... -
在核心数据存储中初始化数据的适当位置在哪里?(Where is the proper place to initialize data in a core data store?)[2022-03-21]
理想情况下,在开发结束时,您可以将此数据填充到Core Data存储中并将其添加到项目中。 首次运行时,您将该应用程序包中的该商店作为用户的Core Data商店进行复制。 这适用于您的情况。 在无法做到这一点的情况下,可以在后台线程上执行导入。 Ideally towards the end of development you would populate this data into a Core Data store and add that to your project. On first ru ... -
您可以将表单宏与Laravel Collective Package一起使用 Laravel Collective: https : //github.com/LaravelCollective/html 一个很棒的例子,你可以找到https://github.com/rappasoft/laravel-5-boilerplate 请参阅App \ Providers \ MacroServiceProvider.php I have found a very good solution to this o ...
-
存储应用数据的最佳位置(The best place to store app's data)[2024-05-11]
这里有三件事需要考虑: 数据的性质是什么:设置或文档 - 或者每个的一些? 是按用户还是按机器安装应用程序? 设置数据是否应该与用户一起漫游? 有时很难确定数据的性质。 为简单起见,将数据分为两类:设置和文档。 它们通常存储在不同的地方,如The New Old Thing博客中所讨论的 “我的文档”和“应用程序数据”之间最重要的区别是“我的文档”是用户存储文件的位置,而“应用程序数据”是程序存储文件的位置。 如果每台计算机都安装了该应用程序,则“app installer”对用户数据没有任何影响。 (否则 ...