首页 \ 问答 \ 欢迎创建我自己的Swing组件的建议(Advice welcomed on creating my own Swing component)

欢迎创建我自己的Swing组件的建议(Advice welcomed on creating my own Swing component)

最近我问到哪个是最好的Swing组件绑定到BigDecimal变量(具有一些特定的编辑属性)。 事实证明,没有一个标准的Swing组件完全适合我,也没有找到我发现的第三方Swing组件库。 所以我决定创建自己的Swing组件。

组件说明:

我想扩展JTextFieldJFormattedTextField ,因此我的新组件可以很容易地绑定到BigDecimal变量。

该组件将具有可自定义的缩放长度属性。

行为:

绘制组件时,它仅显示右侧刻度数字的小数点和空格。

当组件获得焦点时,插入符号应位于小数点左侧。 当用户键入数字(忽略任何其他字符)时,它们出现在插入符的左侧,只接受长度 - 数字的数字,当整数部分已满时,忽略任何其他数字类型。 每当用户键入小数点时,插入符号移动到小数点的右侧。 键入的以下数字显示在小数部分,只有小数位数被认为是小数部分已满的任何其他数字被忽略。 此外,当用户键入小数点左侧的数字时,应显示千位分隔符。

我还希望能够将该组件用作JTable中单元编辑器 (无需对其进行两次编码)。

在组件上调用getValue()方法应该生成表示刚刚输入的数字的BigDecimal。


我从来没有创建过自己的Swing组件; 我几乎没有使用标准的。 所以我很感激有关创建所描述组件的任何好的教程/信息/提示。 到目前为止, 是我唯一得到的东西。

提前致谢。


Recently I asked which was the best Swing component to bind to a BigDecimal variable (with some particular editing properties). It turns out that none of the standard Swing components suit me completely, nor did the third-party Swing component libraries I've found out there. So I’ve decided to create my own Swing component.

Component description:

I want to extend JTextField or JFormattedTextField, so my new component can be easily bound to a BigDecimal variable.

The component will have customizable scale and length properties.

Behavior:

When the component is drawn, it shows only the decimal point and space for scale digits to its right.

When the component receives focus the caret should be positioned left to the decimal point. As the user types numbers (any other character is ignored) they appear to the left of the caret, only lengthscale numbers are accepted, any other number typed is ignored as the integer portion is full. Any time the user types the decimal point the caret moves to the right side of the decimal point. The following numbers typed are shown in the decimal part, only scale numbers are considered any other number typed is ignored as the decimal portion is full. Additionally, thousand separators should appear as the user types numbers left to the decimal point.

I also want to be able to use the component as a Cell Editor in a JTable (without having to code it twice).

Invoking a getValue() method on the component should yield the BigDecimal representing the number just entered.


I’ve never created my own Swing component; I’ve barely used the standard ones. So I would appreciate any good tutorial/info/tip on creating the component described. This is the only thing I've got so far.

Thanks in advance.


原文:https://stackoverflow.com/questions/2511270
更新时间:2021-05-22 20:05

最满意答案

  1. 运行git fsck --unreachable --no-progress以获取包含提交信息的行。
  2. Grep它只是提交, grep 'unreachable commit'
  3. 管道它来cut -d' ' -f3以获得提交它(第3个字段)。

把它们放在一起......

git fsck --unreachable --no-progress | grep 'unreachable commit' | cut -d' ' -f3

现在您有一个所有无法访问的提交列表。 把它放在一个文件中。

您可以在每个文件上运行git --no-pager log --format=oneline -n1 --stat <commit id> ,以查看它们更改了哪些文件。 这是一个小的Perl单行程来做到这一点。

perl -nwle 'system "git --no-pager log --format=oneline -n1 --stat $_"' <commit file>

您甚至可以通过grep“WIP”来查找旧的藏匿处。


  1. Run git fsck --unreachable --no-progress to get just the lines with the commit info.
  2. Grep it for just commits, grep 'unreachable commit'.
  3. Pipe it to cut -d' ' -f3 to get the commit it (the 3rd field).

Putting that all together...

git fsck --unreachable --no-progress | grep 'unreachable commit' | cut -d' ' -f3

Now you have a list of all the unreachable commits. Put that in a file.

You can run git --no-pager log --format=oneline -n1 --stat <commit id> on each of them to see what files they changed. Here's a little Perl one-liner to do that.

perl -nwle 'system "git --no-pager log --format=oneline -n1 --stat $_"' <commit file>

You can even grep for "WIP" to find old stashes.

相关问答

