java.beans.PropertyChangeEvent Java Examples

The following examples show how to use java.beans.PropertyChangeEvent. 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: SubstanceRadioButtonUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void installListeners(final AbstractButton b) {
    super.installListeners(b);

    this.stateTransitionTracker.registerModelListeners();
    this.stateTransitionTracker.registerFocusListeners();

    this.substancePropertyListener = (PropertyChangeEvent evt) -> {
        if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
            stateTransitionTracker.setModel((ButtonModel) evt.getNewValue());
        }
        if ("font".equals(evt.getPropertyName())) {
            SwingUtilities.invokeLater(b::updateUI);
        }
    };
    b.addPropertyChangeListener(substancePropertyListener);
}
 
Example #2
Source File: SectionNodePanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public SectionNodePanel(final SectionNode node, boolean openFirstChild) {
    super(node.getSectionNodeView(), node, node.getDisplayName(), node);
    this.openFirstChild = openFirstChild;
    
    if (node.getKey() instanceof SectionView) {
        // the section corresponding to the top level node is always expanded
        setInnerViewMode();
    } else if (node.isExpanded()) {
        setExpandedViewMode();
    }
    node.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (Node.PROP_DISPLAY_NAME.equals(evt.getPropertyName())) {
                setTitle(node.getDisplayName());
            }
        }
    });
}
 
Example #3
Source File: MotifInternalFrameTitlePane.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    JInternalFrame f = (JInternalFrame)evt.getSource();
    boolean value = false;
    if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
        repaint();
    } else if (prop.equals("maximizable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(maximizeButton);
        else
            remove(maximizeButton);
        revalidate();
        repaint();
    } else if (prop.equals("iconable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(minimizeButton);
        else
            remove(minimizeButton);
        revalidate();
        repaint();
    } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
        repaint();
    }
    enableActions();
}
 
Example #4
Source File: MainActivity.java    From Sparkplug with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
 */
@Override
public void propertyChange(PropertyChangeEvent event) {

    if (!event.getPropertyName().equals(ActivityConstants.ConnectionStatusProperty)) {
        return;
    }
    mainActivity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            mainActivity.drawerFragment.notifyDataSetChanged();
        }

    });

}
 
Example #5
Source File: EnumEditor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void setValue( Object value ) {
    if ( ( value != null ) && !this.type.isInstance( value ) ) {
        throw new IllegalArgumentException( "Unsupported value: " + value );
    }
    Object oldValue;
    PropertyChangeListener[] listeners;
    synchronized ( this.listeners ) {
        oldValue = this.value;
        this.value = value;

        if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) {
            return; // do not fire event if value is not changed
        }
        int size = this.listeners.size();
        if ( size == 0 ) {
            return; // do not fire event if there are no any listener
        }
        listeners = this.listeners.toArray( new PropertyChangeListener[size] );
    }
    PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value );
    for ( PropertyChangeListener listener : listeners ) {
        listener.propertyChange( event );
    }
}
 
Example #6
Source File: IDEF0TabView.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (Action.SELECTED_KEY.equals(evt.getPropertyName())) {
        if ((Boolean) evt.getNewValue()) {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Image image = toolkit.getImage(getClass()
                    .getResource("/images/pen-cursor.png"));
            java.awt.Point point = new java.awt.Point(0, 15);
            panel.getMovingArea().setVisualCopyCursor(
                    toolkit.createCustomCursor(image, point,
                            "CopyVisualCursor"));
        } else {
            panel.getMovingArea().setVisualCopyCursor(null);
        }
    }
}
 
Example #7
Source File: MotifInternalFrameTitlePane.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    JInternalFrame f = (JInternalFrame)evt.getSource();
    boolean value = false;
    if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
        repaint();
    } else if (prop.equals("maximizable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(maximizeButton);
        else
            remove(maximizeButton);
        revalidate();
        repaint();
    } else if (prop.equals("iconable")) {
        if ((Boolean)evt.getNewValue() == Boolean.TRUE)
            add(minimizeButton);
        else
            remove(minimizeButton);
        revalidate();
        repaint();
    } else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
        repaint();
    }
    enableActions();
}
 
