Java 类javax.swing.JLayer 实例源码

项目:me3modmanager    文件:StarterKitWindow.java   
@Override
public void paint(Graphics g, JComponent c) {
    super.paint(g, c);

    JLayer jlayer = (JLayer) c;
    JFormattedTextField ftf = (JFormattedTextField) jlayer.getView();
    if (!ftf.isEditValid()) {
        Graphics2D g2 = (Graphics2D) g.create();

        // Paint the red X.
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        int w = c.getWidth();
        int h = c.getHeight();
        int s = 8;
        int pad = 4;
        int x = w - pad - s;
        int y = (h - s) / 2;
        g2.setPaint(Color.red);
        g2.fillRect(x, y, s + 1, s + 1);
        g2.setPaint(Color.white);
        g2.drawLine(x, y, x + s, y + s);
        g2.drawLine(x, y + s, x + s, y);

        g2.dispose();
    }
}
项目:sp16-ceg3120    文件:CloseableTabbedPaneLayer.java   
@Override
public void paint(Graphics gr, JComponent jc) {
    super.paint(gr, jc);
    if (jc instanceof JLayer<?>) {
        JLayer<?> jlayer = (JLayer<?>) jc;
        JTabbedPane tabPane =  (JTabbedPane) jlayer.getView();
        for (int i = 0; i < tabPane.getTabCount(); i++) {
            Rectangle rect = tabPane.getBoundsAt(i);
            Dimension dim = button.getPreferredSize();
            int x0 = rect.x + rect.width - dim.width - 2;
            int y0 = rect.y + (rect.height - dim.height) / 2;
            Rectangle r2 = new Rectangle(x0, y0, dim.width, dim.height);
            button.setForeground(r2.contains(pt) ? Color.RED : Color.BLACK);
            SwingUtilities.paintComponent(gr, button, p0, r2);
        }
    }
}
项目:sp16-ceg3120    文件:CloseableTabbedPaneLayer.java   
@Override
protected void processMouseEvent(MouseEvent event, JLayer<? extends JTabbedPane> jl) {
    if (event.getID() == MouseEvent.MOUSE_CLICKED) {
        pt.setLocation(event.getPoint());
        JTabbedPane tabbedPane = (JTabbedPane) jl.getView();
        int index = tabbedPane.indexAtLocation(pt.x, pt.y);
        if (index >= 0) {
            Rectangle rect = tabbedPane.getBoundsAt(index);
            Dimension d0 = button.getPreferredSize();
            int x0 = rect.x + rect.width - d0.width - 2;
            int y0 = rect.y + (rect.height - d0.height) / 2;
            Rectangle r0 = new Rectangle(x0, y0, d0.width, d0.height);
            if (r0.contains(pt)) {
                tabbedPane.removeTabAt(index);
            }
        }
        jl.getView().repaint();
    }
}
项目:rapidminer    文件:CardCellRenderer.java   
/**
 * Creates a {@link CardCellRenderer} that is used by lists containing {@link Card}s.
 */
public CardCellRenderer() {
    setVerticalTextPosition(SwingConstants.BOTTOM);
    setHorizontalTextPosition(SwingConstants.CENTER);
    setHorizontalAlignment(CENTER);
    setOpaque(false);
    layer = new JLayer<>(this, new CardLayerUI());
}
项目:rapidminer-studio    文件:CardCellRenderer.java   
/**
 * Creates a {@link CardCellRenderer} that is used by lists containing {@link Card}s.
 */
