List of usage examples for javax.swing JInternalFrame putClientProperty
public final void putClientProperty(Object key, Object value)
From source file:InternalFramePaletteSample.java
public static void main(final String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);/*from w w w.ja v a2 s.c om*/ frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true);//from w ww . j av a2 s. c o m frame.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:DesktopSample.java
public static void main(String[] args) { String title = "Desktop Sample"; JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktop = new JDesktopPane(); JInternalFrame internalFrames[] = { new JInternalFrame("Can Do All", true, true, true, true), new JInternalFrame("Not Resizable", false, true, true, true), new JInternalFrame("Not Closable", true, false, true, true), new JInternalFrame("Not Maximizable", true, true, false, true), new JInternalFrame("Not Iconifiable", true, true, true, false) }; InternalFrameListener internalFrameListener = new InternalFrameIconifyListener(); for (int i = 0, n = internalFrames.length; i < n; i++) { desktop.add(internalFrames[i]);// w ww . j ava 2 s . c o m internalFrames[i].setBounds(i * 25, i * 25, 200, 100); internalFrames[i].addInternalFrameListener(internalFrameListener); JLabel label = new JLabel(internalFrames[i].getTitle(), JLabel.CENTER); Container content = internalFrames[i].getContentPane(); content.add(label, BorderLayout.CENTER); internalFrames[i].setVisible(true); } JInternalFrame palette = new JInternalFrame("Palette", true, false, true, false); palette.setBounds(350, 150, 100, 100); palette.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); desktop.add(palette, JDesktopPane.PALETTE_LAYER); palette.setVisible(true); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); Container content = frame.getContentPane(); content.add(desktop, BorderLayout.CENTER); frame.setSize(500, 300); frame.setVisible(true); }
From source file:GUIUtils.java
/** * Make the passed internal frame a Tool Window. *//* w w w.j av a2 s . co m*/ public static void makeToolWindow(JInternalFrame frame, boolean isToolWindow) { if (frame == null) { throw new IllegalArgumentException("null JInternalFrame passed"); } frame.putClientProperty("JInternalFrame.isPalette", isToolWindow ? Boolean.TRUE : Boolean.FALSE); }
From source file:org.docx4all.ui.main.WordMLEditor.java
public void createInternalFrame(FileObject f) { if (f == null) { return;//ww w. ja v a 2 s . c o m } log.info(VFSUtils.getFriendlyName(f.getName().getURI())); JInternalFrame iframe = _iframeMap.get(f.getName().getURI()); if (iframe != null) { iframe.setVisible(true); } else { iframe = new JInternalFrame(f.getName().getBaseName(), true, true, true, true); iframe.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); iframe.addInternalFrameListener(_internalFrameListener); iframe.addInternalFrameListener(_toolbarStates); iframe.addPropertyChangeListener(WindowMenu.getInstance()); if (iframe.getUI() instanceof BasicInternalFrameUI) { BasicInternalFrameUI ui = (BasicInternalFrameUI) iframe.getUI(); javax.swing.JComponent northPane = ui.getNorthPane(); if (northPane == null) { // Happens on Mac OSX: Google for "osx java getNorthPane" // Fix is from it.businesslogic.ireport.gui.JMDIFrame javax.swing.plaf.basic.BasicInternalFrameUI aUI = new javax.swing.plaf.basic.BasicInternalFrameUI( iframe); iframe.setUI(aUI); // Try again ui = (BasicInternalFrameUI) iframe.getUI(); northPane = ((javax.swing.plaf.basic.BasicInternalFrameUI) ui).getNorthPane(); } northPane.addMouseMotionListener(_titleBarMouseListener); } JEditorPane editorView = createEditorView(f); JPanel panel = FxScriptUIHelper.getInstance().createEditorPanel(editorView); iframe.getContentPane().add(panel); iframe.pack(); _desktop.add(iframe); editorView.requestFocusInWindow(); editorView.select(0, 0); String filePath = f.getName().getURI(); iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, filePath); _iframeMap.put(filePath, iframe); iframe.show(); } try { iframe.setSelected(true); iframe.setIcon(false); iframe.setMaximum(true); } catch (PropertyVetoException exc) { // do nothing } }
From source file:org.docx4all.ui.main.WordMLEditor.java
public void updateInternalFrame(FileObject oldFile, FileObject newFile) { if (oldFile.equals(newFile)) { return;/* w w w.jav a 2 s . c om*/ } String fileUri = oldFile.getName().getURI(); JInternalFrame iframe = _iframeMap.remove(fileUri); if (iframe != null) { fileUri = newFile.getName().getURI(); iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, fileUri); iframe.setTitle(newFile.getName().getBaseName()); } }
From source file:org.docx4all.ui.menu.FileMenu.java
/** * Saves editor documents to a file.//w w w . j a va 2s . c o m * * Internal frame may have two editors for presenting two different views * to user namely editor view and source view. WordMLTextPane is used for * editor view and JEditorPane for source view. * The contents of these two editors are synchronized when user switches * from one view to the other. Therefore, there will be ONLY ONE editor * that is dirty and has to be saved by this method. * * @param iframe * @param saveAsFilePath * @param callerActionName * @return */ public boolean save(JInternalFrame iframe, String saveAsFilePath, String callerActionName) { boolean success = true; if (saveAsFilePath == null) { saveAsFilePath = (String) iframe.getClientProperty(WordMLDocument.FILE_PATH_PROPERTY); } if (log.isDebugEnabled()) { log.debug("save(): filePath=" + VFSUtils.getFriendlyName(saveAsFilePath)); } WordMLTextPane editorView = SwingUtil.getWordMLTextPane(iframe); JEditorPane sourceView = SwingUtil.getSourceEditor(iframe); if (sourceView != null && !((Boolean) sourceView.getClientProperty(Constants.LOCAL_VIEWS_SYNCHRONIZED_FLAG)) .booleanValue()) { //signifies that Source View is not synchronised with Editor View yet. //Therefore, it is dirty and has to be saved. if (editorView != null && editorView.getWordMLEditorKit().getPlutextClient() != null) { //Document has to be saved from editor view //by committing local edits success = false; } else { EditorKit kit = sourceView.getEditorKit(); Document doc = sourceView.getDocument(); WordprocessingMLPackage wmlPackage = (WordprocessingMLPackage) doc .getProperty(WordMLDocument.WML_PACKAGE_PROPERTY); DocUtil.write(kit, doc, wmlPackage); success = save(wmlPackage, saveAsFilePath, callerActionName); if (success) { if (saveAsFilePath.endsWith(Constants.DOCX_STRING) || saveAsFilePath.endsWith(Constants.FLAT_OPC_STRING)) { doc.putProperty(WordMLDocument.FILE_PATH_PROPERTY, saveAsFilePath); iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, saveAsFilePath); } } } return success; } sourceView = null; if (editorView == null) { ;//pass } else if (editorView.getWordMLEditorKit().getPlutextClient() != null) { if (saveAsFilePath.equals(editorView.getDocument().getProperty(WordMLDocument.FILE_PATH_PROPERTY))) { success = commitLocalChanges(editorView, callerActionName); } else { //TODO: Enable saving Plutext document as a new file. WordMLEditor wmlEditor = WordMLEditor.getInstance(WordMLEditor.class); ResourceMap rm = wmlEditor.getContext().getResourceMap(getClass()); String title = rm.getString(callerActionName + ".Action.text"); StringBuilder message = new StringBuilder(); message.append("File "); message.append(saveAsFilePath); message.append(Constants.NEWLINE); message.append(rm.getString(callerActionName + ".Action.wrong.fileName.infoMessage")); wmlEditor.showMessageDialog(title, message.toString(), JOptionPane.INFORMATION_MESSAGE); success = false; } } else { WordMLEditorKit kit = (WordMLEditorKit) editorView.getEditorKit(); kit.saveCaretText(); Document doc = editorView.getDocument(); DocumentElement elem = (DocumentElement) doc.getDefaultRootElement(); DocumentML rootML = (DocumentML) elem.getElementML(); //Do not include the last paragraph when saving. //After saving we put it back. elem = (DocumentElement) elem.getElement(elem.getElementCount() - 1); ElementML paraML = elem.getElementML(); ElementML bodyML = paraML.getParent(); paraML.delete(); success = save(rootML.getWordprocessingMLPackage(), saveAsFilePath, callerActionName); //Remember to put 'paraML' as last paragraph bodyML.addChild(paraML); if (success) { if (saveAsFilePath.endsWith(Constants.DOCX_STRING)) { doc.putProperty(WordMLDocument.FILE_PATH_PROPERTY, saveAsFilePath); iframe.putClientProperty(WordMLDocument.FILE_PATH_PROPERTY, saveAsFilePath); } } } return success; }