Example #8
Source File: EditorRegistry.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private synchronized static void _focusGained(JTextComponent c, Component origFocused, List<PropertyChangeEvent> events) {
    Item item = item(c);
    assert (item != null) : "Not registered!"; // NOI18N

    // Move the item to head of the list
    removeFromItemList(item);
    addToItemListAsFirst(item);
    item.focused = true;

    c.addPropertyChangeListener(PropertyDocL.INSTANCE);
    if (LOG.isLoggable(Level.FINE)) {
        LOG.log(Level.FINE, FOCUS_GAINED_PROPERTY + ": " + dumpComponent(c) + '\n'); //NOI18N
        logItemListFinest();
    }
    if (c == origFocused) {
        origFocused = null;
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("has equal components, using origFocused = "+origFocused);
        }
    }
    events.add(new PropertyChangeEvent(EditorRegistry.class, FOCUS_GAINED_PROPERTY, origFocused, c));
}
 
Example #9
Source File: BaseActionProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public BaseActionProvider(Project project, UpdateHelper updateHelper, PropertyEvaluator evaluator, 
        SourceRoots sourceRoots, SourceRoots testRoots, AntProjectHelper antProjectHelper, Callback callback) {
    this.antProjectHelper = antProjectHelper;
    this.callback = callback;
    this.classpaths = (id) -> getCallback().getProjectSourcesClassPath(id);
    this.updateHelper = updateHelper;
    this.project = project;
    this.evaluator = evaluator;
    this.projectSourceRoots = sourceRoots;
    this.projectTestRoots = testRoots;
    this.evaluator.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            synchronized (BaseActionProvider.class) {
                final String propName = evt.getPropertyName();
                if (propName == null || BUILD_SCRIPT.equals(propName)) {
                    buildXMLName = null;
                }
            }
        }
    });
    this.listeners = Collections.singletonList(new EventAdaptor());
    this.delegate = new AtomicReference<>();
}
 
Example #10
Source File: DecryptOnePm.java    From pgptool with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
	boolean result = isUseBrowseFolder.getValue();
	actionBrowseTarget.setEnabled(result);
	targetFileEnabled.setValueByOwner(result);
	// NOTE: MAGIC: This event might be triggered when using suggested
	// parameters. So if value is already provided for target file then
	// we'll not show file chooser
	if (result && !StringUtils.hasText(targetFile.getValue())) {
		getTargetFileChooser().askUserForFile(UiUtils.actionEvent(evt));
	}

	if (!result) {
		clearValidationErrorsFromTargetFile();
	}
}
 
Example #11
Source File: SummonMenuItem.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * Create a new <code>SummonMenuItem</code>.
 * 
 * @param f
 *            the frame to bring to front when this menu item is activated
 */
public SummonMenuItem(Frame f) {
	super();
	frame = f;
	addActionListener(actionListener);
	updateText();

	frame.addPropertyChangeListener("title", new PropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent e) {
			updateText();
		}
	});

	// this UI is buggy, and has issues.
	// the main issue is that it won't even show up on Macs
	// if you use the screen menubar, and since the goal
	// is to emulate macs: why bother?
	// if(frame instanceof JFrame)
	// setUI(new FrameMenuItemUI((JFrame)frame));
}
 
Example #12
Source File: ElementTreePanel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Invoked when a property changes. We are only interested in when the
 * Document changes to reset the DocumentListener.
 */
public void propertyChange(PropertyChangeEvent e) {
    if (e.getSource() == getEditor() && e.getPropertyName().equals(
            "document")) {
        Document oldDoc = (Document) e.getOldValue();
        Document newDoc = (Document) e.getNewValue();

        // Reset the DocumentListener
        oldDoc.removeDocumentListener(this);
        newDoc.addDocumentListener(this);

        // Recreate the TreeModel.
        treeModel = new ElementTreeModel(newDoc);
        tree.setModel(treeModel);
    }
}
 
Example #13
Source File: SynthLabelUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    super.propertyChange(e);
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JLabel)e.getSource());
    }
}
 