public CardCellRenderer() {
    setVerticalTextPosition(SwingConstants.BOTTOM);
    setHorizontalTextPosition(SwingConstants.CENTER);
    setHorizontalAlignment(CENTER);
    setOpaque(false);
    layer = new JLayer<>(this, new CardLayerUI());
}
项目:mars-sim    文件:SpotlightLayerUI.java   
@Override
public void installUI(JComponent c) {
  super.installUI(c);

  JLayer jlayer = (JLayer)c;
  jlayer.setLayerEventMask(
    AWTEvent.MOUSE_EVENT_MASK |
    AWTEvent.MOUSE_MOTION_EVENT_MASK
  );


}
项目:mars-sim    文件:SpotlightLayerUI.java   
@Override
protected void processMouseMotionEvent(MouseEvent e, JLayer l) {
  Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), l);
  mX = p.x;
  mY = p.y;
  l.repaint();
}
项目:sp16-ceg3120    文件:CloseableTabbedPaneLayer.java   
@Override
public void installUI(JComponent jc) {
    super.installUI(jc);
    if (jc instanceof JLayer<?>) {
        ((JLayer<?>) jc).setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK 
                | AWTEvent.MOUSE_MOTION_EVENT_MASK);
    }
}
项目:sp16-ceg3120    文件:CloseableTabbedPaneLayer.java   
@Override
public void uninstallUI(JComponent comp) {
    if (comp instanceof JLayer<?>) {
        ((JLayer<?>) comp).setLayerEventMask(0);
        super.uninstallUI(comp);
    }
}
项目:sp16-ceg3120    文件:CloseableTabbedPaneLayer.java   
@Override
protected void processMouseMotionEvent(MouseEvent e0, JLayer<? extends JTabbedPane> jl) {
    pt.setLocation(e0.getPoint());
    JTabbedPane tabbedPane = (JTabbedPane) jl.getView();
    int index = tabbedPane.indexAtLocation(pt.x, pt.y);
    if (index >= 0) {
        tabbedPane.repaint(tabbedPane.getBoundsAt(index));
    } else {
        tabbedPane.repaint();
    }
}
项目:sp16-ceg3120    文件:MainGui.java   
/**
 * Creates the tab pane that holds all the tabs for the application.
 */
private void createTabPane() {
    tabPane = new MainTabPane();

    add(new JLayer<JTabbedPane>(tabPane, new CloseableTabbedPaneLayer()));
    //add(tabPane);
}
项目:quickfix-messenger    文件:FieldValidationLayerUI.java   
@Override
public void paint(Graphics g, JComponent c)
{
    super.paint(g, c);

    JLayer<?> jlayer = (JLayer<?>) c;

    JFormattedTextField jFormattedTextField = (JFormattedTextField) jlayer
            .getView();
    if (jFormattedTextField.getFormatterFactory() != null
            && !jFormattedTextField.isEditValid())
    {
        Graphics2D g2 = (Graphics2D) g.create();

        // Paint a red X
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        int w = c.getWidth();
        int h = c.getHeight();
        // int pad = 4;
        int s = 10;
        int pad = 10;
        int x = w - pad - s;
        int y = (h - s) / 2;
        ImageIcon icon = IconBuilder
                .build(frame.getMessenger().getConfig(),
                        IconBuilder.INVALID_FIELD);
        g2.drawImage(icon.getImage(), x, y, null);
        g2.dispose();
    }
}
项目:BaiduYunAssistant    文件:LoadingLayer.java   
public void installUI(JComponent c) {  
//      System.out.println("install UI");
        super.installUI(c);  
        JLayer jlayer = (JLayer) c;  
        // 启动鼠标事件和鼠标移动事件  
//            jlayer.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK  
//                    | AWTEvent.MOUSE_MOTION_EVENT_MASK);  
    }
项目:snap-desktop    文件:ProductSceneViewTopComponent.java   
public ProductSceneViewTopComponent(ProductSceneView view, UndoRedo undoRedo) {
        super(view.getRaster());
        this.view = view;
        this.undoRedo = undoRedo != null ? undoRedo : UndoRedo.NONE;
        this.nodeRenameHandler = new NodeRenameHandler();
        this.selection = Selection.EMPTY;
        setToolTipText(view.getRaster().getDescription());
        setIcon(ImageUtilities.loadImage("org/esa/snap/rcp/icons/RsBandAsSwath.gif"));
        updateDisplayName();
        setName(getDisplayName());
/*
        // checkme - this is ugly and not wanted (nf), the node will either passed in or we'll have
        // a central node factory, e.g. via an ExtensionObject
        Node node = null;
        try {
            if (raster instanceof Mask) {
                node = new MNode((Mask) raster, undoRedo);
            } else if (raster instanceof Band) {
                node = new BNode((Band) raster, undoRedo);
            } else if (raster instanceof TiePointGrid) {
                node = new TPGNode((TiePointGrid) raster, undoRedo);
            }
        } catch (IntrospectionException e) {
            Exceptions.printStackTrace(e);
        }
        if (node != null) {
            setActivatedNodes(new Node[]{node});
        }
*/
        setLayout(new BorderLayout());
        add(new JLayer<>(this.view, new ProductSceneViewLayerUI()), BorderLayout.CENTER);
    }
项目:Lumpi    文件:HostFrame.java   
public HostFrame(LumpiApplication<? extends LumpiApplicationContext, ? extends BindableWindow> application) {
    this.appRef = new WeakReference<>(application);
    this.pca = new PropertyChangeAwareAdapter(this);
    this.windowListener = new WindowListener();
    this.displayHost = initDisplayHost();
    this.layer = new JLayer<>();
    init();
}
项目:incubator-netbeans    文件:HtmlPreviewElement.java   
@Override
protected void processMouseEvent( MouseEvent e, JLayer<? extends JPanel> panel ) {
    super.processMouseEvent( e, panel );
    if( e.getButton() == MouseEvent.BUTTON1 )
        e.consume();
}
项目:rapidminer    文件:ConfigurableDialog.java   
/**
 * Initializes the GUI.
 */
private void initGUI() {
    realOuterPanel = new JPanel(new BorderLayout());

    outerLayer = new JLayer<JPanel>(realOuterPanel);
    savingGlassPane = new TransparentGlassPanePanel(WAITING_ICON,
            I18N.getGUILabel("configurable_dialog.saving_configurables"), getBackground(), 0.5f);
    outerLayer.setGlassPane(savingGlassPane);
    savingGlassPane.setVisible(false);

    JPanel pagePanel = new JPanel(new BorderLayout());

    // list of configurables
    JPanel configPanel = createConfigPanel();
    // force size so it does not resize itself depending on entered values
    configPanel.setMinimumSize(CONFIG_LIST_SIZE);
    configPanel.setMaximumSize(CONFIG_LIST_SIZE);
    configPanel.setPreferredSize(CONFIG_LIST_SIZE);
    buttonPanel = createConfigurableButtonPanel();
    // create middle spacer
    JLabel spacer = new JLabel();
    spacer.setMinimumSize(DIMENSION_SPACER_MIDDLE);
    spacer.setMaximumSize(DIMENSION_SPACER_MIDDLE);
    spacer.setPreferredSize(DIMENSION_SPACER_MIDDLE);
    // add both to an outer panel for layout reasons
    JPanel outerConfigPanel = new JPanel(new BorderLayout());
    outerConfigPanel.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.LIGHT_GRAY));
    outerConfigPanel.add(configPanel, BorderLayout.CENTER);
    outerConfigPanel.add(buttonPanel, BorderLayout.SOUTH);
    // another panel for layouting
    JPanel outermostConfigPanel = new JPanel(new BorderLayout());
    outermostConfigPanel.add(outerConfigPanel, BorderLayout.CENTER);
    outermostConfigPanel.add(spacer, BorderLayout.EAST);

    // glass pane showed if the user is not able to edit connections due to an old version of
    // the server
    simpleGlassPane = new TransparentGlassPanePanel(null, null, getBackground(), 0.5f);

    // panel displaying the selected configurable
    JPanel paramPanel = createParameterPanel();

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 0.3;
    c.gridwidth = GridBagConstraints.REMAINDER;

    // add panels to page panel
    pagePanel.add(outermostConfigPanel, BorderLayout.WEST);
    pagePanel.add(paramPanel, BorderLayout.CENTER);

    // add page and button panel to outer panel
    realOuterPanel.add(pagePanel, BorderLayout.CENTER);

    layoutDefault(outerLayer, makeSaveButton(), makeCancel());
    setDefaultSize(ButtonDialog.HUGE);
    setLocationRelativeTo(ApplicationFrame.getApplicationFrame());
    setModal(true);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            cancelButton.doClick();
        }
    });

    updateButtonState(true);
}
项目:semtool    文件:RepositoryList.java   
public JComponent getNeverEmptyLayer() {
//      return this;
        LayerUI<RepositoryList> layer = new RepositoryListLayerUI();
        return new JLayer<>( this, layer );
    }
