我正在制作一个用Java编辑图像的程序.我想知道是否可以将图像从用户桌面拖到JPanel
图像上,然后将拖动的图像设置为背景JPanel
.这可能在Java中吗?如果是这样,我该怎么做?
这是我的代码:
public class DownloadMainView extends JFrame{
private ArrayList<DownloadItem> downloadList = new ArrayList<DownloadItem>();
private JMenuBar menubar = new JMenuBar();
private JMenu m_task = new JMenu("Tasks");
private JMenu m_tool = new JMenu("Tools");
private JMenu m_help = new JMenu("Help");
private JMenuItem mi_add = new JMenuItem("Add");
private JMenuItem mi_exit = new JMenuItem("Exit");
private JMenuItem mi_options = new JMenuItem("Options");
private JMenuItem mi_help = new JMenuItem("Help");
private JMenuItem mi_about = new JMenuItem("About");
private JTree categoryTree = new JTree();
private JTable contentTable = new JTable(new Object[][]{},new Object[]{"No.","Filename","URL","Status","Size","Added …
Run Code Online (Sandbox Code Playgroud) 我是Java世界的新手.我想添加Json lib来编译我的程序.我从这里下载了文件.
当我尝试编译程序时
javac -classpath json.jar MyClassName.java
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Note: JsonSimpleExample.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
当我试图跑:
java MyClassName
Run Code Online (Sandbox Code Playgroud)
我越来越:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
at MyClassName.main(MyClassName.java:9)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
Run Code Online (Sandbox Code Playgroud)
我在哪里弄错了?
我正在尝试编写代码,以便当用户单击"文件"选项卡并选择"退出"时,它会退出我构建的整个窗口.
我正在尝试使用该dispose();
方法,但它给了我错误"方法dispose()未定义类型new ActionListener()"
继承人的代码
public static void addLayouts(){
frame = new JFrame();
frame.setSize(600, 600);
frame.setTitle("IPFinder");
GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGap(0, 384, Short.MAX_VALUE)
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGap(0, 362, Short.MAX_VALUE)
);
frame.getContentPane().setLayout(groupLayout);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu mnFile = new JMenu("File");
menuBar.add(mnFile);
JMenu mnEdit = new JMenu("Edit");
menuBar.add(mnEdit);
JMenuItem mntmCopyResults = new JMenuItem("Copy Results");
mnEdit.add(mntmCopyResults);
JMenu mnAbout = new JMenu("About");
menuBar.add(mnAbout);
JMenuItem mntmAboutIpfinder = new JMenuItem("About IPFinder");
mnAbout.add(mntmAboutIpfinder);
frame.setVisible(true);
JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.addActionListener(new …
Run Code Online (Sandbox Code Playgroud) 我在hashMap中研究了我的键的位置.示例:
Run Code Online (Sandbox Code Playgroud)HashMap<Integer, String> ht = new HashMap(); ht.put(1, "c"); ht.put(10, "b"); ht.put(8, "r"); System.out.println(ht);
10位有3位HashMap
,8位有2位...
所以我有两个问题:
环顾四周,但找不到任何可以解释如何执行以下操作的内容:
Object rowData[] = { "Row1-Column1", "Row1-Column2", "Row1-Column3" };
Object columnNames[] = { "Column One", "Column Two", "Column Three" };
Run Code Online (Sandbox Code Playgroud)
我已经用编辑器制作了一个表格,名称:“jTable1”。