JScrollPane based component

Hi all,
There's a common feature in office applications (including MS Excel) where a user can load in a text file which has been layed out with fixed width columns (not delimited, actually set out with X characters until next column).
The interface used by these applications is one where a use can click to create, and hold to drag column lines around to show how a lump of text is to be split into columns.
I'm trying to create a component like this, but I'm having real troubles with it!
I'm thinking it should be based on a JScrollPane which contains a JTextArea (containing the text and also some custom painting method for the vertical lines) and a JLabel (or something) that has custom painting and event handling for displaying and moving columns around (an inverted triangle I guess).
The JLabel will have to be as wide as the JTextArea, which itself needs to be as wide as the long line of text it contains.
I haven't even got so far as to produce an useful code to post here yet, as my experimenting has failed completely at the prototype stage! I'm even having trouble getting anything to show inside a JScrollPane when not supplying the component in the constructor!
I can do the dragging/painting/lines/columns nonsense myself once I have something to work from, but I'm desperate to work out a solution for simply displaying the scrollpane/ textarea-wide-enough-for-displaying-its-own-text / JLabel-same-width-as-textarea combination!
Can anyone help?

you may try this:
import java.awt.*;
import javax.swing.*;
public class Testing extends javax.swing.JFrame {
     private JScrollPane jScrollPane1;
     private JLabel jLabel1;
     private JTextArea jTextArea1;
     public static void main(String[] args) {
          Testing inst = new Testing();
          inst.setVisible(true);
     public Testing() {
          super();
          initGUI();
     private void initGUI() {
          try {
               GridLayout thisLayout = new GridLayout(2, 1);
               this.getContentPane().setLayout(thisLayout);
               setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                    jScrollPane1 = new JScrollPane();
                    this.getContentPane().add(jScrollPane1);
                    jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                    jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
                         jTextArea1 = new JTextArea();
                         jScrollPane1.setViewportView(jTextArea1);
                    jLabel1 = new JLabel();
                    this.getContentPane().add(jLabel1);
                    jLabel1.setText("Label");
               pack();
               setSize(300, 200);
          } catch (Exception e) {
               e.printStackTrace();
}

Similar Messages

  • Editable assets within a swc-based component

    Hi there,
    I created several swc-based components with AS3 and Flash CS4 extending the UIComponent structure. After exporting a fla-based component to a swc-file i created a flash-extension with the Adobe Extension Manager and installed the component.
    This swc-based component works fine and shows up in the component panel, but i'm not able to edit the components assets because they don't show up in the library anymore.
    Can someone please tell me if there's a way to export the components assets respectively the components symbols with the swc-file in order make them editable and show up in the library of the FLA which's using the component?
    Thank you!
    Best regards,
    Daniel

    Hi there,
    has none one encountered this problem yet? Somehow it must be possible to export the assets with the swc-component so they are still editable.
    Thx!
    Daniel

  • [svn:fx-trunk] 8271: Change the event type of List-based component's change , changing and caretChange events to a new event class: spark.events. IndexChangeEvent.

    Revision: 8271
    Author:   [email protected]
    Date:     2009-06-25 16:25:28 -0700 (Thu, 25 Jun 2009)
    Log Message:
    Change the event type of List-based component's change, changing and caretChange events to a new event class: spark.events.IndexChangeEvent.
    QA: Yes
    Doc: Yes
    Checkintests: Pass
    Mustella: List/DDL/ButtonBar tests pass
    Reviewers: Hans & Jason
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/events/IndexChangedEvent.as
        flex/sdk/trunk/frameworks/projects/spark/asdoc/en_US/spark/components/examples/ButtonBarE xample.mxml
        flex/sdk/trunk/frameworks/projects/spark/asdoc/en_US/spark/components/examples/DropDownLi stExample.mxml
        flex/sdk/trunk/frameworks/projects/spark/asdoc/en_US/spark/components/examples/ListExampl e.mxml
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/ButtonBar.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
    Added Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/events/IndexChangeEvent.as

    Are those components in a SWC?  I would expect them to also have a namespace
    that looks more like http://.....
    Otherwise, make sure the path to the components are correct.

  • Can we rebrand flex based component using CSS?

    Hi,
    We are new to Flex.
    We just built a custom grid component extending ADG using version 4. We would like the consumers (other application developers) use this component within other J2EE based applications with additional customization like
    branding or themes. --- can we use external CSS ?
    grid columns, order, initial sort order, filtering, , data source   ( or backend service url )  to retrieve data, etc ? how can we do it? if this component is offered as an HTTP(S) url, can we pass in parameters to customize before framing it ? which is the best way ?
    Please let us know whether it is possible ? If so, how best we can implement it ? Any examples out there? Appreciate if someone can share. It will help us to add this custom grid to our component repository.
    Thanks in advance,
    -Shiva

    hi,
    Thanks for the quick reply. It will be helpful if you have any examples of customization by passing in FlashVars or thru ExternalInterface. Appreciate your time and help.
    For styling, it is very disappointing to know that we are limited. If there is a way to tweak in that will help while Adobe comes out with additional support for styling in future versions.
    -Shiva

  • How to create and call a COM component in Java

    Hi All,
    can you suggest how to create and call a COM component..or if have any sample simple application can you send it to me...i will try to develop my project.
    actually i am configuring a OCR Engine using SDK which is in VB .Net when i contacted their support they told that if i have any sample COM based component Project they will help me...
    So please can you help in this.
    Thanks in advance.

    As said by my fellow posters Java Devolopment Environment (Except Microsoft implementation of JVM,this is no longer supported by MS themseleves) does not provide an built-in support to serve this cause.
    If you are looking to devolop a custom based solution the below is a good place to start with where end user is talking about Java <=> JNI <=> Native <=> COM connectivity.
    [http://bloggershetty.blogspot.com/2004/12/java-jni-com-activex-bridge-lots-of.html]
    However,if you are looking for ready made solutions ?
    Implementation any one of the solutions stated below might serve your cause.
    Open Source Solutions:
    [http://j-interop.org/]
    [http://www.danadler.com/jacob/]
    Commercial Solutions:
    [http://javacombridge.com/]
    [http://www.jnbridge.com/]
    [http://www.nevaobject.com/j2cdetails.asp?kw=java%20com%20bridge]
    [http://j-integra.intrinsyc.com/]
    Hope this might help :)
    REGARDS,
    RaHuL

  • Problem with space between rendered items in a list component

    Hi,
        Thanks again for taking your time to read my newbie posts. I found (and prove) over the internet that I can set some space between rendered items of a list based component using paddingTop and padding Bottom (vertical space), so I asume that I can do the same thing with paddingLeft and paddingRight. But as a matter of fact, it didn't work, why? that's what I would like to know, and how can I solve this. I would really apreciate if you help me do this.
    Thanks again
    Sebastián Toro O.

    Yeah, it is inconsistent.  The renderer has to implement paddingLeft/Right.
    It was done this way for performance reasons.  The Spark List in Flex 4 is
    more consistent.

  • JScrollPane in a JFrame scrollbars visible but not functional no thumbtabs

    Here is the code that I compiled and run on J2SE v. 1.4.2 (runtime b28). I looked through the various related articles and nothing seems to help with this issue. The scrollbars appear along with the panel but the thumbtabs are not present. Any help would be appreciated.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test {
      public static void main(String[] args){
        Test rce = new Test();
        JFrame frame = new JFrame("Test Scroll");
        JScrollPane scrollBar = new JScrollPane();
        scrollBar.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        scrollBar.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        Component  rcePage = rce.createComponents();
        scrollBar.getViewport().add(rcePage, null);
        frame.getContentPane().add(scrollBar, null);
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.pack();
        frame.setSize(400, 400);
        frame.setVisible(true);
      public Component createComponents() {
        JPanel pan = new JPanel();
        JLabel label = new JLabel("This is a Test!");
        pan.setBorder(BorderFactory.createEmptyBorder(
            0, //top
            0, //left
            0, //bottom
            0) //right
        pan.setLayout(null);
        label.setBounds(100, 100, 80, 20);
        pan.add(label);
        return pan;
    }

    This is a very common mistake. When you put a JPanel in a scrollpane, the scrollpane will use the panel's preferred size to determine if scrolling is needed or not. If the panel is using a LayoutManager this is generally done for you automatically. But in your case you set the layout to null, and then it is your responsibility to make sure that the getPreferredSize() method of the panel returns the correct size.
    One way to fix this in the code you posted would be to override the getPreferredSize() of the panel, like so:
        public Component createComponents() {
            JPanel pan = new JPanel() {
                public Dimension getPreferredSize() {
                    return getSize();
        }Then the scrollbars will appear if you make the frame smaller.
    But what I really suggest is that you use a LayoutManager.

  • Creating flash cs3 component

    Hi,
    There is great and easy way to create flash based component
    in flash cs3 using action script 3.0.
    I am going to make a simple My button component which will
    behave likely same as flash native button component.
    You can modify this according your requirement this is just
    you give an idea about how we can go for creating a component in
    flash cs3.
    Follow these steps…
    1. Create a fla file and save this file with any name
    2. Create a movieClip and draw a rectangle shape on first
    frame.
    3. Right click on movieclip in library, select linkage
    4. Provide class name in text field area [MyButton] (you can
    use any name here which should matched with your class)
    5. Click Ok button
    6. Write class [MyButton]
    (you can copy and use this)
    * author @ sanjeev rajput
    * [email protected]
    * A flash action script 3.0 based component without extending
    UIComponent class
    package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import fl.motion.Color;
    public class MyButton extends Sprite{
    private var _tf:TextField;
    private var _Label:String="My Button";
    private var _bgColor:uint=0xCCCCCC;
    private var _rollOverColor:uint=0xFFCCCC;
    private var _borderColor:uint=0x000000;
    private var _borderThickness:int=1;
    private var _width:Number = 100;
    private var _height:Number =100;
    private var _background:Sprite;
    public function MyButton() {
    init();
    createChildren();
    initEventListeners();
    draw();
    //-------------property section [Start]
    [Inspectable]
    public function set Label(lbl:String){
    _Label=lbl;
    draw();
    public function get Label(){
    return _Label
    [Inspectable]
    public function set bgColor(color:uint):void{
    _bgColor=color;
    draw();
    [Inspectable]
    public function set borderColor(color:uint):void{
    _borderColor=color;
    draw();
    [Inspectable]
    public function set borderThickness(thickness:int):void{
    _borderThickness=thickness;
    [Inspectable]
    public function set rollOverColor(color:uint):void{
    _rollOverColor=color;
    //-------------property section [End]
    private function init():void {
    trace('welcome');
    _width = width;
    _height = height;
    scaleX = 1;
    scaleY = 1;
    removeChildAt(0);
    private function initEventListeners():void{
    addEventListener(MouseEvent.MOUSE_OVER, eventHandler);
    addEventListener(MouseEvent.MOUSE_OUT, eventHandler);
    private function eventHandler(event:Event):void{
    if(event.type == MouseEvent.MOUSE_OVER){
    toggleColor(_rollOverColor);
    if(event.type == MouseEvent.MOUSE_OUT){
    toggleColor(_bgColor)
    private function createChildren():void {
    _background = new Sprite();
    _tf = new TextField();
    _tf.autoSize = "center";
    _tf.selectable=false;
    addChild(_background);
    addChild(_tf);
    protected function draw():void {
    toggleColor(_bgColor);
    _tf.text = _Label;
    _tf.x = Math.floor((_width - _tf.width)/2);
    _tf.y = Math.floor((_height - _tf.height)/2);
    //width = _tf.width;
    private function toggleColor(color:uint):void{
    _background.graphics.clear();
    _background.graphics.beginFill(color, 1);
    _background.graphics.lineStyle(_borderThickness,
    _borderColor, 1);
    _background.graphics.drawRoundRect(0, 0, _width, _height,
    10, 10);
    _background.graphics.endFill();
    public function setSize(w:Number, h:Number):void {
    _width = w;
    _height = h;
    draw();
    7. Now right click again on your movieclip in library and
    select component definition.
    8. In class name text field provide same class name
    [MyButton]
    9. Click on ok button
    10. Right click again on movieClip in library and select
    Export SWC file.
    11. Same your exported SWC file in (For window only)
    [c:\Documents and Settings\$user\Local Settings\Application
    Data\Adobe\Flash CS3\en\Configuration\Commands\
    12. Now just open another new flash file open component
    panel/window reload component you will your component in component
    panel with MyButton name.
    13. Drag your custom component on stage provide inputs form
    property window and text it.
    Enjoy!

    Lt.CYX[UGA] wrote:
    > if anyone is using Flash CS3, try creating a flash
    movie, using the FLVPlayer
    > component to play an flv video and make it an executable
    projector. Run it
    > fullscreen and watch how the screen just stays black
    when the video should
    > appear. If you stay windowed, it works fine.
    >
    >
    steps to reproduce:
    > 1. create flash movie
    > 2. put an FLVPlayer component on a frame that's not the
    first (for testing
    > purposes)
    > 3. before the projector reaches the frame with the
    FLVPlayer component, change
    > it to fullscreen (by script or CTRL+F)
    >
    >
    observed behaviour:
    > not only the video doesn't play, but the whole screen is
    black until the
    > player goes back to windowed mode
    >
    >
    expected behaviour:
    > video should play
    >
    >
    remarks:
    > if you skip step 3, video plays correctly
    >
    Works just fine.
    Made new movie, on frame 2 places Full screen action, on
    frame 5 placed video component
    and stop(); action attached to frame. Projector pops large
    following by video playing
    just fine.
    I tried variety, first frame, many frames, all on one. Not
    able to reproduce your problem.
    Works on first go.
    Best Regards
    Urami
    Beauty is in the eye of the beer holder...
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Passing text component to methods

    I have a method that reads a file and output puts it to a JTextArea. Everything is working fine but I am wondering if I can pass an object from a class above JTextArea (like TextComponent). Looking for a generic feel with whatever text based component I passed...will this make a difference with lightweight and heavyweigth components (swing vs. awt)? Or even streams for that matter? Will byte and character streams act differently?
    What is the super class of all text based gui components?
    What is the super class of all streams?
    Yes I have read the java api doc on streams and using swing! Thanks

    You have me until
    Everything is working fine but I am wondering if I can pass an object from a class above JTextArea (like TextComponent).What are you asking for here?
    You want to know if you can pass an object to a method? Yes.
    You want to know if you can modify a class further up in JTextArea's hierarchy, so it has a method that passes an object to another method? Yes, by extending it and implementing the functionality you want.
    Looking for a generic feel with whatever text based component I passed...will this make a difference with lightweight and heavyweigth components (swing vs. awt)?Not sure what you were asking for in the first place, so I'm unable to help you with this one.
    Or even streams for that matter? Will byte and character streams act differently?If you're asking, "When I pass a stream through a method, will it act differently when I use it inside that method?", then I can answer no, it will not. You are passing your stream by reference.
    class MyClass {
       private Object anObject;
       public MyClass() {
          anObject = new Object();
          MySecondClass secondClass = new MySecondClass(anObject);
    class MySecondClass {
       private Object theSameObject;
       public MyClass(Object argument) {
          theSameObject = argument;
    }In the above example, anObject was created in MyClass, and passed to the constructor of MySecondClass. The field theSameObject in MySecondClass is set to point to the Object passed into its constructor, which just happens to be the Object anObject created in MyClass. anObject was created in MyClass. theSameObject is essentially the exact same Object in that it references (points to) anObject.
    If I'm wrong feel free to call me on it, java gurus.
    What is the super class of all text based gui components?AWT or Swing?
    If it's AWT, look up the API for an AWT text component, try TextField, and look at the class hierarchy.
    If it's Swing, do the same for JTextField. You can easily do some detective work and figure out the super classes of 'text based gui components'.
    What is the super class of all streams?You can do the same as above for streams as well.
    Yes I have read the java api doc on streams and using swing! ThanksIf you've read the API docs on streams and Swing, then why did you ask the last two questions? Not trying to offend, it just seems kind of wierd.

  • How to handle if we need to re-load/replenish component after one SFC START

    Hi Experts,
    I am trying TBCT(Time Based Component Tracebility) function and would like to ask a question.
    For example,
        1. Resource's SLOT_QTY_DECREMENT at POST_START.
        2. Material MAT_01, lot_size = 2
        3. BOM BOM_01, assemble time based component COM_01 at Operation OPR_01, assembleQty =1
        4. I modeling one slot configuration and set COM_01 at SLOT S1.
        5. I load/replenish COM_01's inventory INV_01 into S1 and Slot_qty =1
        6. When I Start one SFC SFC_01(POD), it will consume Slot's qty 1 and now Slot S1 is empty.
        7. Because SFC_01 need to consume COM_01 2 qty, so SFC_01 still need last 1 qty.
        8. I load/replenish COM_01's into S1 and slot_qty = 5
    The Question is
        a. When I Compelete the SFC_01, ME will also consume the last 1 qty automcatically? Because I set Resource's SLOT_QTY_DECREMENT at POST_START.
        b. When SFC_01 status is Active (After Start), any function can do consume the last 1 qty manually?
        c. If not, I don't know how to handle if we need to re-load/replenish component after one SFC is already START.
    Hope someone can help me.... thanks!

    Cary
    The purpose of the hook is just to decrement the inventory in the slot. Timebased component traceability will report the total quantity required by the BOM was consumed. You can see this if you start and SFC, then replenish it whilst it is active. The as-built report will show both inventory records were consumed, and twice as much quantity as was required in the BOM.
    If you perform multiple replenishments, after the SFC is started and before it is complete, then the system just reports them all. In essence, it does not know which exact inventory IDs were consumed for this particular SFC. It's a limitation of timebased, and it's safer to over-report that the SFC may have used an inventory ID as not.

  • Component and Panels - newbie

    sometimes panels are directly added and sometimes a Component is created and panels are added to Component and then they are used in JSplitPane.
    In what kind of situations can we add directly the panel, and when do we need the Component() ?
    eg
    final Label l11 = new Label("Sections");
    DefaultListModel model = new DefaultListModel();
    JList statusList = new JList(model);
    model.addElement("Claim Info");
    model.addElement("Line Info");
    JScrollPane c13 = new JScrollPane(statusList);
    Component c11 = new claimspanel();
    Component c12 = new claimspanel();
    c12.setLayout(new GridLayout(5,1));
    clslabelpanel lbl1 = new clslabelpanel();
    c12.add(lbl1);
    c12.add(c13);
    c12.add(Box.createVerticalStrut(100));
    c12.add(Box.createVerticalStrut(100));
    c12.add(Box.createVerticalStrut(100));
    JSplitPane spLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, c12, c11);
    spLeft.setDividerSize(0);
    spLeft.setContinuousLayout(true);

    By 'use' i assume you mean, hold the reference as
    either a panel or a component.
    The answer is you should hold the reference using the type that is most generic, and still meets your needs. In this way, in the future you can adjust the implementation without effecting anyone other code. So if you need a method that is only found in panel, then hold a panel reference. If not, use container if container's methods satisfy you, otherwise use component.

  • Assembly Point with mix of time based and discrete components

    Hi all,
    I have a scenario where I want to assemble 2 different components - one of them time based (assy data EXTERNAL_LOT), the other one discrete (assy data INV_SFC).
    Resource system rule "time based resource (genealogy)" is set to true.
    I set up and loaded slot config on resource for the time based component.
    Operation is configured to not allow SFC complete if components are missing (CT520 on PRE_COMPLETE hook)
    When I start SFC at operation and resource in POD the time based component is assembled automatically (according to device history record) However, once I open assembly activity (COMP_LIST_DISPLAY, CT500) to assemble the discrete component both components are displayed as not assembled in component list. If I assemble the discrete component only and then try to complete SFC I receive an error message pointing out that not all components are assembled yet.
    I would have expected that time based component is displayed as already assembled and also CT520 hook does recognize the time based component as already assembled.
    Am I missing any settings?
    Or does such a mixed scenario not work at all?
    We are using ME 6.1.4.2
    Thanks for your help!
    BR Ulrike

    Hi,
    The issue you are seeing with CT520  whereby the hook does not recognize the time based component as already assembled was resolved in a later release.  Please patch to latest version.  Associated release notes will detail which patch fixed it.
    You would need to use assembly point in POD to add the INV_SFC
    Thanks
    Steve

  • Is there any component like the "Enhanced Gird View" of XMLSPY?

    Hi!
    I want to cusomize a XML editor.
    I am looking for any Java based component like the "Enhanced Gird View" of XMLSPY.
    http://www.xmlspy.com/features_views.html
    If you know any component like it, please tell me.
    Thank you!

    JTable?
    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]

  • Capturing Mouse Click Event Outside a Canvas/Component

    Hello Guys
    I have a canvas based component and i want to capture a mouse click event outside that component.
    How is it possible?
    Thanks a lot

    Thanks a lot Morphic
    I solved it using focusout method from my component;s textinput but your method is also good and will help me in later stages.

  • Execute RFC from PDK based development

    Hi All,
    I want to execute a RFC from PDK based component (AbstractPortalComp/JSPDynp).
    What are the different options availabel for doing executing RFC?
    Is there a way I can live without hard coding SAP system Connetion params in the project code or in a properties file?
    Any help is appreciated.
    Thanks
    Aakash

    Hi,
    you could also use Sap Enterprise Connector - see [http://help.sap.com/saphelp_webas630/helpdata/en/79/c6213e225f9a0be10000000a114084/frameset.htm|http://help.sap.com/saphelp_webas630/helpdata/en/79/c6213e225f9a0be10000000a114084/frameset.htm] for more info.
    For getting the client without specifying the login/pass in the code just get it from the usermapping of the current user (from the request) for the alias of the system used:
        IJCOClientService clientService =
          (IJCOClientService) PortalRuntime.getRuntimeResources().getService(IJCOClientService.KEY);
        IJCOClientPoolEntry poolEntry = clientService.getJCOClientPoolEntry(systemAlias, request);
        Client client = poolEntry.getJCOClient();
        if (!client.isAlive()) {
          client.connect();
    the rest is as usual - see the help.
    Romano

Maybe you are looking for