private void initComponents() { setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); messagePane.setBackground(contentPane.getBackground()); messagePane.setEditorKit(new HTMLEditorKit()); messagePane.setForeground(contentPane.getForeground()); setSize(450, 360); // center the window int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2; int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2; setLocation(x, y); okButton.addActionListener(this); }
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Windows Form * Designer. Otherwise, retrieving design might not work properly. Tip: If you must revise this * method, please backup this GUI file for JFrameBuilder to retrieve your design properly in * future, before revising this method. */ private void initializeComponent() { jLabel1 = new JLabel(); jLabel2 = new JLabel(); jLabel3 = new JLabel(); jLabel4 = new JLabel(); jLabel5 = new JLabel(); jLabel6 = new JLabel("Pets"); jLabel7 = new JLabel("Drinking"); jLabel8 = new JLabel("Smoking"); jButton1 = new JButton("Back"); passion = new JEditorPane(); passion1 = new JScrollPane(); books = new JEditorPane(); books1 = new JScrollPane(); movies = new JEditorPane(); movies1 = new JScrollPane(); /* jTextField1 = new JTextField(); jTextField2 = new JTextField(); jTextField3 = new JTextField(); */ jTextField4 = new JTextField(); jTextField5 = new JTextField(); jTextField6 = new JTextField(); jTextField7 = new JTextField(); jTextField8 = new JTextField(); passion1.setViewportView(passion); books1.setViewportView(books); movies1.setViewportView(movies); contentPane = (JPanel) this.getContentPane(); // set editable false passion.setEditable(false); books.setEditable(false); movies.setEditable(false); jTextField4.setEditable(false); jTextField5.setEditable(false); jTextField6.setEditable(false); jTextField7.setEditable(false); jTextField8.setEditable(false); // // jLabel1 // jLabel1.setText("Passion"); // // jLabel2 // jLabel2.setText("Books"); // // jLabel3 // jLabel3.setText("Movies"); // // jLabel4 // jLabel4.setText("Living"); // // jLabel5 // jLabel5.setText("Fashion"); // // jTextField1 // /* jTextField1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField1_actionPerformed(e); } }); // // jTextField2 // jTextField2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField2_actionPerformed(e); } }); // // jTextField3 // jTextField3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField3_actionPerformed(e); } }); */ // // jTextField4 // jTextField4.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField4_actionPerformed(e); } }); // // jTextField5 // jTextField5.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField5_actionPerformed(e); } }); jButton1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); // // contentPane // contentPane.setLayout(null); contentPane.setBackground(new Color(158, 168, 237)); addComponent(contentPane, jLabel1, 36, 97, 86, 26); addComponent(contentPane, jLabel2, 34, 238, 60, 18); addComponent(contentPane, jLabel3, 33, 373, 60, 18); addComponent(contentPane, jLabel4, 31, 440, 60, 18); addComponent(contentPane, jLabel5, 30, 484, 60, 18); addComponent(contentPane, jLabel6, 30, 527, 60, 18); addComponent(contentPane, jLabel7, 30, 567, 60, 18); addComponent(contentPane, jLabel8, 30, 612, 60, 18); addComponent(contentPane, passion1, 237, 59, 350, 96); addComponent(contentPane, books1, 236, 189, 350, 96); addComponent(contentPane, movies1, 236, 320, 350, 98); addComponent(contentPane, jTextField4, 237, 440, 350, 22); addComponent(contentPane, jTextField5, 237, 484, 350, 22); addComponent(contentPane, jTextField6, 237, 527, 350, 22); addComponent(contentPane, jTextField7, 237, 567, 350, 22); addComponent(contentPane, jTextField8, 237, 612, 350, 22); addComponent(contentPane, jButton1, 456, 654, 74, 25); // // viewprofile1 // passion.setBackground(new Color(161, 247, 241)); books.setBackground(new Color(244, 195, 103)); movies.setBackground(new Color(239, 122, 247)); jTextField4.setBackground(new Color(161, 247, 241)); jTextField5.setBackground(new Color(244, 195, 103)); jTextField6.setBackground(new Color(239, 122, 247)); jTextField7.setBackground(new Color(161, 247, 241)); jTextField8.setBackground(new Color(244, 195, 103)); this.setTitle("viewprofile1 - extends JFrame"); this.setLocation(new Point(0, 0)); this.setSize(new Dimension(1024, 768)); }
public DocumentationComponent( final DocumentationManager manager, final AnAction[] additionalActions) { myManager = manager; myIsEmpty = true; myIsShown = false; myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "") { @Override public Dimension getPreferredScrollableViewportSize() { if (getWidth() == 0 || getHeight() == 0) { setSize(MAX_WIDTH, MAX_HEIGHT); } Insets ins = myEditorPane.getInsets(); View rootView = myEditorPane.getUI().getRootView(myEditorPane); rootView.setSize( MAX_WIDTH, MAX_HEIGHT); // Necessary! Without this line, size will not increase then you go // from small page to bigger one int prefHeight = (int) rootView.getPreferredSpan(View.Y_AXIS); prefHeight += ins.bottom + ins.top + myScrollPane.getHorizontalScrollBar().getMaximumSize().height; return new Dimension(MAX_WIDTH, Math.max(MIN_HEIGHT, Math.min(MAX_HEIGHT, prefHeight))); } { enableEvents(AWTEvent.KEY_EVENT_MASK); } @Override protected void processKeyEvent(KeyEvent e) { KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e); ActionListener listener = myKeyboardActions.get(keyStroke); if (listener != null) { listener.actionPerformed(new ActionEvent(DocumentationComponent.this, 0, "")); e.consume(); return; } super.processKeyEvent(e); } @Override protected void paintComponent(Graphics g) { GraphicsUtil.setupAntialiasing(g); super.paintComponent(g); } }; DataProvider helpDataProvider = new DataProvider() { @Override public Object getData(@NonNls String dataId) { return PlatformDataKeys.HELP_ID.is(dataId) ? DOCUMENTATION_TOPIC_ID : null; } }; myEditorPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider); myText = ""; myEditorPane.setEditable(false); myEditorPane.setBackground(HintUtil.INFORMATION_COLOR); myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit()); myScrollPane = new JBScrollPane(myEditorPane) { @Override protected void processMouseWheelEvent(MouseWheelEvent e) { if (!EditorSettingsExternalizable.getInstance().isWheelFontChangeEnabled() || !EditorUtil.isChangeFontSize(e)) { super.processMouseWheelEvent(e); return; } int change = Math.abs(e.getWheelRotation()); boolean increase = e.getWheelRotation() <= 0; EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); FontSize newFontSize = scheme.getQuickDocFontSize(); for (; change > 0; change--) { if (increase) { newFontSize = newFontSize.larger(); } else { newFontSize = newFontSize.smaller(); } } if (newFontSize == scheme.getQuickDocFontSize()) { return; } scheme.setQuickDocFontSize(newFontSize); applyFontSize(); setFontSizeSliderSize(newFontSize); } }; myScrollPane.setBorder(null); myScrollPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider); final MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { myManager.requestFocus(); myShowSettingsButton.hideSettings(); } }; myEditorPane.addMouseListener(mouseAdapter); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeMouseListener(mouseAdapter); } }); final FocusAdapter focusAdapter = new FocusAdapter() { @Override public void focusLost(FocusEvent e) { Component previouslyFocused = WindowManagerEx.getInstanceEx() .getFocusedComponent(manager.getProject(getElement())); if (!(previouslyFocused == myEditorPane)) { if (myHint != null && !myHint.isDisposed()) myHint.cancel(); } } }; myEditorPane.addFocusListener(focusAdapter); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeFocusListener(focusAdapter); } }); setLayout(new BorderLayout()); JLayeredPane layeredPane = new JBLayeredPane() { @Override public void doLayout() { final Rectangle r = getBounds(); for (Component component : getComponents()) { if (component instanceof JScrollPane) { component.setBounds(0, 0, r.width, r.height); } else { int insets = 2; Dimension d = component.getPreferredSize(); component.setBounds(r.width - d.width - insets, insets, d.width, d.height); } } } @Override public Dimension getPreferredSize() { Dimension editorPaneSize = myEditorPane.getPreferredScrollableViewportSize(); Dimension controlPanelSize = myControlPanel.getPreferredSize(); return new Dimension( Math.max(editorPaneSize.width, controlPanelSize.width), editorPaneSize.height + controlPanelSize.height); } }; layeredPane.add(myScrollPane); layeredPane.setLayer(myScrollPane, 0); mySettingsPanel = createSettingsPanel(); layeredPane.add(mySettingsPanel); layeredPane.setLayer(mySettingsPanel, JLayeredPane.POPUP_LAYER); add(layeredPane, BorderLayout.CENTER); setOpaque(true); myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder()); final DefaultActionGroup actions = new DefaultActionGroup(); final BackAction back = new BackAction(); final ForwardAction forward = new ForwardAction(); actions.add(back); actions.add(forward); actions.add(myExternalDocAction = new ExternalDocAction()); back.registerCustomShortcutSet(CustomShortcutSet.fromString("LEFT"), this); forward.registerCustomShortcutSet(CustomShortcutSet.fromString("RIGHT"), this); myExternalDocAction.registerCustomShortcutSet(CustomShortcutSet.fromString("UP"), this); if (additionalActions != null) { for (final AnAction action : additionalActions) { actions.add(action); } } myToolBar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true); myControlPanel = new JPanel(); myControlPanel.setLayout(new BorderLayout()); myControlPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); JPanel dummyPanel = new JPanel(); myElementLabel = new JLabel(); dummyPanel.setLayout(new BorderLayout()); dummyPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); dummyPanel.add(myElementLabel, BorderLayout.EAST); myControlPanel.add(myToolBar.getComponent(), BorderLayout.WEST); myControlPanel.add(dummyPanel, BorderLayout.CENTER); myControlPanel.add(myShowSettingsButton = new MyShowSettingsButton(), BorderLayout.EAST); myControlPanelVisible = false; final HyperlinkListener hyperlinkListener = new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { HyperlinkEvent.EventType type = e.getEventType(); if (type == HyperlinkEvent.EventType.ACTIVATED) { manager.navigateByLink(DocumentationComponent.this, e.getDescription()); } } }; myEditorPane.addHyperlinkListener(hyperlinkListener); Disposer.register( this, new Disposable() { @Override public void dispose() { myEditorPane.removeHyperlinkListener(hyperlinkListener); } }); registerActions(); updateControlState(); }