Example #14
Source File: SunClipboard.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (AppContext.DISPOSED_PROPERTY_NAME.equals(evt.getPropertyName()) &&
        Boolean.TRUE.equals(evt.getNewValue())) {
        final AppContext disposedContext = (AppContext)evt.getSource();
        lostOwnershipLater(disposedContext);
    }
}
 
Example #15
Source File: MergeDialogComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
    if (MergePanel.PROP_CAN_BE_SAVED.equals(propertyChangeEvent.getPropertyName())) {
        activateSave();
    } else if (MergePanel.PROP_CAN_NOT_BE_SAVED.equals(propertyChangeEvent.getPropertyName())) {
        deactivateSave();
    }
    MergeDialogComponent.this.refreshName();
}
 
Example #16
Source File: SubstanceCheckBoxMenuItemUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void installListeners() {
    super.installListeners();

    // Improving performance on big menus.
    this.substanceMenuPropertyListener = new MenuPropertyListener(this.menuItem);
    this.substanceMenuPropertyListener.install();
    // fix for defect 109 - storing reference to rollover listener
    this.substanceRolloverListener = new RolloverMenuItemListener(
            this.menuItem, this.stateTransitionTracker);
    this.menuItem.addMouseListener(this.substanceRolloverListener);

    this.stateTransitionTracker.registerModelListeners();

    this.substancePropertyListener = (PropertyChangeEvent evt) -> {
        if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
            stateTransitionTracker.setModel((ButtonModel) evt.getNewValue());
        }
        if ("font".equals(evt.getPropertyName())) {
            SwingUtilities.invokeLater(() -> {
                if (menuItem != null) {
                    menuItem.updateUI();
                }
            });
        }
    };
    this.menuItem.addPropertyChangeListener(this.substancePropertyListener);
}
 
Example #17
Source File: StyledEditorKit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    Object newValue = evt.getNewValue();
    Object source = evt.getSource();

    if ((source instanceof JTextComponent) &&
        (newValue instanceof Document)) {
        // New document will have changed selection to 0,0.
        updateInputAttributes(0, 0, (JTextComponent)source);
    }
}
 
Example #18
Source File: GroovyToggleBreakpointActionProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange (PropertyChangeEvent evt) {
    FileObject fo = Context.getCurrentFile();
    boolean isGroovyFile = fo != null && 
            "text/x-groovy".equals(fo.getMIMEType()); // NOI18N [TODO]
    
    setEnabled(ActionsManager.ACTION_TOGGLE_BREAKPOINT, isGroovyFile);
    if ( debugger != null && 
         debugger.getState () == JPDADebugger.STATE_DISCONNECTED
    ) 
        destroy ();
}
 
Example #19
Source File: SerialDataConvertor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** place where to filter events comming from setting object */
private boolean ignoreChange(PropertyChangeEvent pce) {
    if (isChanged || isWriting || !getDataObject().isValid()) return true;
    
    // undocumented workaround used in 3.3; since 3.4 convertors make
    // possible to customize the setting change notification filtering 
    if (pce != null && Boolean.FALSE.equals(pce.getPropagationId())) return true;
    
    if (knownToBeTemplate == null) knownToBeTemplate = getDataObject().isTemplate() ? Boolean.TRUE : Boolean.FALSE;
    return knownToBeTemplate.booleanValue();
}
 
Example #20
Source File: BasicLabelUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    String name = e.getPropertyName();
    if (name == "text" || "font" == name || "foreground" == 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.
        JLabel lbl = ((JLabel) e.getSource());
        String text = lbl.getText();
        BasicHTML.updateRenderer(lbl, text);
    }
    else if (name == "labelFor" || name == "displayedMnemonic") {
        installKeyboardActions((JLabel) e.getSource());
    }
}
 
Example #21
Source File: ToolsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent ev) {
    String prop = ev.getPropertyName();

    if ((prop == null) || prop.equals(ActionManager.PROP_CONTEXT_ACTIONS)) {
        actionsListChanged();
    } else if (prop.equals("enabled")) {
        actionStateChanged();
    }
}
 
