|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.form.fakepeer; import java.awt.*; import java.awt.peer.ListPeer; /** * * @author Tran Duc Trung */ class FakeListPeer extends FakeComponentPeer implements ListPeer { FakeListPeer(List target) { super(target); } Component createDelegate() { return new Delegate(); } public int[] getSelectedIndexes() { return new int[0]; } public void add(String item, int index) { } public void delItems(int start, int end) { } public void removeAll() { } public void select(int index) { } public void deselect(int index) { } public void makeVisible(int index) { } public void setMultipleMode(boolean b) { } public Dimension getPreferredSize(int rows) { return new Dimension(40, 80); } public Dimension getMinimumSize(int rows) { return new Dimension(40, 80); } public void addItem(String item, int index) { add(item, index); } public void clear() { removeAll(); } public void setMultipleSelections(boolean v) { setMultipleMode(v); } public Dimension preferredSize(int rows) { return getPreferredSize(rows); } public Dimension minimumSize(int rows) { return getMinimumSize(rows); } // // // private class Delegate extends Component { Delegate() { this.setBackground(SystemColor.window); this.setForeground(SystemColor.windowText); } public void paint(Graphics g) { List target =(List) _target; Dimension sz = target.getSize(); int w = sz.width; int h = sz.height; g.setColor(target.getBackground()); FakePeerUtils.drawLoweredBox(g,0,0,w,h); int n = target.getItemCount(); if (n <= 0) return; if (target.isEnabled()) { g.setColor(target.getForeground()); } else { g.setColor(SystemColor.controlShadow); } g.setFont(target.getFont()); g.setClip(1,1,w-5,h-4); FontMetrics fm = g.getFontMetrics(); int th = fm.getHeight(), ty = th+2; for (int i=0; i < n; i++) { g.drawString(target.getItem(i), 4, ty); if (ty > h) break; ty += th; } } public Dimension getMinimumSize() { return FakeListPeer.this.getMinimumSize(1); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.