0
我試圖製作一個java swing面板,您可以在其中拖放圖像。並保存面板上顯示的圖像。 我發現this,我認爲這對我很有幫助。 但在我的電腦與Windows 7無法正常工作。我無法將圖像拖到應用程序中。我將不勝感激任何建議。感謝用於拖放圖像文件的面板,使用java swing
我試圖製作一個java swing面板,您可以在其中拖放圖像。並保存面板上顯示的圖像。 我發現this,我認爲這對我很有幫助。 但在我的電腦與Windows 7無法正常工作。我無法將圖像拖到應用程序中。我將不勝感激任何建議。感謝用於拖放圖像文件的面板,使用java swing
法則一,不亂用的東西,你不明白;)
法則二,僞造它,直到你把它;)
與更換initComponents
方法...
private void initComponents() {
listScroller = new javax.swing.JScrollPane();
imageList = new JList();
imageList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
imageList.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP);
imageList.setVisibleRowCount(-1);
listScroller.setViewportView(imageList);
setLayout(new BorderLayout());
add(listScroller);
}// </editor-fold>//GEN-END:initComponents
在GlassPaneDragAndDrop
構造,以取代 「降窗格」 的paintComponent
方法...
setContentPane(new JPanel(new BorderLayout()) {
private BufferedImage image = null;
@Override
public boolean isOpaque() {
return imageList.getModel().getSize() > 0;
}
@Override
protected void paintComponent(Graphics g) {
Rectangle clip = g.getClipBounds();
g.setColor(Color.WHITE);
g.fillRect(clip.x, clip.y, clip.width, clip.height);
}
});
這將允許它運行。在Windows 7下,雖然你可能不喜歡這個結果,但是......
謝謝,對不起我的愚蠢,但我不能這樣做。 – user60108 2013-02-28 06:32:12
你是什麼意思,你「不能走這些變化」? – MadProgrammer 2013-02-28 19:20:02
仍然無法正常工作。對不起,我的英文 – user60108 2013-03-01 04:07:14