如何访问JPanel?
我试图在 SingleFrameApplication 的 JPanel 中绘制一个简单的指针,0..360 度。 我使用的是 NetBeans IDE 6.9.1,因为它有一个很好的 Swing 容器、控件、菜单等调色板。 我希望 DrawPointer 接口是这样的,因为会有多个 [指针]:
DrawPointer(JPanel panel, double degrees);
但是 JPanel 被 IDE 生成的代码声明为私有,如下所示:
public class MyView extends FrameView {
public MyView(SingleFrameApplication app) {
super(app);
initComponents();
...
private void initComponents() {
...
private javax.swing.JPanel jPanelA;
...
How do I access the JPanel to draw in it if it is private ?
I am trying to draw a simple pointer, 0..360 degrees, in a JPanel on a SingleFrameApplication.
I am using NetBeans IDE 6.9.1 since it has a nice Palette of Swing Containers, Controls, Menus, etc.
I'd like the DrawPointer interface to be something like this since there will be more than one [pointer]:
DrawPointer(JPanel panel, double degrees);
but the JPanel is declared private by IDE generated code like this:
public class MyView extends FrameView {
public MyView(SingleFrameApplication app) {
super(app);
initComponents();
...
private void initComponents() {
...
private javax.swing.JPanel jPanelA;
...
How do I access the JPanel to draw in it if it is private?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您唯一关心的是
private
,您可以在 netbeans 中更改它,If that being
private
is your sole concern, you can change that in netbeans ,您向
MyView
类添加一个返回jPanelA
的方法(就此而言,可能已经有这样的方法,您检查过自动生成的代码吗?)you add a method to your
MyView
class which returnsjPanelA
(for that matter there could already be a method like that, have you checked the autogenerated code?)