Hi Alan, Firstly, ULC is a server-side GUI library and you cannot use Swing Widgets in your server-side ULC application.
You have to use ULC widgets like ULCButton, ULCFrame etc. to build the GUI of your application. ULC offers different layout panels (equivalent of JPanel with layout) - ULCBoxPane, ULCGridBagLayoutPane, ULCFlowLayoutPane, ULCBoxLayoutPane etc. In case you want to customize a ULC widget, you need to create an extension of the ULC widget which involves creating a server side proxy and a client side proxy. This is described in the ULC Extension Guide. At the end of this mail you will find a sample code snippet. Thanks and regards, Janak ________________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of alan aherne Sent: Thursday, April 03, 2008 5:20 AM To: [email protected] Subject: [ULC-developer] paintComponent and JPanel Hi, I am new to ULC and am having some problems with my first few attempts to check if ULC will work for my planned software. I need to use paintComponent as in the basic 'MyPanel' example below. I have searched the old posts hereĀ and found an example that uses 'UiJPanel' that would seem to be an option, however I can't find the 'import com.ulcjava.base.client.UiJPanel'. Can somebody please point me in the right direction. Is there a ULC substitute for JPanel ?? If not is there any examples as to how I go about painting a grid or likewise that would help me get started. Thank you for any help. Al package painting; import javax.swing.SwingUtilities; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.BorderFactory; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; public class SwingPaintDemo2 { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } private static void createAndShowGUI() { System.out.println("Created GUI on EDT? "+ SwingUtilities.isEventDispatchThread()); JFrame f = new JFrame("Swing Paint Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new MyPanel()); f.pack(); f.setVisible(true); } } class MyPanel extends JPanel { public MyPanel() { setBorder(BorderFactory.createLineBorder(Color.black)); } public Dimension getPreferredSize() { return new Dimension(250,200); } public void paintComponent(Graphics g) { super.paintComponent(g); // Draw Text g.drawString("This is my custom Panel!",10,20); } } ----------------------------------------------- import java.awt.Graphics; import com.ulcjava.base.application.AbstractApplication; import com.ulcjava.base.application.ULCBoxPane; import com.ulcjava.base.application.ULCButton; import com.ulcjava.base.application.ULCFrame; import com.ulcjava.base.application.event.ActionEvent; import com.ulcjava.base.application.event.IActionListener; import com.ulcjava.base.client.UIGridBagLayoutPane; import com.ulcjava.base.development.DevelopmentRunner; public class PaintPanelSnippet extends AbstractApplication { public void start() { final ULCBoxPane pane = new ULCMyBoxPane(); ULCButton button = new ULCButton("Button"); button.addActionListener(new IActionListener() { public void actionPerformed(ActionEvent event) { } }); pane.add(ULCBoxPane.BOX_CENTER_CENTER, button); ULCFrame frame = new ULCFrame("TableNoDataSnippet"); frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); frame.add(pane); frame.setSize(300, 300); frame.setVisible(true); } public static void main(String[] args) { DevelopmentRunner.setApplicationClass(PaintPanelSnippet.class); DevelopmentRunner.run(); } // server side class public static class ULCMyBoxPane extends ULCBoxPane { protected String typeString() { return UIMyBoxPane.class.getName(); // replace with fully qualified name string of client side class } } // client side class public static class UIMyBoxPane extends UIGridBagLayoutPane { protected Object createBasicObject(Object[] arguments) { return new MyBasicPane(); } public class MyBasicPane extends BasicGridBagLayoutPane { public void paint(Graphics g) { super.paint(g); g.drawString("This is my custom Panel!", 10, 20); } } } }
