本文整理匯總了Java中java.beans.Beans類的典型用法代碼示例。如果您正苦於以下問題:Java Beans類的具體用法?Java Beans怎麽用?Java Beans使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Beans類屬於java.beans包,在下文中一共展示了Beans類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCommandObject
import java.beans.Beans; //導入依賴的package包/類
/**
* Returns the instantiated bean.
* If the bean implements <code>CommandObject</code>, its
* <code>setCommandContext</code> method will be called.
* @param dh the data handler describing the command data
* @param loader the class loader used to instantiate the bean
*/
public Object getCommandObject(DataHandler dh, ClassLoader loader)
throws IOException, ClassNotFoundException
{
Object object = Beans.instantiate(loader, className);
if (object != null)
{
if (object instanceof CommandObject)
{
CommandObject command = (CommandObject)object;
command.setCommandContext(verb, dh);
}
else if (dh != null && (object instanceof Externalizable))
{
InputStream in = dh.getInputStream();
if (in != null)
{
Externalizable externalizable = (Externalizable)object;
externalizable.readExternal(new ObjectInputStream(in));
}
}
}
return object;
}
示例2: setValue
import java.beans.Beans; //導入依賴的package包/類
public void setValue(T val)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (setter == null) {
throw new IllegalAccessException();
}
Object valideInstance = Beans.getInstanceOf(instance, setter.getDeclaringClass());
try {
setter.invoke(valideInstance, val);
} catch (IllegalAccessException ex) {
try {
setter.setAccessible(true);
setter.invoke(valideInstance, val);
} finally {
setter.setAccessible(false);
}
}
}
示例3: setValue
import java.beans.Beans; //導入依賴的package包/類
public void setValue(T val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (!canWrite()) {
throw new IllegalAccessException();
}
Object validInstance = Beans.getInstanceOf(instance, setter.getDeclaringClass());
Object value = val;
if (
(val != null) && (setter.getParameterTypes()[0].getComponentType().isPrimitive()) &&
(!val.getClass().getComponentType().isPrimitive())
) {
value = Utilities.toPrimitiveArray((Object[]) val);
}
setter.invoke(validInstance, value);
}
示例4: MVMapElement
import java.beans.Beans; //導入依賴的package包/類
MVMapElement(TLDataObject dataObject) {
// Hack
if (Beans.isDesignTime()) {
Beans.setDesignTime(false);
}
this.dataObject = dataObject;
glPanel = new TLMapGLPanel(dataObject.getDatabase().getMap(), dataObject.getDatabase());
slider = new TLSlider(dataObject.getDatabase());
elementPanel = new JPanel(new BorderLayout());
elementPanel.add(glPanel, BorderLayout.CENTER);
elementPanel.add(slider, BorderLayout.PAGE_END);
ActionMap map = new ActionMap();
map.put("save", SystemAction.get(SaveAction.class));
elementPanel.setActionMap(map);
lookupContent = new InstanceContent();
lookup = new ProxyLookup(dataObject.getLookup(), new AbstractLookup(lookupContent));
}
示例5: test
import java.beans.Beans; //導入依賴的package包/類
private static void test(String[] path) {
try {
Beans.setDesignTime(true);
Beans.setGuiAvailable(true);
Introspector.setBeanInfoSearchPath(path);
PropertyEditorManager.setEditorSearchPath(path);
} catch (SecurityException exception) {
throw new Error("unexpected security exception", exception);
}
}
示例6: addAllBeansToContainer
import java.beans.Beans; //導入依賴的package包/類
/**
* Adds all beans to the supplied component
*
* @param container a <code>JComponent</code> value
*/
public static void addAllBeansToContainer(JComponent container,
Integer... tab) {
int index = 0;
if (tab.length > 0) {
index = tab[0].intValue();
}
Vector<Object> components = null;
if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
components = TABBED_COMPONENTS.get(index);
}
if (container != null) {
if (components != null) {
for (int i = 0; i < components.size(); i++) {
BeanInstance tempInstance = (BeanInstance) components.elementAt(i);
Object tempBean = tempInstance.getBean();
if (Beans.isInstanceOf(tempBean, JComponent.class)) {
container.add((JComponent) tempBean);
}
}
}
container.revalidate();
}
}
示例7: addBeanInstances
import java.beans.Beans; //導入依賴的package包/類
/**
* Adds the supplied collection of beans to the end of the list of collections
* and to the JComponent container (if not null)
*
* @param beanInstances the vector of bean instances to add
* @param container
*/
public static void addBeanInstances(Vector<Object> beanInstances,
JComponent container) {
// reset(container);
if (container != null) {
for (int i = 0; i < beanInstances.size(); i++) {
Object bean = ((BeanInstance) beanInstances.elementAt(i)).getBean();
if (Beans.isInstanceOf(bean, JComponent.class)) {
container.add((JComponent) bean);
}
}
container.revalidate();
container.repaint();
}
TABBED_COMPONENTS.add(beanInstances);
}
示例8: BeanInstance
import java.beans.Beans; //導入依賴的package包/類
/**
* Creates a new <code>BeanInstance</code> instance given the fully qualified
* name of the bean
*
* @param container a <code>JComponent</code> to add the bean to
* @param beanName the fully qualified name of the bean
* @param x the x coordinate of the bean
* @param y th y coordinate of the bean
*/
public BeanInstance(JComponent container, String beanName, int x, int y,
Integer... tab) {
m_x = x;
m_y = y;
// try and instantiate the named component
try {
m_bean = Beans.instantiate(null, beanName);
} catch (Exception ex) {
ex.printStackTrace();
return;
}
addBean(container, tab);
}
示例9: appendBeans
import java.beans.Beans; //導入依賴的package包/類
public static void appendBeans(JComponent container, Vector<Object> beans,
int tab) {
if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
Vector<Object> components = TABBED_COMPONENTS.get(tab);
//
for (int i = 0; i < beans.size(); i++) {
components.add(beans.get(i));
if (container != null) {
Object bean = ((BeanInstance) beans.elementAt(i)).getBean();
if (Beans.isInstanceOf(bean, JComponent.class)) {
container.add((JComponent) bean);
}
}
}
if (container != null) {
container.revalidate();
container.repaint();
}
}
}
示例10: addAllBeansToContainer
import java.beans.Beans; //導入依賴的package包/類
/**
* Adds all beans to the supplied component
*
* @param container a <code>JComponent</code> value
*/
public static void addAllBeansToContainer(JComponent container, Integer... tab) {
int index = 0;
if (tab.length > 0) {
index = tab[0].intValue();
}
Vector components = null;
if (TABBED_COMPONENTS.size() > 0 && index < TABBED_COMPONENTS.size()) {
components = TABBED_COMPONENTS.get(index);
}
if (container != null) {
if (components != null) {
for (int i = 0; i < components.size(); i++) {
BeanInstance tempInstance = (BeanInstance)components.elementAt(i);
Object tempBean = tempInstance.getBean();
if (Beans.isInstanceOf(tempBean, JComponent.class)) {
container.add((JComponent)tempBean);
}
}
}
container.revalidate();
}
}
示例11: addBeanInstances
import java.beans.Beans; //導入依賴的package包/類
/**
* Adds the supplied collection of beans to the end of the list
* of collections and to the JComponent container (if not null)
*
* @param beanInstances the vector of bean instances to add
* @param container
*/
public static void addBeanInstances(Vector beanInstances, JComponent container) {
// reset(container);
if (container != null) {
for (int i = 0; i < beanInstances.size(); i++) {
Object bean = ((BeanInstance)beanInstances.elementAt(i)).getBean();
if (Beans.isInstanceOf(bean, JComponent.class)) {
container.add((JComponent)bean);
}
}
container.revalidate();
container.repaint();
}
TABBED_COMPONENTS.add(beanInstances);
}
示例12: appendBeans
import java.beans.Beans; //導入依賴的package包/類
public static void appendBeans(JComponent container, Vector beans, int tab) {
if (TABBED_COMPONENTS.size() > 0 && tab < TABBED_COMPONENTS.size()) {
Vector components = TABBED_COMPONENTS.get(tab);
//
for (int i = 0; i < beans.size(); i++) {
components.add(beans.get(i));
if (container != null) {
Object bean = ((BeanInstance)beans.elementAt(i)).getBean();
if (Beans.isInstanceOf(bean, JComponent.class)) {
container.add((JComponent)bean);
}
}
}
if (container != null) {
container.revalidate();
container.repaint();
}
}
}
示例13: onLoad
import java.beans.Beans; //導入依賴的package包/類
@Override
public void onLoad() {
tabPanel.selectTab(0);
if (!Beans.isDesignTime()) {
Storage s = Storage.getLocalStorageIfSupported();
if (s != null) {
for (int i = 0; i < s.getLength(); i++) {
String key = s.key(i);
if ((key != null) && key.startsWith(STORAGE_KEY)) {
String name = key.substring(STORAGE_KEY.length());
storageList.addItem(name, key);
}
}
}
}
}
示例14: getInstance
import java.beans.Beans; //導入依賴的package包/類
/**
* Get a new Bean instance given its name
*/
public Object getInstance(String name) {
try {
return Beans.instantiate(null, name);
} catch (Throwable th) {
if (com.bbn.openmap.util.Debug.debugging("beanbox")) {
System.err.println(th);
th.printStackTrace();
if (name.indexOf('\\') >= 0) {
System.err.println(" Note that file names in manifests must use forward "
+ "slashes \"/\" \n rather than back-slashes \"\\\"");
}
}
return null;
}
}
示例15: setBeanInstances
import java.beans.Beans; //導入依賴的package包/類
/**
* Describe <code>setBeanInstances</code> method here.
*
* @param beanInstances a <code>Vector</code> value
* @param container a <code>JComponent</code> value
*/
public static void setBeanInstances(Vector beanInstances,
JComponent container) {
reset(container);
if (container != null) {
for (int i = 0; i < beanInstances.size(); i++) {
Object bean = ((BeanInstance)beanInstances.elementAt(i)).getBean();
if (Beans.isInstanceOf(bean, JComponent.class)) {
container.add((JComponent)bean);
}
}
container.revalidate();
container.repaint();
}
COMPONENTS = beanInstances;
}