Results 1 to 1 of 1
- 12-05-2007, 05:05 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 12
- Rep Power
- 0
menu inserting table in the document
this is menu for insert image in the document i create it....the problem with this menu is i can insert image inside the document but cannot save the image went i save the document. the image disappear by it self. the image also cannot resize using mouse pointer like in open office or micorosft word..any want able to make this code work????????plz..
Java Code:ItemInsertImage.setText(imagemenu); ItemInsertImage.setToolTipText("Masukkan Imej"); ItemInsertImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/thumbnail_tiny.png"))); ItemInsertImage.setComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT); ItemInsertImage.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { fc = new JFileChooser(); fc.addChoosableFileFilter(m_gifFilter); fc.addChoosableFileFilter(m_jpgFilter); fc.setDialogTitle("\u0645\u0627\u0633\u0648\u0642\u06A9\u0646\u0020\u0627\u064A\u0645\u064A\u062C"); fc.setComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT); fc.setFileFilter(m_gifFilter); fc.removeChoosableFileFilter(m_rtfFilter); Thread runner = new Thread() { public void run() { if (fc.showOpenDialog(OJMain.this) != JFileChooser.APPROVE_OPTION) return; OJMain.this.repaint(); File fChoosen = fc.getSelectedFile(); ImageIcon icon = new ImageIcon(fChoosen.getPath()); int w = icon.getIconWidth(); int h = icon.getIconHeight(); if (w<=0 || h<=0) { JOptionPane.showMessageDialog(OJMain.this,"\u0645\u0639\u0627\u0641,\u0020\u0641\u0627\u0674\u064A\u0644\u0020\u06AC\u0627\u0645\u0628\u0631\u0020\u06AC\u0627\u06AC\u0644\u0020\u062F\u0628\u0627\u0686.\n"+fChoosen.getPath(), error , JOptionPane.WARNING_MESSAGE); return; } MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setIcon(attr, icon); int p = tpOpenJawi.getCaretPosition(); try { m_doc.insertString(p, " ", attr); } catch (BadLocationException ex) {} // Its ok to do this outside of the event-dispatching // thread because the chooser is not visible here. fc.addChoosableFileFilter(m_rtfFilter); fc.setFileFilter(m_rtfFilter); fc.removeChoosableFileFilter(m_gifFilter); fc.removeChoosableFileFilter(m_jpgFilter); } }; runner.start(); } }); MenuTools.add(ItemInsertImage);
Similar Threads
-
how to create Popup Menu with Sub Menu while right-clicking the JTree Node??
By Kabiraa in forum AWT / SwingReplies: 7Last Post: 05-09-2008, 07:54 AM -
Inserting current date into a DB table
By Java Tip in forum Java TipReplies: 0Last Post: 02-15-2008, 08:38 AM -
Inserting into a table (Example)
By Java Tip in forum Java TipReplies: 0Last Post: 02-06-2008, 09:25 AM -
Inserting file in to database
By Java Tip in forum Java TipReplies: 0Last Post: 01-07-2008, 08:39 AM -
inserting bit value in sqlserver2000 using hibernate
By javadev in forum JDBCReplies: 0Last Post: 06-07-2007, 02:15 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks