Java Code Examples for sun.swing.SwingUtilities2#isScaleChanged()

The following examples show how to use sun.swing.SwingUtilities2#isScaleChanged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SynthToolTipUI.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || SwingUtilities2.isScaleChanged(e)
            || "foreground".equals(name) || "font".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
 
Example 2
Source File: DefaultTreeCellRenderer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
* Overridden for performance reasons.
* See the <a href="#override">Implementation Note</a>
* for more information.
*/
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
    // Strings get interned...
    if (propertyName == "text"
        || ((SwingUtilities2.isScaleChanged(propertyName, oldValue, newValue)
                || propertyName == "font" || propertyName == "foreground")
            && oldValue != newValue
            && getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {

        super.firePropertyChange(propertyName, oldValue, newValue);
    }
}
 
Example 3
Source File: DefaultTableCellRenderer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Overridden for performance reasons.
 * See the <a href="#override">Implementation Note</a>
 * for more information.
 */
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
    // Strings get interned...
    if (propertyName=="text"
        || propertyName == "labelFor"
        || propertyName == "displayedMnemonic"
        || ((SwingUtilities2.isScaleChanged(propertyName, oldValue, newValue)
                || propertyName == "font" || propertyName == "foreground")
            && oldValue != newValue
            && getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {

        super.firePropertyChange(propertyName, oldValue, newValue);
    }
}
 
Example 4
Source File: DefaultListCellRenderer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
* Overridden for performance reasons.
* See the <a href="#override">Implementation Note</a>
* for more information.
*/
@Override
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
    // Strings get interned...
    if (propertyName == "text"
        || ((SwingUtilities2.isScaleChanged(propertyName, oldValue, newValue)
                || propertyName == "font" || propertyName == "foreground")
            && oldValue != newValue
            && getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey) != null)) {

        super.firePropertyChange(propertyName, oldValue, newValue);
    }
}
 
Example 5
Source File: BasicSliderUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    if (propertyName == "orientation" ||
            propertyName == "inverted" ||
            propertyName == "labelTable" ||
            propertyName == "majorTickSpacing" ||
            propertyName == "minorTickSpacing" ||
            propertyName == "paintTicks" ||
            propertyName == "paintTrack" ||
            propertyName == "font" ||
            SwingUtilities2.isScaleChanged(e) ||
            propertyName == "paintLabels" ||
            propertyName == "Slider.paintThumbArrowShape") {
        checkedLabelBaselines = false;
        calculateGeometry();
        slider.repaint();
    } else if (propertyName == "componentOrientation") {
        calculateGeometry();
        slider.repaint();
        InputMap km = getInputMap(JComponent.WHEN_FOCUSED, slider);
        SwingUtilities.replaceUIInputMap(slider,
            JComponent.WHEN_FOCUSED, km);
    } else if (propertyName == "model") {
        ((BoundedRangeModel)e.getOldValue()).removeChangeListener(
            changeListener);
        ((BoundedRangeModel)e.getNewValue()).addChangeListener(
            changeListener);
        calculateThumbLocation();
        slider.repaint();
    }
}
 
Example 6
Source File: BasicLabelUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String name = e.getPropertyName();
    if (name == "text" || "font" == name || "foreground" == name
            || SwingUtilities2.isScaleChanged(e)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JLabel lbl = ((JLabel) e.getSource());
        String text = lbl.getText();
        BasicHTML.updateRenderer(lbl, text);
    }
    else if (name == "labelFor" || name == "displayedMnemonic") {
        installKeyboardActions((JLabel) e.getSource());
    }
}
 
Example 7
Source File: BasicButtonListener.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if(prop == AbstractButton.MNEMONIC_CHANGED_PROPERTY) {
        updateMnemonicBinding((AbstractButton)e.getSource());
    }
    else if(prop == AbstractButton.CONTENT_AREA_FILLED_CHANGED_PROPERTY) {
        checkOpacity((AbstractButton) e.getSource() );
    }
    else if(prop == AbstractButton.TEXT_CHANGED_PROPERTY || "font" == prop
            || "foreground" == prop || SwingUtilities2.isScaleChanged(e)) {
        AbstractButton b = (AbstractButton) e.getSource();
        BasicHTML.updateRenderer(b, b.getText());
    }
}
 
Example 8
Source File: BasicTreeUI.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void propertyChange(PropertyChangeEvent event) {
    if (event.getSource() == treeSelectionModel) {
        treeSelectionModel.resetRowSelection();
    }
    else if(event.getSource() == tree) {
        String              changeName = event.getPropertyName();

        if (changeName == JTree.LEAD_SELECTION_PATH_PROPERTY) {
            if (!ignoreLAChange) {
                updateLeadSelectionRow();
                repaintPath((TreePath)event.getOldValue());
                repaintPath((TreePath)event.getNewValue());
            }
        }
        else if (changeName == JTree.ANCHOR_SELECTION_PATH_PROPERTY) {
            if (!ignoreLAChange) {
                repaintPath((TreePath)event.getOldValue());
                repaintPath((TreePath)event.getNewValue());
            }
        }
        if(changeName == JTree.CELL_RENDERER_PROPERTY) {
            setCellRenderer((TreeCellRenderer)event.getNewValue());
            redoTheLayout();
        }
        else if(changeName == JTree.TREE_MODEL_PROPERTY) {
            setModel((TreeModel)event.getNewValue());
        }
        else if(changeName == JTree.ROOT_VISIBLE_PROPERTY) {
            setRootVisible(((Boolean)event.getNewValue()).
                           booleanValue());
        }
        else if(changeName == JTree.SHOWS_ROOT_HANDLES_PROPERTY) {
            setShowsRootHandles(((Boolean)event.getNewValue()).
                                booleanValue());
        }
        else if(changeName == JTree.ROW_HEIGHT_PROPERTY) {
            setRowHeight(((Integer)event.getNewValue()).
                         intValue());
        }
        else if(changeName == JTree.CELL_EDITOR_PROPERTY) {
            setCellEditor((TreeCellEditor)event.getNewValue());
        }
        else if(changeName == JTree.EDITABLE_PROPERTY) {
            setEditable(((Boolean)event.getNewValue()).booleanValue());
        }
        else if(changeName == JTree.LARGE_MODEL_PROPERTY) {
            setLargeModel(tree.isLargeModel());
        }
        else if(changeName == JTree.SELECTION_MODEL_PROPERTY) {
            setSelectionModel(tree.getSelectionModel());
        }
        else if(changeName == "font"
                || SwingUtilities2.isScaleChanged(event)) {
            completeEditing();
            if(treeState != null)
                treeState.invalidateSizes();
            updateSize();
        }
        else if (changeName == "componentOrientation") {
            if (tree != null) {
                leftToRight = BasicGraphicsUtils.isLeftToRight(tree);
                redoTheLayout();
                tree.treeDidChange();

                InputMap km = getInputMap(JComponent.WHEN_FOCUSED);
                SwingUtilities.replaceUIInputMap(tree,
                                        JComponent.WHEN_FOCUSED, km);
            }
        } else if ("dropLocation" == changeName) {
            JTree.DropLocation oldValue = (JTree.DropLocation)event.getOldValue();
            repaintDropLocation(oldValue);
            repaintDropLocation(tree.getDropLocation());
        }
    }
}