Example #22
Source File: Quaqua13ColorChooserUI.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e) {
    
    if (e.getPropertyName().equals( JColorChooser.CHOOSER_PANELS_PROPERTY)) {
        AbstractColorChooserPanel[] oldPanels = (AbstractColorChooserPanel[]) e.getOldValue();
        AbstractColorChooserPanel[] newPanels = (AbstractColorChooserPanel[]) e.getNewValue();
        
        for (int i = 0; i < oldPanels.length; i++) {  // remove old panels
            Container wrapper = oldPanels[i].getParent();
            if (wrapper != null) {
                Container parent = wrapper.getParent();
                if (parent != null)
                    parent.remove(wrapper);  // remove from hierarchy
                oldPanels[i].uninstallChooserPanel(chooser); // uninstall
            }
        }
        
        mainPanel.removeAllColorChooserPanels();
        for (int i = 0; i < newPanels.length; i++) {
            if (newPanels[i] != null) {
            mainPanel.addColorChooserPanel((SubstanceColorChooserPanel) newPanels[i]);
            }
        }
        
        for (int i = 0; i < newPanels.length; i++) {
            if (newPanels[i] != null) {
            newPanels[i].installChooserPanel(chooser);
            }
        }
    }
    
    if ( e.getPropertyName().equals( JColorChooser.PREVIEW_PANEL_PROPERTY)) {
        if (e.getNewValue() != previewPanel) {
            installPreviewPanel();
        }
    }
}
 
Example #23
Source File: MultiDiffPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean affectsView(PropertyChangeEvent event) {
    FileStatusCache.ChangedEvent changedEvent = (FileStatusCache.ChangedEvent) event.getNewValue();
    File file = changedEvent.getFile();
    FileInformation oldInfo = changedEvent.getOldInfo();
    FileInformation newInfo = changedEvent.getNewInfo();
    if (oldInfo == null) {
        if ((newInfo.getStatus() & displayStatuses) == 0) return false;
    } else {
        if ((oldInfo.getStatus() & displayStatuses) + (newInfo.getStatus() & displayStatuses) == 0) return false;
    }
    return isLocal() && containsFile(file);
}
 
Example #24
Source File: SynthProgressBarUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e) ||
            "indeterminate".equals(e.getPropertyName())) {
        updateStyle((JProgressBar)e.getSource());
    }
}
 
Example #25
Source File: MavenForBinaryQueryImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public MavenForBinaryQueryImpl(Project proj) {
    p = proj;
    map = new HashMap<String, BinResult>();
    NbMavenProject.addPropertyChangeListener(proj, new PropertyChangeListener() {
        public @Override void propertyChange(PropertyChangeEvent event) {
            if (NbMavenProject.PROP_PROJECT.equals(event.getPropertyName())) {
                if (p.getLookup().lookup(NbMavenProject.class).isUnloadable()) {
                    return; //let's just continue with the old value, reloading classpath for broken project and re-creating it later serves no greater good.
                }
                ForeignClassBundler bundler = p.getLookup().lookup(ForeignClassBundler.class);
                boolean oldprefer = bundler.preferSources();
                bundler.resetCachedValue();
                boolean preferChanged = oldprefer != bundler.preferSources();
                synchronized (map) {
                    for (BinResult res : map.values()) {
                        FileObject[] cached = res.getCached();
                        res.cached = null; // force refresh to see if we have to fire changes
                        FileObject[] current = res.getRoots();
                        if (preferChanged || !Arrays.equals(cached, current)) {
                            LOGGER.log(Level.FINE, "SFBQ.Result changed from {0} to {1}", new Object[]{Arrays.toString(cached), Arrays.toString(current)});
                            res.fireChanged();
                        }
                    }
                }
            }
        }
    });
}
 
