List of usage examples for javax.swing JPanel setTransferHandler
@BeanProperty(hidden = true, description = "Mechanism for transfer of data to and from the component") public void setTransferHandler(TransferHandler newHandler)
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Creates the content.// w w w.j a va2 s.co m */ private void createContent() { this.tabs = new JTabbedPane(); this.tabs.setPreferredSize(new Dimension(640, 480)); this.tabs.addChangeListener(this); this.tabs.setTransferHandler(this.transferHandler); final JPanel welcomePanel = this.welcomePanel = new JPanel(); welcomePanel.setTransferHandler(this.transferHandler); welcomePanel.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); welcomePanel.setPreferredSize(new Dimension(640, 480)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); c.anchor = GridBagConstraints.CENTER; welcomePanel.add(buttonPanel, c); final JButton newButton = new JButton(this.newAction); newButton.setHorizontalAlignment(SwingConstants.LEFT); newButton.setIconTextGap(10); newButton.setText("<html><body><strong>" + newButton.getText() + "</strong><br />" + newButton.getToolTipText() + "</body></html>"); newButton.setToolTipText(null); newButton.setMargin(new Insets(5, 10, 5, 10)); c.gridy = 0; c.fill = GridBagConstraints.BOTH; c.insets.set(5, 5, 5, 5); buttonPanel.add(newButton, c); final JButton openButton = new JButton(this.openAction); openButton.setHorizontalAlignment(SwingConstants.LEFT); openButton.setIconTextGap(10); openButton.setText("<html><body><strong>" + openButton.getText() + "</strong><br />" + openButton.getToolTipText() + "</body></html>"); openButton.setToolTipText(null); openButton.setMargin(new Insets(5, 10, 5, 10)); c.gridy++; buttonPanel.add(openButton, c); final JPanel separator = new JPanel(); separator.setPreferredSize(new Dimension(20, 20)); c.gridy++; buttonPanel.add(separator, c); final JButton donateButton = new JButton(this.donateAction); donateButton.setHorizontalAlignment(SwingConstants.LEFT); donateButton.setIconTextGap(10); donateButton.setText("<html><body><strong>" + donateButton.getText() + "</strong><br />" + donateButton.getToolTipText() + "</body></html>"); donateButton.setToolTipText(null); donateButton.setMargin(new Insets(5, 10, 5, 10)); c.gridy++; buttonPanel.add(donateButton, c); final SocialPane socialPane = new SocialPane(); c.insets.top = 50; c.gridy++; buttonPanel.add(socialPane, c); installStatusHandler(buttonPanel); add(welcomePanel, BorderLayout.CENTER); }
From source file:processing.app.Editor.java
public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception { super("Arduino"); this.base = ibase; this.platform = platform; Base.setIcon(this); // Install default actions for Run, Present, etc. resetHandlers();/*from ww w . ja v a 2s .co m*/ // add listener to handle window close box hit event addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { base.handleClose(Editor.this); } }); // don't close the window when clicked, the app will take care // of that via the handleQuitInternal() methods // http://dev.processing.org/bugs/show_bug.cgi?id=440 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // When bringing a window to front, let the Base know addWindowListener(new WindowAdapter() { public void windowActivated(WindowEvent e) { base.handleActivated(Editor.this); } // added for 1.0.5 // http://dev.processing.org/bugs/show_bug.cgi?id=1260 public void windowDeactivated(WindowEvent e) { fileMenu.remove(sketchbookMenu); fileMenu.remove(examplesMenu); List<Component> toolsMenuItemsToRemove = new LinkedList<Component>(); for (Component menuItem : toolsMenu.getMenuComponents()) { if (menuItem instanceof JComponent) { Object removeOnWindowDeactivation = ((JComponent) menuItem) .getClientProperty("removeOnWindowDeactivation"); if (removeOnWindowDeactivation != null && Boolean.valueOf(removeOnWindowDeactivation.toString())) { toolsMenuItemsToRemove.add(menuItem); } } } for (Component menuItem : toolsMenuItemsToRemove) { toolsMenu.remove(menuItem); } toolsMenu.remove(serialMenu); } }); //PdeKeywords keywords = new PdeKeywords(); //sketchbook = new Sketchbook(this); buildMenuBar(); // For rev 0120, placing things inside a JPanel Container contentPain = getContentPane(); contentPain.setLayout(new BorderLayout()); JPanel pain = new JPanel(); pain.setLayout(new BorderLayout()); contentPain.add(pain, BorderLayout.CENTER); Box box = Box.createVerticalBox(); Box upper = Box.createVerticalBox(); if (toolbarMenu == null) { toolbarMenu = new JMenu(); base.rebuildToolbarMenu(toolbarMenu); } toolbar = new EditorToolbar(this, toolbarMenu); upper.add(toolbar); header = new EditorHeader(this); upper.add(header); textarea = createTextArea(); textarea.setName("editor"); // assemble console panel, consisting of status area and the console itself consolePanel = new JPanel(); consolePanel.setLayout(new BorderLayout()); status = new EditorStatus(this); consolePanel.add(status, BorderLayout.NORTH); console = new EditorConsole(this); console.setName("console"); // windows puts an ugly border on this guy console.setBorder(null); consolePanel.add(console, BorderLayout.CENTER); lineStatus = new EditorLineStatus(); consolePanel.add(lineStatus, BorderLayout.SOUTH); // RTextScrollPane scrollPane = new RTextScrollPane(textarea, true); scrollPane.setBorder(new MatteBorder(0, 6, 0, 0, Theme.getColor("editor.bgcolor"))); scrollPane.setViewportBorder(BorderFactory.createEmptyBorder()); scrollPane.setLineNumbersEnabled(PreferencesData.getBoolean("editor.linenumbers")); scrollPane.setIconRowHeaderEnabled(false); Gutter gutter = scrollPane.getGutter(); gutter.setBookmarkingEnabled(false); //gutter.setBookmarkIcon(CompletionsRenderer.getIcon(CompletionType.TEMPLATE)); gutter.setIconRowHeaderInheritsGutterBackground(true); upper.add(scrollPane); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, consolePanel); splitPane.setOneTouchExpandable(true); // repaint child panes while resizing splitPane.setContinuousLayout(true); // if window increases in size, give all of increase to // the textarea in the uppper pane splitPane.setResizeWeight(1D); // to fix ugliness.. normally macosx java 1.3 puts an // ugly white border around this object, so turn it off. splitPane.setBorder(null); // the default size on windows is too small and kinda ugly int dividerSize = PreferencesData.getInteger("editor.divider.size"); if (dividerSize != 0) { splitPane.setDividerSize(dividerSize); } // the following changed from 600, 400 for netbooks // http://code.google.com/p/arduino/issues/detail?id=52 splitPane.setMinimumSize(new Dimension(600, 100)); box.add(splitPane); // hopefully these are no longer needed w/ swing // (har har har.. that was wishful thinking) // listener = new EditorListener(this, textarea); pain.add(box); // get shift down/up events so we can show the alt version of toolbar buttons textarea.addKeyListener(toolbar); pain.setTransferHandler(new FileDropHandler()); // System.out.println("t1"); // Finish preparing Editor (formerly found in Base) pack(); // System.out.println("t2"); // Set the window bounds and the divider location before setting it visible setPlacement(location); // Set the minimum size for the editor window setMinimumSize(new Dimension(PreferencesData.getInteger("editor.window.width.min"), PreferencesData.getInteger("editor.window.height.min"))); // System.out.println("t3"); // Bring back the general options for the editor applyPreferences(); // System.out.println("t4"); // Open the document that was passed in boolean loaded = handleOpenInternal(file); if (!loaded) sketch = null; // System.out.println("t5"); // All set, now show the window //setVisible(true); }