Re: Connection from one tree node to another

2002-08-27 Thread Kurt Baumgarten


The paint method of JComponent calls paintComponent, paintBorder
and paintChildren.   The container that holds the two trees will
call paintChildren, which will cause the trees to be painted.
So I'd think if you override the paint method of the container, and
put your drawing code *after* the call to paintChildren, then the
arrow will appear on top of the two trees.
Eg.,

public void paint(Graphics g)
{
   paintComponent( g)
   paintBorder(g)
   paintChildren(g)
   // insert drawing code here.
}

You'd need to subclass your container to override this method.   You'd
call repaint on the container when the node finishes dragging.

--Kurt

From: Deepesh Bhar [EMAIL PROTECTED]
Subject: Connection from one tree node to another
To: [EMAIL PROTECTED]

Hello All,

I am trying to develop a UI that has 2 panes showing
JTrees. I want such a functionality that if a user
drags a node from one tree to another then an arrow
should be drawn from the dragged tree node to the node
where node was dropped. The intension is not to cut
the node and paste on other end but only to show that
these tree node are connected. This should only be
possible between two different tree nodes and should
not be affected if tree is resized.

Does anyone has any pointers or code snippets to help
me out??? I am kinda stuck here.


Thanks in advance
Dennis



___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Calling a jInternalFrame from JFrame

2002-03-10 Thread Kurt Baumgarten

The best place to start is to compare your code with the code in 
JavaSoft's Java tutorial.
The section on How to Use Internal Frames has an example in which a 
JInternalFrame
is opened from a JFrame actionListener.

--Kurt

___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: titled border problem

2002-03-01 Thread Kurt Baumgarten




According to the JavaSoft Swing tutorial, 

"When you invoke the setText method on a component, for example, the
component should automatically repaint itself and, if appropriate,
resize itself. If it doesn't, it's a bug."

I would think that would apply to "setTitle" also, but perhaps not.

The tutorial also says of paintBorder:

"paintBorder -- Tells the component's border (if any) to paint. Do not
invoke or override this method."

(This is in the "Working with Graphics" section.)

If you absolutely have to avoid painting the JPanel, you
could try calling repaint(int,int,int,int), which defines a clipping
area for the repaint operation.   Not sure how you'd get the width
and height of the Border, since it doesn't inherit from JComponent.
Maybe getBorderInsets?

--Kurt 

--- In [EMAIL PROTECTED], Jaspreet Singh [EMAIL PROTECTED] wrote:


   Hi
 	I am facing a problem that after changing the title of a titled
 border on a swing panel i am not being able to call the border's
 paintBorder(...) function correctly. the border is on the panel and
 panel.repaint() works perfectly fine but since i am just changing

  
  the title

  
 of the border i don't want to repaint the whole panel. the problem


is that


   the graphics object being passed is null. i don't even know if i'm

  
  calling

  
 the function correctly ! i am getting a NullPointerException. 
 
 i am calling the function as:
 
 myBorder.paintBorder(panel, panel.getGraphics(),  0, 0,


panel.getWidth(),


   panel.getHeight());	// myBorder is attached to panel
 
 and the stack trace is:
 
 Exception occurred during event dispatching: 
 java.lang.NullPointerException 	
 at java.awt.Rectangle.setBounds(Rectangle.java:251) 	
 at javax.swing.border.TitledBorder.paintBorder(T

  
  itledBorder.java:329) 	

  
 at myui.MyPanel$1.valueChanged(MyPanel.java:50) 	
 at



javax.swing.DefaultListSelectionModel.fireValueCha
nged(DefaultListSelectionM


   odel.java:170) 	
 at


  
  javax.swing.DefaultListSelectionModel.fireValueCha
nged(DefaultListSelectionM

  
 odel.java:140) 	
 at



javax.swing.DefaultListSelectionModel.setValueIsAd
justing(DefaultListSelecti


   onModel.java:507) 	
 at


  
  javax.swing.plaf.basic.BasicTableUI$MouseInputHand
ler.setValueIsAdjusting(Ba

  
 sicTableUI.java:443) 	
 at



javax.swing.plaf.basic.BasicTableUI$MouseInputHand
ler.mouseReleased(BasicTab


   leUI.java:486) 
 at

  
  java.awt.AWTEventMulticaster.mouseReleased(AWTEven
tMulticaster.java:231)

  
 
 at java.awt.Component.processMouseEvent(Component.java:3717) 	
 at java.awt.Component.processEvent(Component.java:3546) 	
 at java.awt.Container.processEvent(Container.java:1164) 	
 at java.awt.Component.dispatchEventImpl(Component.java:2595) 	
 at java.awt.Container.dispatchEventImpl(Container.java:1213) 	
 at java.awt.Component.dispatchEvent(Component.java:2499) 	
 at


java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)


   
 at java.awt.LightweightDispatcher.processMouseEv

  
  ent(Container.java:2216)

  
 
 at java.awt.LightweightDispatcher.dispatchEvent(


Container.java:2125) 	


   at java.awt.Container.dispatchEventImpl(Container.java:1200) 	
 at java.awt.Window.dispatchEventImpl(Window.java:912) 	
 at java.awt.Component.dispatchEvent(Component.java:2499) 	
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:319) 	
 at

  
  java.awt.EventDispatchThread.pumpOneEvent(EventDis
patchThread.java:103)

  
 
 at java.awt.EventDispatchThread.pumpEvents(Event


DispatchThread.java:93)


   
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
 
 is there any way i can call this function successfully? or will i

  
  have to

   use panel.repaint()?
 
 thanks in advance,
 jassi