Example #26
Source File: BuildConfig.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (GrailsProjectConfig.GRAILS_PROJECT_PLUGINS_DIR_PROPERTY.equals(evt.getPropertyName())
            || GrailsProjectConfig.GRAILS_GLOBAL_PLUGINS_DIR_PROPERTY.equals(evt.getPropertyName())
            || GrailsProjectConfig.GRAILS_LOCAL_PLUGINS_PROPERTY.equals(evt.getPropertyName())) {

        synchronized (this) {
            changed = true;
        }
    }
}
 
Example #27
Source File: MetalInternalFrameUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent e)
{
    String name = e.getPropertyName();
    JInternalFrame jif = (JInternalFrame)e.getSource();

    if (!(jif.getUI() instanceof MetalInternalFrameUI)) {
        return;
    }

    MetalInternalFrameUI ui = (MetalInternalFrameUI)jif.getUI();

    if ( name.equals( FRAME_TYPE ) )
    {
        if ( e.getNewValue() instanceof String )
        {
            ui.setFrameType( (String) e.getNewValue() );
        }
    }
    else if ( name.equals(IS_PALETTE_KEY) )
    {
        if ( e.getNewValue() != null )
        {
            ui.setPalette( ((Boolean)e.getNewValue()).booleanValue() );
        }
        else
        {
            ui.setPalette( false );
        }
    } else if ( name.equals( JInternalFrame.CONTENT_PANE_PROPERTY ) ) {
        ui.stripContentBorder(e.getNewValue());
    }
}
 
Example #28
Source File: BasicInternalFrameTitlePane.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();

    if (prop == JInternalFrame.IS_SELECTED_PROPERTY) {
        repaint();
        return;
    }

    if (prop == JInternalFrame.IS_ICON_PROPERTY ||
            prop == JInternalFrame.IS_MAXIMUM_PROPERTY) {
        setButtonIcons();
        enableActions();
        return;
    }

    if ("closable" == prop) {
        if (evt.getNewValue() == Boolean.TRUE) {
            add(closeButton);
        } else {
            remove(closeButton);
        }
    } else if ("maximizable" == prop) {
        if (evt.getNewValue() == Boolean.TRUE) {
            add(maxButton);
        } else {
            remove(maxButton);
        }
    } else if ("iconable" == prop) {
        if (evt.getNewValue() == Boolean.TRUE) {
            add(iconButton);
        } else {
            remove(iconButton);
        }
    }
    enableActions();

    revalidate();
    repaint();
}
 
Example #29
Source File: NamedEntryPoint.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public void propertyChange(final PropertyChangeEvent event) {
    final Object object = event.getSource();
    FactHandle handle = getFactHandle( object );
    if ( handle == null ) {
        throw new RuntimeException( "Update error: handle not found for object: " + object + ". Is it in the working memory?" );
    }
    update( handle, object );
}
 
Example #30
Source File: BasicScrollPaneUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void sbPropertyChange(PropertyChangeEvent e) {
    String propertyName = e.getPropertyName();
    Object source = e.getSource();

    if ("model" == propertyName) {
        JScrollBar sb = scrollpane.getVerticalScrollBar();
        BoundedRangeModel oldModel = (BoundedRangeModel)e.
                             getOldValue();
        ChangeListener cl = null;

        if (source == sb) {
            cl = vsbChangeListener;
        }
        else if (source == scrollpane.getHorizontalScrollBar()) {
            sb = scrollpane.getHorizontalScrollBar();
            cl = hsbChangeListener;
        }
        if (cl != null) {
            if (oldModel != null) {
                oldModel.removeChangeListener(cl);
            }
            if (sb.getModel() != null) {
                sb.getModel().addChangeListener(cl);
            }
        }
    }
    else if ("componentOrientation" == propertyName) {
        if (source == scrollpane.getHorizontalScrollBar()) {
            JScrollBar hsb = scrollpane.getHorizontalScrollBar();
            JViewport viewport = scrollpane.getViewport();
            Point p = viewport.getViewPosition();
            if (scrollpane.getComponentOrientation().isLeftToRight()) {
                p.x = hsb.getValue();
            } else {
                p.x = viewport.getViewSize().width - viewport.getExtentSize().width - hsb.getValue();
            }
            viewport.setViewPosition(p);
        }
    }
}