项目:rapidminer-studio    文件:ConfigurableDialog.java   
/**
 * Initializes the GUI.
 */
private void initGUI() {
    realOuterPanel = new JPanel(new BorderLayout());

    outerLayer = new JLayer<JPanel>(realOuterPanel);
    savingGlassPane = new TransparentGlassPanePanel(WAITING_ICON,
            I18N.getGUILabel("configurable_dialog.saving_configurables"), getBackground(), 0.5f);
    outerLayer.setGlassPane(savingGlassPane);
    savingGlassPane.setVisible(false);

    JPanel pagePanel = new JPanel(new BorderLayout());

    // list of configurables
    JPanel configPanel = createConfigPanel();
    // force size so it does not resize itself depending on entered values
    configPanel.setMinimumSize(CONFIG_LIST_SIZE);
    configPanel.setMaximumSize(CONFIG_LIST_SIZE);
    configPanel.setPreferredSize(CONFIG_LIST_SIZE);
    buttonPanel = createConfigurableButtonPanel();
    // create middle spacer
    JLabel spacer = new JLabel();
    spacer.setMinimumSize(DIMENSION_SPACER_MIDDLE);
    spacer.setMaximumSize(DIMENSION_SPACER_MIDDLE);
    spacer.setPreferredSize(DIMENSION_SPACER_MIDDLE);
    // add both to an outer panel for layout reasons
    JPanel outerConfigPanel = new JPanel(new BorderLayout());
    outerConfigPanel.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.LIGHT_GRAY));
    outerConfigPanel.add(configPanel, BorderLayout.CENTER);
    outerConfigPanel.add(buttonPanel, BorderLayout.SOUTH);
    // another panel for layouting
    JPanel outermostConfigPanel = new JPanel(new BorderLayout());
    outermostConfigPanel.add(outerConfigPanel, BorderLayout.CENTER);
    outermostConfigPanel.add(spacer, BorderLayout.EAST);

    // glass pane showed if the user is not able to edit connections due to an old version of
    // the server
    simpleGlassPane = new TransparentGlassPanePanel(null, null, getBackground(), 0.5f);

    // panel displaying the selected configurable
    JPanel paramPanel = createParameterPanel();

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 0.3;
    c.gridwidth = GridBagConstraints.REMAINDER;

    // add panels to page panel
    pagePanel.add(outermostConfigPanel, BorderLayout.WEST);
    pagePanel.add(paramPanel, BorderLayout.CENTER);

    // add page and button panel to outer panel
    realOuterPanel.add(pagePanel, BorderLayout.CENTER);

    layoutDefault(outerLayer, makeSaveButton(), makeCancel());
    setDefaultSize(ButtonDialog.HUGE);
    setLocationRelativeTo(ApplicationFrame.getApplicationFrame());
    setModal(true);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            cancelButton.doClick();
        }
    });

    updateButtonState(true);
}
项目:mars-sim    文件:SpotlightLayerUI.java   
@Override
public void uninstallUI(JComponent c) {
  JLayer jlayer = (JLayer)c;
  jlayer.setLayerEventMask(0);
  super.uninstallUI(c);
}
项目:mars-sim    文件:SpotlightLayerUI.java   
@Override
protected void processMouseEvent(MouseEvent e, JLayer l) {
  if (e.getID() == MouseEvent.MOUSE_ENTERED) mActive = true;
  if (e.getID() == MouseEvent.MOUSE_EXITED) mActive = false;
  l.repaint();
}
项目:mars-sim    文件:WaitLayerUI.java   
@Override
public void applyPropertyChange(PropertyChangeEvent pce, JLayer l) {
  if ("tick".equals(pce.getPropertyName())) {
    l.repaint();
  }
}
项目:File-UI    文件:WaitLayerUI.java   
@Override
public void applyPropertyChange(PropertyChangeEvent pce, JLayer l) {
    if ("load".equals(pce.getPropertyName())) {
        l.repaint();
    }
}
项目:quickfix-messenger    文件:GroupPanel.java   
private void initComponents()
{
    setLayout(new GridBagLayout());

    layerUI = new FieldValidationLayerUI(getFrame());

    groupLabel = new JLabel(getMember().toString());
    groupLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    groupLabel.addMouseListener(new LinkMouseAdapter(this));
    groupLabel.setToolTipText("Double-click to look-up in FIXwiki");
    if (isRequired)
    {
        groupLabel.setForeground(Color.BLUE);
    }

    JPanel groupValuePanel = new JPanel();
    groupValuePanel.setLayout(new BoxLayout(groupValuePanel,
            BoxLayout.X_AXIS));

    groupTextField = new JFormattedTextField(
            NumberFormat.getIntegerInstance());
    groupTextField.setFocusLostBehavior(JFormattedTextField.COMMIT);
    if (initialNoOfGroups > 0)
    {
        groupTextField.setText(String.valueOf(initialNoOfGroups));
    }
    setButton = new JButton("Set");
    setButton.addActionListener(new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            getFrame().displayMainPanel();
        }
    });

    groupValuePanel.add(new JLayer<JFormattedTextField>(groupTextField,
            layerUI));
    groupValuePanel.add(setButton);

    groupPanels = new JPanel();
    groupPanels.setLayout(new GridBagLayout());

    loadMembers();

    add(groupLabel, createGridBagConstraints());
    add(groupValuePanel, createGridBagConstraints());
    add(groupPanels, createGridBagConstraints());
}
项目:BaiduYunAssistant    文件:LoadingLayer.java   
public void uninstallUI(JComponent c) {  
    JLayer jlayer = (JLayer) c;  
    jlayer.setLayerEventMask(0);  
    super.uninstallUI(c);  
}
项目:BaiduYunAssistant    文件:LoadingLayer.java   
public void applyPropertyChange(PropertyChangeEvent pce, JLayer l) {  
    if ("tick".equals(pce.getPropertyName())) {  
        l.repaint();  
    }  
}
项目:Lumpi    文件:HostFrame.java   
public final JLayer<DisplayHost> getLayer() {
    return layer;
}
项目:rapidminer    文件:PerspectivesPanelBar.java   
/**
 * Factory to create a perspectives panel bar which is covered by a JLayer.
 * 
 * @param perspectives
 * @return
 */
public static final JLayer<JPanel> getPerspecitvesPanelBar(Perspectives perspectives) {
    PerspectivesPanelBar view = new PerspectivesPanelBar(perspectives);
    return new JLayer<>(view, new PerspectivesLayerUI(view));
}
项目:rapidminer-studio    文件:PerspectivesPanelBar.java   
/**
 * Factory to create a perspectives panel bar which is covered by a JLayer.
 *
 * @param perspectives
 * @return
 */
@SuppressWarnings("deprecation")
public static final JLayer<JPanel> getPerspecitvesPanelBar(Perspectives perspectives) {
    PerspectivesPanelBar view = new PerspectivesPanelBar(perspectives);
    return new JLayer<>(view, new PerspectivesLayerUI(view));
}