更多
  • 这不是用git fsck解决这个问题的答案,但是在这种情况下可能有效。 git reflog输出存储库中过去HEAD的列表。 例如,如果您从分支主机切换到分支开发,则会生成带有主分支HEAD的reflog条目。 因此,如果提交是某个分支的一部分,那么可以使用git reflog , git log和一些手动工作来恢复它。 有几种情况: 只需启动git reflog并滚动浏览它。 如果它显示你正在寻找的提交信息,那太棒了! 复制提交ID并将其用于任何你想要的(例如git cherry-pick ,或者使用gi ...
  • fsck有几个实现,具体取决于使用的文件系统。 对于ext2 / ext3 / ext4,您需要在Ubuntu中使用“e2fsprogs”包。 尝试: sudo apt-get source e2fsprogs fsck has several implementations depending on used file system. For ext2/ext3/ext4 you need "e2fsprogs" package in Ubuntu. Try: sudo apt-get source e ...
  • 没有输出,没什么悬垂(对吧?) 请注意,您的reflog引用的提交被认为是可达到的。 该承诺的状态究竟是什么? 如何列出所有类似状态的提交 通过--no-reflogs来说服git fsck向你显示。 如何删除这些提交? 一旦您的reflog条目过期,那么这些对象也将被git gc清理。 到期时间由gc.pruneexpire , gc.reflogexpire和gc.reflogexpireunreachable设置来规定。 参看 git help config 。 默认值都是非常合理的。 No outp ...
  • 实际上,我发现了! 那是refs / original / mybranch ref仍然保持我的提交可达。 这些原始引用是在git filter-branch期间创建的 git branch --all 不包括它们。 之所以我在开头找不到它们是因为它们在.git / refs / original文件夹中丢失了。 我在.git / packed-refs文件中找到了它们。 我刚刚从该文件中删除了那些分支并再次清理了存储库。 Actually, I found it! That is refs/origin ...
  • 你想要做的是: 使用普通文件复制命令将裸仓库复制到另一个文件夹。 将裸仓库副本转换为正常仓库 。 做你需要做的事情来找到你寻找的提交对象。 一旦找到,就在丢失的提交中创建一个新的分支。 将原始裸仓库添加为远程仓库。 将新分支推送到裸存储库。 What you want to do is: Copy the bare repo to another folder using normal file copy commands. Convert the bare repo copy to a normal re ...
  • 运行git fsck --unreachable --no-progress以获取包含提交信息的行。 Grep它只是提交, grep 'unreachable commit' 。 管道它来cut -d' ' -f3以获得提交它(第3个字段)。 把它们放在一起...... git fsck --unreachable --no-progress | grep 'unreachable commit' | cut -d' ' -f3 现在您有一个所有无法访问的提交列表。 把它放在一个文件中。 您可以在每个文件 ...
  • 1)做git show a0fc4f8仍然显示提交 这是设计的。 由于以下几个原因,不会立即删除无法访问的对象: 也许你错误地运行了最后一个命令(或提供了错误的参数),你意识到错误并希望回到之前的状态; 与完成操作所需的工作量相比,删除无法访问的对象(节省一些磁盘空间)的收益太小。 修剪无法访问的对象会不时自动执行。 它也是由一些git命令执行的( fetch和push是其中的一部分)。 2)执行git status显示通过提交a0fc4f8添加的file.txt为未跟踪,并且由commit f705657 ...
  • 看起来你的git服务器是可以访问的。 您正在使用SSH访问GIT仓库。 在这种情况下,您需要创建SSH密钥。 如果您这样做,请存储您的公钥 .ssh/authorized_keys 在你的Ubuntu机器上。 在Windows上,您可以使用Putty http://www.putty.org /创建SSH密钥 Looks like your git server is reachable. You are using SSH to access the GIT repo. In that case you ...
  • 那么只需将它添加到/etc/rc.conf : fsck_y_enable="YES" background_fsck="NO" 基本上,意味着运行fsck -y并且不要尝试在后台运行,因此根据磁盘的大小,这可能需要一段时间才能完成。 What about just add this to /etc/rc.conf: fsck_y_enable="YES" background_fsck="NO" Basically, means to run fsck -y and don't try to run ...
  • BP-929597290-192.0.0.2-1439573305237 这是Block Pool ID。 块池是属于单个名称空间的一组块。 为简单起见,您可以说名称节点管理的所有块都在同一个块池下。 Block Pool形成如下: String bpid = "BP-" + rand + "-"+ ip + "-" + Time.now(); Where: rand = Some random number ip = IP address of the Name Node Time.n ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。