Working with multiple swing classes

First off let me preface this by saying that I am relatively new to java and oop and am learning on my own.
I wrote a text editor by extending JFrame and then adding all the panels, menu items and the textarea all in the extended class. I have a second class that basically creates a new instance of the extended class.
My question is this: I decided that I wanted to 1)clean up the code and get some better encapsulation and 2) move to using internal frames for multiple documents. The problem is I'm unsure of how to do this. Should I create classes that extend components(IE extend JMenu to make a class that full makes my file menu)? If so, is there a way to perform operations on things in the class that instantiates the sub class? (IE if new file is selected is there a way that the parent frame can be instructed to create a new frame?)
I know that this is a pretty broad question and poorly worded due to my lack of knowledge, but any assistance would be greatly appreciated.
Ryan

Well, in general the more classes the better. But this rule does not apply in constructing GUI. Keep the JMenu as a private instance of the class that extends JFrame. Basically keep all the GUI inside that JFrame class because you may need access to instance variables that are in JFrame. If you want to create another frame when the user selects something in JMenu, then you can create an inner class inside that JFrame class since it will have access to the private instances of the outer class. This will organize your code. Do not extend JFrame for that pop up window, JDialogs are for that. Check the Java Tutorial for using them.
Nikita

Similar Messages

  • Working with Multiple Files in Workspace Layout

    If I was working with multiple files in the workspace layout, they each used to be available for selection from a tab.  Now I can either cascade the files horizontally or vertically - but not have them appear in a tab across the top of the workspace layout.
    Does anyone know how to set the workspace to present multiple files in tabs?  I have CS3.

    Tanya,
    This may not help, but the times when that happens to me is when I go too fast and some operations haven't finished. I then try to select a file that hasn't completed and the file I select is in the process of having the data updated. The worst is when it is trying to render as I am doing something.
    I hope this helps some.
    Mel

  • Working with  multiple layers in CS 3 ?

    In order to work with multiple layers in cs3, I first need to open few images to work with,and when I open few images it only shows last image that I opened.Frist images can't be seen in workspace, and when I open new document I can't see not even one photo I opened?

    try tapping the F key a few times until you get to the screen mode that allows you to see all image windows.

  • Working with AS3 External Classes

    Ok... trying to work with AS3 external classes. I have a movieClip that I want to also function as a button. Instance name is "_onDemand". This movieClip is on the stage of my Home.fla.  "_onDemand" movieClip properties   Class:HomePage  Base clase: flash.display.MovieClip
    I want the user to click this movieClip and take the user to an external URL within a new browser window or tab.
    Can anyone help me? Or at least point me to a really really good tutroial that does exactly this using external classes?
    Thanks so much,
    Mark
    My code:
    package com.cox4college.pages
    import com.gaiaframework.templates.AbstractPage;
    import com.gaiaframework.events.*;
    import com.gaiaframework.debug.*;
    import com.gaiaframework.api.*;
    import flash.display.*;
    import flash.events.*;
    import com.greensock.TweenMax;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    public class HomePage extends AbstractPage
    public function HomePage()
    super();
    alpha = 0;
    //new Scaffold(this);
    override public function transitionIn():void
    super.transitionIn();
    TweenMax.to(this, 0.3, {alpha:1, onComplete:transitionInComplete});
    override public function transitionOut():void
    super.transitionOut();
    TweenMax.to(this, 0.3, {alpha:0, onComplete:transitionOutComplete});
    public class _onDemand extends Sprite
    // Link Navigation button handlers
    public var _onDemand:Sprite;
    // if you want a hand cursor
    _onDemand.buttonMode = true;
    _onDemand.useHandCursor = true;
    _onDemand.addEventListener(MouseEvent.CLICK, onDemandClickHandler);
    _onDemand.addEventListener(MouseEvent.ROLL_OVER, onDemandRollOverHandler);
    _onDemand.addEventListener(MouseEvent.ROLL_OUT, onDemandRollOutHandler);
    public function onDemandClickHandler(e:MouseEvent):void{
    navigateToURL(new URLRequest("http://ww2.cox.com/residential/santabarbara/tv/ondemand.cox"));
    public function onDemandRollOverHandler(event:MouseEvent):void{
    _onDemand.gotoAndStop("hover");
    public function onDemandRollOutHandler(event:MouseEvent):void{
    _onDemand.gotoAndStop("static");
    Getting the following errors:
    1120: Access of undefined property _onDemand.

    Ok. I admit it... I had some wonderful help to resolve this issue. You ever feel like you are on an island learning AS3 External Classes? I feel that way all the time... so far... I plan on not feeling that way soon. I hope this helps someone get off that island.
    package com.domainname.client {
        import flash.display.*;
        import flash.events.*;
        import flash.net.*;
        import flash.utils.*;   
        import caurina.transitions.Tweener;
        import caurina.transitions.properties.*;
        FilterShortcuts.init();   
        ColorShortcuts.init();      
        public class Main extends MovieClip {
            private var coverDelay:Number = 4;
            //#DF6D27
            public function Main():void {
                initMain();
            private function initMain():void {
                mc_form.visible = false;
                Tweener.addTween(mc_cover,{alpha:1,time:1,delay:coverDelay,onComplete:formIn});
                btn_onDemand.buttonMode = true;
                btn_listings.buttonMode = true;
                btn_ppv.buttonMode = true;
                btn_rhapsody.buttonMode = true;
                btn_onDemand.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_onDemand.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_onDemand.addEventListener(MouseEvent.CLICK,navClick);
                btn_listings.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_listings.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_listings.addEventListener(MouseEvent.CLICK,navClick);
                btn_ppv.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_ppv.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_ppv.addEventListener(MouseEvent.CLICK,navClick);
                btn_rhapsody.addEventListener(MouseEvent.MOUSE_OVER,navOver);
                btn_rhapsody.addEventListener(MouseEvent.MOUSE_OUT,navOut);
                btn_rhapsody.addEventListener(MouseEvent.CLICK,navClick);           
                function navOver(evt:MouseEvent):void {
                    Tweener.addTween(evt.target,{_color:0xffc614,time:.2});
                function navOut(evt:MouseEvent):void {
                    Tweener.addTween(evt.target,{_color:0xffffff,time:.2});
                function navClick(evt:MouseEvent):void {
                    var url;
                    switch (evt.target.name) {
                        case 'btn_onDemand':
                        url = new URLRequest("http://ww2.cox.com/residential/santabarbara/tv/ondemand.cox");
                        break;
                        case 'btn_listings':
                        url = new URLRequest("http://ww2.cox.com/myconnection/santabarbara/watch/entertainment/tv-listings.cox");
                        break;
                        case 'btn_ppv':
                        url = new URLRequest("http://ww2.cox.com/residential/santabarbara/tv/pay-per-view.cox");
                        break;
                        case 'btn_rhapsody':
                        url = new URLRequest("http://ww2.cox.com/myconnection/santabarbara/listen.cox");
                        break;                                                           
                    navigateToURL(url,"_blank");

  • Does WRT54GP2 work with multiple ViOP providers ?

    My question is, Does WRT54GP2 router work with multiple ViOP providers ? Can I use it with a ViOP provider other then Vonage ?
    Thanks, John

    Yes you definately can , all you need is a VOIP adapter that supports SIP . It's a standard protocol and is supported by all routers and VOIP providers

  • Reg:working with multiple windows in webdynpro-abap

    Hi ,
    How can we create multiple windows and how can we link them...
    suppose we have 3 fields on first screen .how to move the data from the first screen to second screen..
    Thanks & Regards
    Suman Puthadi

    Hi
    As per your Subject you are looking for "working with multiple windows in webdynpro-abap" and for abap there is a different forum. Web Dynpro ABAP
    Hope its clear to you...
    Even you can read this post when ever you get time Read before posting
    Regards
    Ayyapparaj

  • Problem when working with multiple sequences

    Dears,
    In order to make life easier (I am currently working on a rather long project), I work with multiple sequences, one per chapter.
    My problem: I named one sequence "assembly sequences" in order to add the various sequences. I dropped the sequence no 1, then no 2. All works fine, beside that when playing the sequence no 2, I see two black lines on top and bottom of the screen for the all length of the sequence. Which is not the case when I click on the sequence itself and play it independently.
    Any idea how to solve this ?
    Thanks
    Nic

    Thanks, what happened is that :
    1st sequence is like this : Frame size 720x576 pixels, video rate 25fps, Compressor DV-Pal. And I think it is the one appropriate for me and my country.
    2nd sequence is like this : Frame size 720x480 pixels,
    video rate 29.97 fps, Compressor DV-DVPRO-NTSC.
    I think I should change the second sequence setting, but can I do it after all the work I have done, and continue making a 3rd, 4th and so on ?
    Tx for your precious help,
    Nicolas

  • Why is scrolling not working with multiple youtube embeds layed out vertically in a stack on one page?

    Why is scrolling not working with multiple youtube embeds layed out in a stack on one page?

    Hi ,  
      This is a sort of performance issue , because your program takes more than the max time set for the program to execute in foreground.
    There are many stuff in program which will hamper your performance.
    I will list down a few
    1. SELECT *
    FROM konp
    INTO CORRESPONDING FIELDS OF TABLE konp_itab
    FOR ALL ENTRIES IN a363_itab
    WHERE knumh EQ a363_itab-knumh
    in this statement you are using for all entries a363_itab , but before this statement you are not checking if the table has any entry or not , please do remember that for all entries has this characterstic , that if you internal table does not contain any record , then all the records are selected from the database table. So in this case if you table a363_itab is empty , so what you want is no data must be seelcted from table konp , but what will happen is all the records in KONP will be seelcted.
    2. While retreiving data you are using seelct * even though you do not require all the fields , an example is
    <b>SELECT *
    FROM mkpf
    INTO CORRESPONDING FIELDS OF TABLE mkpf_itab
    FOR ALL ENTRIES IN mseg_itab
    WHERE mblnr EQ mseg_itab-mblnr.</b>
    in this your internal table contains only 2 fields
    <b>mblnr LIKE mkpf-mblnr, "Number of Material Document
    bldat LIKE mkpf-bldat, "Document Date in Document</b> , but to get these 2 fields you are selecting all the fields of the table.
    3. In select you are using into corresponding fields of table , it is not a good practice., so please avoidd it.
    Please understand that you must try to reduce the access to your database tables and try to keep it minimal , because this same thing may happen becasue data in DEV is very less compared to the volume of data in production , so a program working in DEV will take much more time in PRD if not written properly and may result in timeouts , as in your case.
    Please try to make chanegs to the prorgam and see if it works.
    In case you have more queries , please do revert back.
    Regards
    Arun
    *Reward points if replay is helpful

  • Maintain performance while working with multiple shape layers (~50 )

    Hey guys, I've been working on some projects lately where I need to animate a lot of shape layers cascading, arraying, with various animation properties. When I get to the point of using 30-60 or so shape layers, and they're all doing some kind of scale, position, etc. animations, my computer slows to a complete crawl. This then forces me into using a single shape layer and the repeater functions. These can work well sometimes, and don't hamstring the flexibility too much, UNTIL you need to incorporate varying colors. At that point, I usually switch my shape layers to masks and place a layer below with varying colors as needed. The shape animations then reveal those colors, but this doesn't work for a complex object that in itself requires many colors. Sooo...
    What kind of workflows do you all have for working with multiple semi-complex objects at once? I figure I must be missing something, because this has gotten really limiting. Is everyone just working with 256GB of RAM?
    FYI, my computer specs are:
    2 x 2.66 GHz 6-Core Intel Xeon
    32 GB 1333 MHz DDR3 ECC
    ATI Radeon HD 5870 1024 MB
    OS X 10.9.4 (13E28)
    Thanks!!

    Pre-comping can speed up your previews if you are using disk cache, but nothing will speed up  your first ram preview or a ram preview after a keyframe change except a better optimized system. All it takes to slow things down is one effect or a footage file that causes AE to start consuming memory and processor power.
    As a test I just created a gradient filled rectangle, added rotation keyframes, duplicated the layer so I have 64 copies on my Mac Mini and tried a ram preview compared with the same comp with only 1 layer. Almost no difference in the time it took to preview 10 seconds. Threw in a scale transform for all layers and again, not much difference between one shape layer and 64. To make things much harder I change the rectangle to a Polystar and animated everything in the Polystart transform properties, set up a composition with 128 duplicates and a comp with one layer. 2.5 seconds for a ram preview at quarter rez for a single layer, 10 seconds for a ram preview for 128 layers. That's more than acceptable to me for a two year old Mac Mini with 16 gb of ram. Increasing the zoom factor to 50% with Resolution set to Auto doubled the ram preview time which was still acceptable.
    This makes me wonder what else is going on in your composition. Any effects or other things going on? Have you optimized your system for maximum performance? There are links with suggestions for doing that all over this site as well as the Adobe recommendations found here: Optimizing After Effects Performance

  • When working with multiple artboards, are there separate layers panels for each artboard?

    Just started working with multiple artboards in ai but have read nothing about the layers panel, whether you use one layers panel for all the artboards or if the layers panel is duplicated so there is one for each artboard.

    I don't really understand your problem, but I've had headaches with managing a GUI before (as many programmers have, I'm sure).
    My best advice, if the scheme your using to build and manage a GUI is too confusing for you, the programmer, to easily understand/manage, change the scheme. Even if this means recoding a good deal of your program (though, hopefully, you've kept the GUI as seperate from your functional code as possible) it should be worth it.
    Perhaps a clearer explination of your problem would help better illustrate your problem?
    -Rejun

  • How do icloud and itunes match work with multiple libraries?

    How do icloud and itunes match work with multiple libraries?

    This forum is for troubleshooting compatibility issues between Macs and Windows, not iTunes. You'll probably want to repost your question in the iTunes discussions:
    http://discussions.apple.com/category.jspa?categoryID=150

  • Mapping editor not working with Java 5 classes

    I have a small protoype web service which I wrote using Tomcat/Axis/Spring/Hibernate and using EJB3 annotations for the mappings. I want to port the persistence layer to Toplink.
    I installed Toplink 9.0.4.1 and added the toplink libraries to my project and implemented the DAO and the spring bean defs.
    I opened the mapping editor and created a project. When I try to add classes to it for mapping I get an error that it can't find the classes (even though I selected them from the chooser). I figured it might be that they were compiled with Java 5, so I switched the JRE_HOME in setenv.cmd to my Java 5 JRE. Now I can import the classes and see the attributes but when I click on any of them in the Navigator panel, the editor panel remains blank. If I now try to save, I get:
    java.lang.NullPointerException
         at oracle.toplink.workbench.ui.tools.CheckListModel.getRowCount(CheckListModel.java:119)
         at javax.swing.JTable.checkLeadAnchor(JTable.java:2949)
         at javax.swing.JTable.tableChanged(JTable.java:2993)
         at javax.swing.JTable.setModel(JTable.java:2827)
         at oracle.toplink.workbench.ui.tools.CheckList.initialize(CheckList.java:47)
         at oracle.toplink.workbench.ui.tools.CheckList.<init>(CheckList.java:26)
    It seems that the mapping workbench doesnt work with Java 5. What should I do?

    Ah, I see. I saw another post here stating that must use 10.1.3.

  • Print to pdf often doesn't work with multiple pages?

    When I try to print to pdf, it often doesn't work right.
    I can select, for example, multiple Excel worksheets to print. It looks fine with 4 pages in Preview, but when I select save as .pdf, it only prints 2 of the 4 pages, and it prints those in 2 separate documents rather than a single .pdf document with multiple pages.
    Is there a way to do this? Is this an Apple error or Microsoft error? Since it looks fine in Preview, my guess it is an Apple error?
    Mark

    It sounds like this is the problem with the way Apple handles multiple orientations in a pdf document. You can use Acrobat to print the files - it handles multiple orientations correctly. There was a previous thread on this:
    http://discussions.apple.com/message.jspa?messageID=1983431#1983431

  • One material type assign with multiple valuation class

    Dear All,
    One material type assign with the multiple valuation class.it is possible.what is defuclty for that.
    pls, explan.
    Regards,
    Ranjeet

    Hi,
    ABC 3040 - spare mach BSX ( G/ L )- Goto OBYC and double click on the transaction key BSX and enter your chart of account proceed
    val modifier(0001)-val class 3040--G/L account
    XYZ 3041 - spare mach BSX ( G/ L )-Goto OBYC and double click on the transaction key BSX and enter your chart of account proceed
    val modifier(0001)-val class 3041--G/L account
    ABC 3040 - store consumable GBB ( G/ L )-Goto OBYC and double click on the transaction key GBB nter your chart of account proceed
    val modifier(0001)-Account modifier VBR-Valuaiton class 3040-G/L Account(cr)-G/L Account (Dr)
    ABC 3040 - repair and maintanance GBB ( G/ L )-Goto OBYC and double click on the transaction key GBB nter your chart of account proceed
    val modifier(0001)-Account modifier VBR-Valuaiton class 3041-G/L Account(cr)-G/L Account (Dr)
    Regards,
    Deepak.

  • Working with multiple audio tracks

    Hello,
    I'm working with video clips that have a stereo audio track (guide audio fed into the camera) synch'ed to 4 mono tracks (recorded from a variety of boom mics and lavaliers).
    Although I've linked all the audio clips to the video, it still gets a bit cumbersome when performing T or L cuts. When I hold down the Option key, I still have to adjust each of the audio track separately.
    Is there a more efficient way to deal with multiple audio tracks? Maybe some way to treat these audio tracks as one unit?
    BTW I'm working in FCP 7.
    Thanks,
    Thien

    One way:
    Lock the video track.
    Use the Edit Selection Tool to Select the audio transition points
    This will automatically open the Trim window, where you can move the cut point - in this case I am moving the audio cut(s) 30 frames later than the video cut:
    which gives me the displacement of all the tracks that I wanted:
    You can use this quite quickly once you get used to it.
    MtD

Maybe you are looking for

  • How do i keep my apps and data when syncing with a new laptop?

    My last laptop died so i have got a new one. How can i make sure all my apps,data and music on my Ipod Touch are not deleted when i get round to installing Itunes? I have done a few searches on this forum but are still unsure of exactly what to do. T

  • Pass a date parameter to Stored Procedure

    Hello friends, Can you help to pass a date parameter to Stored procedure from JSP. This is my code: In Oracle 9i I have this: PROCEDURE SP_EDORES( pfechaini IN hist_pol_reclama.hrc_fecha_contabilidad%Type, <-- This is a date field pfechafin IN hist_p

  • Signature Capture in MI 7.0

    HI All, I am working in SAP MI 7.0 and I wanted to know about the Functionality of Signature Capture. I found Note - 897289 - in which it explains how to install/deploy the functionality. My First Question is - What is this exact functionality? I mea

  • Upload Material Master

    Dear all, I´m trying to upload the material master form R3. I´m able to import all the materials that do not have the "Sales 1 view". But unfortunately, I can not upload materials with this view. When trying to replicate a material with Sales 1 view,

  • Issues Syncing Photos to PC from iPad with ios5 with Solution.

    As far as transferring pictures TO your PC FROM the Ipad2 (in my case) with Windows 7, I have a done a lot of testing with the new IOS5. As far as I can tell, only pictures taken with the device can be uploaded. So pictures to the iPad using Dropbox;