/**
* This method initializes this
*/
private void initialize() {
// --- Set appearance -----------------------------
this.setVisible(true);
this.setSize(300,300);
this.setLayout(new BorderLayout());
this.setDoubleBuffered(true);
// --- Add components -----------------------------
this.add(this.getJPanelToolBars(),BorderLayout.WEST);
this.add(this.getGraphZoomScrollPane(),BorderLayout.CENTER);
this.addContainerListener(new ContainerAdapter() {
boolean doneAdded = false;
@Override
public void componentAdded(ContainerEvent ce) {
if (doneAdded==false) {
validate();
zoomSetinitialScalingAndMovement(getVisualizationViewer());
doneAdded=true;
}
}
});
}
@Override
public void componentAdded(ContainerEvent e) {
JTabbedPane tp = (JTabbedPane) e.getContainer();
Component child = e.getChild();
if (child instanceof UIResource) {
return;
}
int index = tp.indexOfComponent(child);
String title = tp.getTitleAt(index);
boolean isHTML = BasicHTML.isHTMLString(title);
if (isHTML) {
if (htmlViews == null) { // Initialize vector
htmlViews = createHTMLVector();
}
else { // Vector already exists
View v = BasicHTML.createHTMLView(tp,title);
htmlViews.insertElementAt(v,index);
}
}
else { // Not HTML
if (htmlViews != null) { // Add placeholder
htmlViews.insertElementAt(null,index);
} // else nada!
}
}
@Override
public void componentRemoved(ContainerEvent e) {
JTabbedPane tp = (JTabbedPane) e.getContainer();
Component child = e.getChild();
if (child instanceof UIResource) {
return;
}
// NOTE 4/15/2002 (joutwate):
// This fix is implemented using client properties since there is
// currently no IndexPropertyChangeEvent. Once
// IndexPropertyChangeEvents have been added this code should be
// modified to use it.
Integer indexObj = (Integer) tp.getClientProperty("__index_to_remove__");
if (indexObj != null) {
int index = indexObj.intValue();
if (htmlViews != null && htmlViews.size() >= index) {
htmlViews.removeElementAt(index);
}
}
}
/**
* Called when a container event occurs if container events are enabled.
* This method calls any registered listeners.
*
* @param e The event that occurred.
*/
protected void processContainerEvent(ContainerEvent e)
{
if (containerListener == null)
return;
switch (e.id)
{
case ContainerEvent.COMPONENT_ADDED:
containerListener.componentAdded(e);
break;
case ContainerEvent.COMPONENT_REMOVED:
containerListener.componentRemoved(e);
break;
}
}
/**
* This method is responsible for setting rollover or non rollover for new
* buttons added to the JToolBar.
*
* @param e The ContainerEvent.
*/
public void componentAdded(ContainerEvent e)
{
if (e.getChild() instanceof JButton)
{
JButton b = (JButton) e.getChild();
if (b.getBorder() != null)
borders.put(b,b.getBorder());
}
if (isRolloverBorders())
setBorderToRollover(e.getChild());
else
setBorderToNonRollover(e.getChild());
cachedBounds = toolBar.getPreferredSize();
cachedOrientation = toolBar.getorientation();
Component c = e.getChild();
if (toolBarFocusListener != null)
c.addFocusListener(toolBarFocusListener);
}
@Override
protected void focusedComponentChanged(final Component component,final AWTEvent cause) {
EditorWindow newWindow = null;
if (component != null) {
newWindow = findWindowWith(component);
}
else if (cause instanceof ContainerEvent && cause.getID() == ContainerEvent.COMPONENT_REMOVED) {
// do not change current window in case of child removal as in JTable.removeEditor
// otherwise Escape in a toolwindow will not focus editor with JTable content
return;
}
setCurrentwindow(newWindow);
setCurrentwindow(newWindow,false);
}
public void componentAdded(ContainerEvent evt) {
Component c = evt.getChild();
if (toolBarFocusListener != null) {
c.addFocusListener(toolBarFocusListener);
}
if (isRolloverBorders()) {
setBorderToRollover(c);
}
else
{
setBorderToNonRollover(c);
}
//## Bug FIX:Issue 51(https://code.google.com/p/beautyeye/issues/detail?id=51)
//* 由Jack Jiang201210-12日注释掉:它样做将导致各种放入的组
//* 件(如文本框)等都将透明,从而不绘制该 组件的背景,那就错误了哦
//* 其实以下代码原本是为了解决放入到JToggleButton的白色背景问题,现在它
//* 已经在BetoolgleButtonUI里解决了,此处就不需要了,也不应该要!
// //* 只有它一行是由jb2011加的
// if(c instanceof JComponent)
// ((JComponent)c).setopaque(false);
}
/**
* Called when a container event occurs if container events are enabled.
* This method calls any registered listeners.
*
* @param e The event that occurred.
*/
protected void processContainerEvent(ContainerEvent e)
{
if (containerListener == null)
return;
switch (e.id)
{
case ContainerEvent.COMPONENT_ADDED:
containerListener.componentAdded(e);
break;
case ContainerEvent.COMPONENT_REMOVED:
containerListener.componentRemoved(e);
break;
}
}
/**
* This method is responsible for setting rollover or non rollover for new
* buttons added to the JToolBar.
*
* @param e The ContainerEvent.
*/
public void componentAdded(ContainerEvent e)
{
if (e.getChild() instanceof JButton)
{
JButton b = (JButton) e.getChild();
if (b.getBorder() != null)
borders.put(b,b.getBorder());
}
if (isRolloverBorders())
setBorderToRollover(e.getChild());
else
setBorderToNonRollover(e.getChild());
cachedBounds = toolBar.getPreferredSize();
cachedOrientation = toolBar.getorientation();
Component c = e.getChild();
if (toolBarFocusListener != null)
c.addFocusListener(toolBarFocusListener);
}
@Override
public void componentRemoved( ContainerEvent e )
{
if( e.getContainer( ) instanceof JTabbedPane )
{
JTabbedPane tabbedPane = ( JTabbedPane ) e.getContainer( );
if( tabbedPane.getTabCount( ) == 0 )
{
Window ancestor = SwingUtilities.getwindowAncestor( tabbedPane );
if( ancestor != null )
{
ancestor.dispose( );
}
}
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JInternalFrame) {
JInternalFrame f = (JInternalFrame) e.getChild();
JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
for (Component comp : getComponents()) {
if (comp == desktopIcon) {
// We have it already
return;
}
}
add(desktopIcon);
f.addComponentListener(this);
if (getComponentCount() == 1) {
adjustSize();
}
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof WizardPage) {
WizardPage wp = (WizardPage)e.getChild();
JButton b;
b = wp.getNextButton();
if (b != null) {
b.addActionListener(nextListener);
}
b = wp.getPrevIoUsButton();
if (b != null) {
b.addActionListener(prevIoUsListener);
}
b = wp.getFinishButton();
if (b != null) {
b.addActionListener(finishListener);
}
b = wp.getCancelButton();
if (b != null) {
b.addActionListener(cancelListener);
}
b = wp.getHelpButton();
if (b != null) {
b.addActionListener(helpListener);
}
}
}
public void componentRemoved(ContainerEvent e) {
if (e.getChild() instanceof WizardPage) {
WizardPage wp = (WizardPage)e.getChild();
JButton b;
b = wp.getNextButton();
if (b != null) {
b.removeActionListener(nextListener);
}
b = wp.getPrevIoUsButton();
if (b != null) {
b.removeActionListener(prevIoUsListener);
}
b = wp.getFinishButton();
if (b != null) {
b.removeActionListener(finishListener);
}
b = wp.getCancelButton();
if (b != null) {
b.removeActionListener(cancelListener);
}
b = wp.getHelpButton();
if (b != null) {
b.removeActionListener(helpListener);
}
}
}
/**
* ContainerListener Interface method. Should not be called directly. Part of
* the ContainerListener interface,and it's here to make the MapBean a good
* Container citizen.
*
* @param e ContainerEvent
*/
public void componentAdded(ContainerEvent e) {
// Blindly cast. addImpl has already checked to be
// sure the child is a Layer.
Layer childLayer = (Layer) e.getChild();
addProjectionListener(childLayer);
// If the new layer is in the queue to have removed() called
// on it take it off the queue,and don't add it to the
// added() queue (it doesn't kNow that it was removed,yet).
// Otherwise,add it to the queue to have added() called on
// it.
if (!removedLayers.removeElement(childLayer)) {
addedLayers.addElement(childLayer);
}
changeLayers(e);
}
/**
* ContainerListener Interface method. Should not be called directly. Part of
* the ContainerListener interface,and it's here to make the MapBean a good
* Container citizen.
*
* @param e ContainerEvent
*/
protected void changeLayers(ContainerEvent e) {
// Container Changes can be disabled to speed adding/removing
// multiple layers
if (!doContainerChange) {
return;
}
Component[] comps = this.getComponents();
int ncomponents = comps.length;
Layer[] newLayers = new Layer[ncomponents];
System.arraycopy(comps,newLayers,ncomponents);
if (logger.isLoggable(Level.FINE)) {
debugmsg("changeLayers() - firing change");
}
firePropertyChange(LayersProperty,currentLayers,newLayers);
// Tell the new layers that they have been added
for (int i = 0; i < addedLayers.size(); i++) {
((Layer) addedLayers.elementAt(i)).added(this);
}
addedLayers.removeAllElements();
currentLayers = newLayers;
}
public void componentAdded(ContainerEvent evt) {
Component c = evt.getChild();
if (toolBarFocusListener != null) {
c.addFocusListener(toolBarFocusListener);
}
if (isRolloverBorders()) {
setBorderToRollover(c);
} else {
setBorderToNonRollover(c);
}
//## Bug FIX:Issue 51(https://code.google.com/p/beautyeye/issues/detail?id=51)
//* 由Jack Jiang201210-12日注释掉:它样做将导致各种放入的组
//* 件(如文本框)等都将透明,从而不绘制该 组件的背景,那就错误了哦
//* 其实以下代码原本是为了解决放入到JToggleButton的白色背景问题,现在它
//* 已经在BetoolgleButtonUI里解决了,此处就不需要了,也不应该要!
// //* 只有它一行是由jb2011加的
// if(c instanceof JComponent)
// ((JComponent)c).setopaque(false);
}
protected void processContainerEvent(ContainerEvent e) {
// toolkit.lockAWT();
// try {
for (Iterator<?> i = containerListeners.getUserIterator(); i.hasNext();) {
ContainerListener listener = (ContainerListener) i.next();
switch (e.getID()) {
case ContainerEvent.COMPONENT_ADDED:
listener.componentAdded(e);
break;
case ContainerEvent.COMPONENT_REMOVED:
listener.componentRemoved(e);
break;
}
}
// } finally {
// toolkit.unlockAWT();
// }
}
/**
* Called when a container event occurs if container events are enabled.
* This method calls any registered listeners.
*
* @param e The event that occurred.
*/
protected void processContainerEvent(ContainerEvent e)
{
if (containerListener == null)
return;
switch (e.id)
{
case ContainerEvent.COMPONENT_ADDED:
containerListener.componentAdded(e);
break;
case ContainerEvent.COMPONENT_REMOVED:
containerListener.componentRemoved(e);
break;
}
}
/**
* This method is responsible for setting rollover or non rollover for new
* buttons added to the JToolBar.
*
* @param e The ContainerEvent.
*/
public void componentAdded(ContainerEvent e)
{
if (e.getChild() instanceof JButton)
{
JButton b = (JButton) e.getChild();
if (b.getBorder() != null)
borders.put(b,b.getBorder());
}
if (isRolloverBorders())
setBorderToRollover(e.getChild());
else
setBorderToNonRollover(e.getChild());
cachedBounds = toolBar.getPreferredSize();
cachedOrientation = toolBar.getorientation();
Component c = e.getChild();
if (toolBarFocusListener != null)
c.addFocusListener(toolBarFocusListener);
}
@Override
public void componentAdded(ContainerEvent e) {
Component c = e.getChild();
while(((c = c.getParent()) != null)) {
if(c instanceof TopComponent) {
RequestProcessor.Task t = (RequestProcessor.Task) ((TopComponent)c).getClientProperty(REGISTER_TASK);
if(t != null) {
t.schedule(1000);
}
break;
}
}
}
@Override
public void componentAdded(ContainerEvent e) {
Component c = e.getChild();
while(((c = c.getParent()) != null)) {
if(c instanceof TopComponent) {
RequestProcessor.Task t = (RequestProcessor.Task) ((TopComponent)c).getClientProperty(REGISTER_TASK);
if(t != null) {
t.schedule(1000);
}
break;
}
}
}
public void componentAdded(ContainerEvent e) {
JMenu menu = (JMenu) e.getContainer();
JComponent item = (JComponent) e.getChild();
//Mark the child as belonging to the parent container context
String containerContext = getContainerContext(menu);
item.putClientProperty (KEY_CONTAINERCONTEXT,containerContext);
}
public void componentAdded(ContainerEvent e) {
Container c = (Container) e.getSource();
boolean isEditorToolbar = "editorToolbar".equals (c.getName());
installButtonUI (e.getChild(),isEditorToolbar);
if (isEditorToolbar) {
//It's an editor toolbar. Aqua's combo Box ui paints outside
//of its literal component bounds,and doesn't honor opacity.
//Need to ensure the toolbar is tall enough that its border is
//not hidden.
Dimension min = new Dimension (32,34);
((JComponent)e.getContainer()).setPreferredSize(min);
}
}
public void componentRemoved(ContainerEvent e) {
// �������
clearEmptyRow();
// �������
int rows = table.getRowCount();
int count = 0;
double money = 0.0;
// ����Ʒ������
TbKucun column = null;
if (rows > 0)
column = (TbKucun) table.getValueAt(rows - 1,0);
if (rows > 0 && (column == null || column.getId().isEmpty()))
rows--;
// �����Ʒ�����ͽ��
for (int i = 0; i < rows; i++) {
String column7 = (String) table.getValueAt(i,7);
String column6 = (String) table.getValueAt(i,6);
int c7 = (column7 == null || column7.isEmpty()) ? 0 : Integer
.parseInt(column7);
Double c6 = (column6 == null || column6.isEmpty()) ? 0 : Double
.valueOf(column6);
count += c7;
money += c6 * c7;
}
pzs.setText(rows + "");
hpzs.setText(count + "");
hjje.setText(money + "");
// /////////////////////////////////////////////////////////////////
}
public void componentRemoved(ContainerEvent e) {
// �������
clearEmptyRow();
// �������
int rows = table.getRowCount();
int count = 0;
double money = 0.0;
// ����Ʒ������
TbSpinfo column = null;
if (rows > 0)
column = (TbSpinfo) table.getValueAt(rows - 1,6);
int c7 = (column7 == null || column7.isEmpty()) ? 0 : Integer
.parseInt(column7);
float c6 = (column6 == null || column6.isEmpty()) ? 0 : Float
.parseFloat(column6);
count += c7;
money += c6 * c7;
}
pzs.setText(rows + "");
hpzs.setText(count + "");
hjje.setText(money + "");
// /////////////////////////////////////////////////////////////////
}
public void componentRemoved(ContainerEvent e) {
// �������
clearEmptyRow();
// �������
int rows = table.getRowCount();
int count = 0;
double money = 0.0;
// ����Ʒ������
TbSpinfo column = null;
if (rows > 0)
column = (TbSpinfo) table.getValueAt(rows - 1,6);
int c7 = (column7 == null || column7.isEmpty()) ? 0 : Integer
.parseInt(column7);
Double c6 = (column6 == null || column6.isEmpty()) ? 0 : Double
.valueOf(column6);
count += c7;
money += c6 * c7;
}
pzs.setText(rows + "");
hpzs.setText(count + "");
hjje.setText(money + "");
// /////////////////////////////////////////////////////////////////
}
public void componentRemoved(ContainerEvent e) {
// �������
clearEmptyRow();
// �������
int rows = table.getRowCount();
int count = 0;
double money = 0.0;
// ����Ʒ������
TbSpinfo column = null;
if (rows > 0)
column = (TbSpinfo) table.getValueAt(rows - 1,6);
int c7 = (column7 == null || column7.isEmpty()) ? 0 : Integer
.valueOf(column7);
Double c6 = (column6 == null || column6.isEmpty()) ? 0 : Double
.valueOf(column6);
count += c7;
money += c6 * c7;
}
pzs.setText(rows + "");
hpzs.setText(count + "");
hjje.setText(money + "");
// /////////////////////////////////////////////////////////////////
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public void componentAdded(ContainerEvent e) {
Jbuttonbar container = (Jbuttonbar)e.getContainer();
if (e.getChild() instanceof AbstractButton) {
((buttonbarUI)container.ui).installbuttonbarUI(
(AbstractButton)e.getChild());
((AbstractButton)e.getChild()).addPropertychangelistener(
"UI",Jbuttonbar.uiUpdater);
}
}
/**
* Records the addition of a window to the desktop.
*
* @see java.awt.event.ContainerListener#componentAdded(java.awt.event.ContainerEvent)
*/
public void componentAdded(ContainerEvent e) {
if ((this.windowPositioner != null) && (e.getChild() instanceof JInternalFrame)) {
JInternalFrame frame = (JInternalFrame) e.getChild();
Point position = this.windowPositioner.getPosition(frame,getAllVisibleFrames());
frame.setLocation(position);
}
updateWindowsList();
}
@Override
public final void componentAdded(final ContainerEvent e) {
ProjectFrame projectFrame = this.getMainFrame().getProjectFrameFromGui(
e.getChild());
if (projectFrame != null && projectFrame instanceof ProjectFrame) {
this.addComponent(projectFrame.getLayerViewPanel());
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public void componentAdded(ContainerEvent e) {
if (e.getChild() instanceof JTextComponent) {
e.getChild().addFocusListener(this);
viewportViewHasFocus = e.getChild().isFocusOwner();
scrollpane.repaint();
}
}
public synchronized void remove(final Component comp) {
if(components == null){
return;
}
final int index = components.indexOf(comp);
if (index >= 0) {
components.remove(index);
comp.parent = null;
final ViewGroup layoutView = (ViewGroup)getContainerViewAdAPI();
final View subView = comp.getPeerAdAPI();
if(layoutView != null && subView != null){
ActivityManager.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
layoutView.removeView(subView);
}
});
}
{
final ContainerEvent event = new ContainerEvent(this,ContainerEvent.COMPONENT_REMOVED,comp);
final ContainerListener[] listener = list.getListeners(ContainerListener.class);
for (int i = 0; i < listener.length; i++) {
listener[i].componentRemoved(event);
}
}
}
if (layout != null) {
layout.removeLayoutComponent(comp);
}
}
/**
* Receives notification when a child component is added to the
* JComponent and fires a PropertyChangeEvent on listeners registered
* with the AccessibleJComponent with a property name of
* {@link AccessibleContext#ACCESSIBLE_CHILD_PROPERTY}.
*
* @param event the container event
*/
public void componentAdded(ContainerEvent event)
{
Component c = event.getChild();
if (c != null && c instanceof Accessible)
{
AccessibleContext childCtx = c.getAccessibleContext();
AccessibleJComponent.this.firePropertyChange
(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,null,childCtx);
}
}
/**
* Receives notification when a child component is removed from the
* JComponent and fires a PropertyChangeEvent on listeners registered
* with the AccessibleJComponent with a property name of
* {@link AccessibleContext#ACCESSIBLE_CHILD_PROPERTY}.
*
* @param event the container event
*/
public void componentRemoved(ContainerEvent event)
{
Component c = event.getChild();
if (c != null && c instanceof Accessible)
{
AccessibleContext childCtx = c.getAccessibleContext();
AccessibleJComponent.this.firePropertyChange
(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,childCtx,null);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。