Tabs Won't Work Right Aligned JPanel

Hello
I'm tring to setup a JPanel using a style object for formating, JPanel.setLogicalStyle(styleimade);, and I haver everything working beautifuly for a left alligned panel, but when I attempt to work with tabs on a panel that is right aligned, StyleConstants.setAlignment(styleimade, ALIGN_RIGHT), I can't seem to get tabs to work at all. Using StyleConstants.setTabSet(styleimade, atabsetimade) to set the tabs. When I make my tabset it doesn't matter what I have my tabstops set to the indention doesn't change. When I set the alignment back to left, the tabs start to work.
When I try to do a search on documentation I naturally get a huge list of tabpanels, and can't seeem to find anything on this particular subject.
Any suggestions or links to other forums would be a huge help.
Thank you in advance!

Ok, I had thought it meant I need to be able to compile and execture the code.
Here it is...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import java.lang.Object.*;
import java.util.*;
//enxtends JFrame because it is a window, Implements KeyListener, ActionListener
//so it can accept keyed input.
public class testGUI extends JFrame {
    //stores the device that this window is using to display itself.
    GraphicsDevice device;
    //both are used to store the height and width of the screen
    int ScreenHeight;
    int ScreenWidth;
    //create a bool to hold if the screen should be fullscreen or not
    boolean fullscreen = true;
    //create colors to hold default colors
    Color Blue;
    Color Orange;
    Color Black;
    //create text panels that will be displayed on the screen
    JTextPane TopLeft;
    StyledDocument DocTopLeft;
    //pass a graphics device so it knows which screen to take, the number of the
    //current display so it knows what to name the window, the height of the
    //current screen, and width so it can use that to set objects
    public testGUI(GraphicsDevice device, String NumberOfDisplay,
                          int WindowHeight, int WindowWidth) {
        //set the name and size of the screen.
        super("Screen " + NumberOfDisplay);
     setSize(800,600);
        //set the screenheight and width data types
        ScreenHeight = WindowHeight;
        ScreenWidth = WindowWidth;
        //start up everything is Design view
        //initComponents();
        //set the screen up
        setScreen();
        //setLocationRelativeTo nothing so the screen will center
     setLocationRelativeTo(null);
        //set the device for this window to the device passed to the class
        this.device = device;
        //when a close is initiated, exit
     setDefaultCloseOperation(EXIT_ON_CLOSE);    
        //as default show the screen
        setVisible(true);
    }//end default constructor
    public void setScreen() {
        //What happens when the X is clicked
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        //set the colors for this window
        Blue = new Color(0, 0, 204);
        Orange = new Color(244, 143, 0);
        Black = new Color(0, 0, 0);
        //change backgruond color of screen
        this.setBackground(Orange);
        this.getContentPane().setBackground(Orange);
//....................................................Settings for TopLeft Pane
        //create the setup the panel
        TopLeft = new JTextPane();
        TopLeft.setEditable(false);
        TopLeft.setFocusable(false);
        TopLeft.setBackground(Orange);
        TopLeft.setPreferredSize(new java.awt.Dimension(((int) (ScreenWidth * .6)), ((int) (ScreenHeight * .6))));
        TopLeft.setDisabledTextColor(Black);
        //set Document to TopLeft
        DocTopLeft = TopLeft.getStyledDocument();
        //Create a list to hold tabstops
        java.util.List TabListLeft = new ArrayList();
        //create a tabstop, using the screen as a reference
        TabStop tstop = new TabStop(((int) (ScreenWidth * .25)), TabStop.ALIGN_CENTER, TabStop.LEAD_NONE);
        TabListLeft.add(tstop);
        //create another tab stop
        tstop = new TabStop(((int) (ScreenWidth * .33)), TabStop.ALIGN_CENTER, TabStop.LEAD_NONE);
        TabListLeft.add(tstop);
        //creating tab stop
        tstop = new TabStop(((int) (ScreenWidth * .41)), TabStop.ALIGN_CENTER, TabStop.LEAD_NONE);
        TabListLeft.add(tstop);
        //create a tab
        tstop = new TabStop(((int) (ScreenWidth * .49)), TabStop.ALIGN_CENTER, TabStop.LEAD_NONE);
        TabListLeft.add(tstop);       
        // Create a tab set from the tab stops that were made above
        TabStop[] TabStopsLeft = (TabStop[])TabListLeft.toArray(new TabStop[0]);
        TabSet TabsLeft = new TabSet(TabStopsLeft);
        // Add the tab set to the logical style;
        // the logical style is inherited by all paragraphs
        Style StyleTopLeft = TopLeft.getLogicalStyle();
        StyleConstants.setAlignment(StyleTopLeft, StyleConstants.ALIGN_RIGHT);
        StyleConstants.setTabSet(StyleTopLeft, TabsLeft);
        TopLeft.setLogicalStyle(StyleTopLeft);
        //add styles to document, in this case, it is just fonts formating
        addStylesToDocument(DocTopLeft);
        //insert text into the JPanels
        try{
                //start with text pane at top left
                DocTopLeft.insertString(TopLeft.getCaretPosition(), "Test", DocTopLeft.getStyle("titles"));
                DocTopLeft.insertString(TopLeft.getCaretPosition(), ("\n\t" + "test\ttest\ttest"), DocTopLeft.getStyle("maintext"));
                DocTopLeft.insertString(TopLeft.getCaretPosition(), "\n Test", DocTopLeft.getStyle("subtitles"));
                DocTopLeft.insertString(TopLeft.getCaretPosition(), ("\t" + "test\ttest"), DocTopLeft.getStyle("maintext"));
                }//end of try block for string insertion
        //I know I'm cheap there is no exception catch here
        //but the user doesn't edit anything so how can it be at the wrong location?!
        catch(Exception e) { }       
        //Make a layout that is based on things added to it
        GroupLayout layout = new GroupLayout(getContentPane());
        //set the layout for MenuDisplayGUI to the layout created above
        getContentPane().setLayout(layout);
        //Left and right                                    left and right
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup()
                //create a sequential group that will hold all text boxes
                .addGroup(layout.createSequentialGroup()
                    //create a paralle group to hold everyting on the left
                    .addGroup(layout.createParallelGroup()
                        .addComponent(TopLeft)
                        )//end of parallel group holding everything on left of screen
                    //.addContainerGap(1, Short.MAX_VALUE)
                )//end of parallel group holding everything horizontally
        ));//close of layout.setHorizontalGroup
        //UP AND DOWN!!!                                      UP AND DOWN
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                //create a sequential group to contain the items vertically
                .addGroup(layout.createSequentialGroup() 
                    //create a paralle group to hold the items at the top of the screen
                    .addGroup(layout.createParallelGroup()
                        //add the item at the top left
                        .addComponent(TopLeft)
                        )//end of parallel group holding the two top items
                        //.addContainerGap(1, Short.MAX_VALUE)
                    )//end of sequential group holding everything vertically
        );//close of setVerticalGroup
        pack();
    }//end member function setScreen
    protected void addStylesToDocument(StyledDocument doc) {
        //create the defualt style that all other styles will build off of
        Style def = StyleContext.getDefaultStyleContext().
                        getStyle(StyleContext.DEFAULT_STYLE);
        //create the baseline for your style type
        Style regular = doc.addStyle("regular", def);
        StyleConstants.setFontFamily(def, "Sans");
        StyleConstants.setBold(def, true);
        //create a style used for titles, set the font
        Style titles = doc.addStyle("titles", regular);
        StyleConstants.setFontSize(titles, ((int) (ScreenWidth * .05)));
        StyleConstants.setForeground(titles, Blue);
        //create a style for subtitles
        Style subtitles = doc.addStyle("subtitles", regular);
        StyleConstants.setFontSize(subtitles, ((int) (ScreenWidth * .025)));
        //create a style for all of the rest of the text
        Style maintext = doc.addStyle("maintext", regular);
        StyleConstants.setFontSize(maintext, ((int) (ScreenHeight * .025)));
    }//end of member class addStyleToDocument   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        pack();
    }// </editor-fold>                       
    * @param args the command line arguments
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                }//end try block
                catch (Exception ex) {
                        System.out.println(ex);
                }//end catch block
                //get the graphics enviroment for this local computer
                GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
                //create an array of graphics devices for all the "screen devices"
                //in the env Graphics enviroment
          GraphicsDevice[] devices = env.getScreenDevices();
                //create an integer for looping
                int loop = 0;
                //create a vector to hold multipe MenuDisplayGuis for systems
                //that use multiple screen
                Vector DisplayWindows;
                DisplayWindows = new Vector();
                //create a display mode which will later pass the height
                //and width of the window to the MenuDisplayGUI object
                DisplayMode DM;
                //loop through all of the display devices on the local computer
                //create a window for each screen
                while( loop < devices.length ) {
                    //change the displaymode to the current display mode
                    DM = devices[loop].getDisplayMode();
                    //put a MenuDisplayGUI Window into the DisplyWindows vector
                    //for each display device that is on the computer. Pass the
                    //current iteration in this loop to the MenuDisplayGUI
                    //that is being created so it can name itself according to
                    //number, send the screen height and width to handle
                    //position of objects.
                    DisplayWindows.addElement(new testGUI(devices[loop],
                                              String.valueOf(loop + 1),
                                              DM.getHeight(), DM.getWidth()));
                    //iterate the loop
                    loop++;
                }//end while loop
            }//end run block
    }//end static main
}

Similar Messages

  • Firefox 12 doesn't load bookmarks in sidebar, home pages don't open, undo closed tab won't work.

    Firefox 11 worked fine. Firefox 12 seemed to install too fast. Now, when opening Firefox, bookmarks don't load in sidebar, even though the top of the sidebar says "bookmarks." Home pages won't load on opening Firefox---only a new tab. Clicking on the little house icon opens the home pages. Display closed tabs icon is dark and Undo closed tabs won't work. Sometimes the toolbar with File, Edit, View etc goes so dark it virtually disappears. I have Vista OS. Reinstalling Firefox 12 didn't help. Is there a fix, or can I go back to Firefox 11?

    Do a clean (re)install and delete the Firefox program folder (C:\Program Files\Mozilla Firefox\).
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 12.0.x: http://www.mozilla.org/en-US/firefox/all.html
    Uninstall your current Firefox version, if possible.
    *Do NOT remove personal data when you uninstall your current Firefox version, because all profile folders will be removed and you will also lose your personal data like bookmarks and passwords from profiles of other Firefox versions.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other profile data are stored elsewhere in the Firefox Profile Folder and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • Headphone jack won't work right

    I have a 60GB video iPod and the headphone jack won't work right. I only get audio in the left ear unless I push the earphone plug to the side. I know this is common among listening devices and wondered if there is any easy way to correct this or if I should just take it to Apple to have them fix it. It's definitely not under warranty and wondered how much it would be to fix it...

    If you are at all handy you can replace the headphone and hold switch. It is not terribly difficult. Almost all sites that sell the parts have online videos that show you how to do it. I have replaced them as well as batteries and screens. I encourage anyone that has some mech skill and there Ipod is off Warranty to try it. If you have a great fear or are all thumbs then of course send it somewhere. One advantage of doing your own repairs is that while you have it open you might as well replace the battery with a longer life batt and also the screen with a brighter one for about the same cost as 3rd party doing the work on just the jack and hold switch. A lot of the sites send the case tools and jewelers screwdriver with the part. or at any hardware store, or where every tools are sold you can get a jewelers screwdriver. Good luck.

  • For those people that have a issue with MSI DVD that won't work right

    I  have an MSI K9 SLI Platium 7250 w/ an AMD Athlon X2 4600+ 2.4 GHz. I have MSIDVD that originaly came with my old Motherboard MS-680E AMD Atlon XP 1700+ 1.4GHz. When I upgraded MSIDVD wouldn't work right and every time I Would insert a a DVD MSIDVD would give a wierd error. But here a hint how to bypass. As long as you have MSIDVD installed you should be able to play DVD's through Windows Media Player without any problems, thats what I was able to do. Or if you still want to use MSIDVD, you need to download a program from AMD, here are the detales, I also done this too
    The Program is called "AMD Dual-Core Optimizer"
    The AMD Dual-Core Optimizer can help improve some PC gaming video performance by compensating for those applications that bypass the Windows API for timing by directly using the RDTSC (Read Time Stamp Counter) instruction. Applications that rely on RDTSC do not benefit from the logic in the operating system to properly account for the affect of power management mechanisms on the rate at which a processor core's
    Time Stamp Counter (TSC) is incremented. The AMD Dual-Core Optimizer helps to correct the resulting video performance effects or other incorrect timing effects that these applications may experience on dual-core processor systems, by periodically adjusting the core time-stamp-counters, so that they are synchronized.
    Heres the link http://www.amd.com/us-en/Processors/TechnicalResources/0,,30_182_871_13118,00.html

    OK, well - I installed Tiger back on a separate disk and will reboot into that when I want to watch a movie. Cheers, all.

  • My HP Photosmart C5280 scanner won't work right anymore. I always used it with my Picasa 3

    For some reason my HP Photosmart C5280 scanner won't work with my Picasa 3, and it used to.  My PC is also an HP Pavilion g6,  with Windows 7.  I tried downloading a new driver, as the CD was too old to have Windows 7, and also updating my Picasa, but none of that worked.  I'm trying to scan an old photo.  I'm just not having any luck at all, and it used to work like magic.
    Thanks.
    Maerzie

    Just when I thought oneof the cures was going to work, I got the message: "The system can't find the "file" specified!", so I opened the "file" with the new drivers, which I THOUGHT it meant, and , of course, it was WRONG!  What file??  PLEASE help!

  • Safari 5.1 won't work right

    When running 5.1 my forward/back buttons won't work until I open the customize toolbar box and then the back button will work but I cannot get the forward button to work. This is some of the weird things that are happening trying to use 5.1.
    This is a mystery to me because I'm not using an old machine (iMac June 2010, purchased last September), I have additional RAM installed (8GB total), and SL 10.6.8. What I've done so far is to trash plist files, maintenance the system using IceClean, repair permissions, fix disks, reset Safari, and removed all extensions. I've reapplied 10.6.8 twice, reverted to 5.05, confirmed it working fine then upgrading again now but nothing works. I can't see going to Lion until I get this resolved...
    Any ideas?
    Thanx!

    Quit Safari. Open a Finder window select your Home folder in the Sidebar on the left. Then open the Library folder, then the Caches folder, then the com.apple.Safari folder. Move the cache.db file from the com.apple.Safari folder to the Trash. Relaunch Safari.
    If that doesn't help, could be a third party Safari add on preventing your back / forward buttons from working.
    Safari: Unsupported third-party add-ons may cause Safari to unexpectedly quit or have performance issues
    BTW.. using a third party utility to "clean" your Mac can cause more problems then they're worth.
    Leave your Mac on over night (not in Sleep mode) once a month. It will run maintenance tasks for you.
    Read here >  Mac OS X: About background maintenance tasks

  • Tabs won't work in Safari after downloading Mavericks

    Need some help please....  I downloaded Mavericks a few days ago --and have had several different glitches happen in Safari.  Most of them I 'fixed'---but now the tabs will not work at all (even though they are set up to work).  What is going on???

    What exactly happens, and how is it different from what you expect?

  • Left side of keyboard won't work, right side isn't right

    Whole left side of MacBook Pro not working at all and right side shows symbols but not the correct ones. Trackpad works fine and top row of keys works all the way across - light, sound, etc. did not spill anything on it. Was working just fine before.

    I dont want to shut down because if I do and it doesn't fix the issue I won't be able to log back in. I am running 10.5.8

  • Just loaded Lion on my iMac 2 days ago. The whole computer is on valium now. iTunes won't work right. Downloads fail. I AM SO FRUSTRATED I COULD CRY. I hate this.

    I just loaded Lion on our iMac 2 days ago and it was the worst thing I have ever done.
    How do I uninstall or remove it and go back to Snow Leopard?
    I can't get any help right now due to time zones. I have an Apple Care account that isn't doing me any good.
    I HATE LION.
    iTunes keeps timing out on an update download stating a 685MB download will take 7 hours.
    EVERYTHING is slow slow slow like a pc.
    I hate this thing.
    How do I get rid of Lion and go back to Snow Leopard.
    I don't even care about the $29.95, just give me back my old computer!!

    leannfromspokane wrote:
    I want Snow Leopard back.
    This is perfectly understandable. Please ignore the users that try to convince you that Lion is good. It isn't as of 10.7.1 . For production work I highly recommend using Snow until Lion gets its major bugfix update which is not on the horizon as far as "End Users" can foresee. Dev-talk is not allowed here, well they all swear 10.7.2 will do the wonders.. anyhow.
    If your Mac was shipped with Snow preinstalled, then you must have either a Restore DVD or a USB thumbdrive. Apple delivered the DVD with all optical-drive equipped macs and the usb for the MacBookAir etc, that don't have a drive.
    The procedure would be in all cases to boot the Mac from that recovery medium, thus landing inside Snow's installer which would give you the option to launch disk utility, erase the partition  and install Snow onto it .
    Your personal data needs to be backed up before , and I do not recommend using Lion's timemachine for that but just copy the complete User Profile Folder with your name to a external drive for example. This will then include your documents // pictures // itunes media // library and so on. All that can be copied back to the same folder names in Snow .

  • Command-Tab & Dock not working right

    I'm talking mainstream apps not showing up in the cmd-tab display. Usually Finder and one other are there, the rest not.
    In the Dock, apps which have been successfully quit still show their open dot until clicked on, whereupon, the dot disappears. Dock problem is constant. Cmd-tab problem is intermittent, about 50% of the time.

    Try using F8

  • Click won't work right on buttons imported from Photoshop

    In Edge, I have created an application where a user can click buttons and then it takes them to a separate scene. However, I seem to have run into a problem where the click only works in a certain area of the box. I created the buttons in Photoshop and imported them to Edge. Only the edge of the button closest to the edge of the stage will work for clicking for some odd reason. Any suggestions?

    Not sure how to upload the whole project on here (sorry, I haven't used the forum before today), but here are a couple of the assets.
    I hope that is helpful, and thanks for responding.
    -Elysse

  • Blog Template won't work right

    Having trouble getting BC Blog Template to work.
    Currently only shows the Blog Name - but no post after.
    Clicking on Post Title on Blog Page works without a template but how to get it to show the post inside the template?
    Its a full page layout DW template with the {tag_pagecontent}
    Blog Page:
    http://www.pjspeech-hearing.com/blog_pjspeech.html
    Post in template:
    http://www.pjspeech-hearing.com/port-jefferson-speech-hearing-blog/november-11-2013-hearin g-clinic-event

    Liam,
    I think I figured out something
    Is this correct? - to use the url in blog details: http://www.pjspeech-hearing.com/port-jefferson-speech-hearing-blog
    for blog link in my "non-dynamic" menu instead of a html page like you suggested.
    Is this correct proceedure?
    But if you look at my blog using template it only shows the BLOG TITLE and not the whole blog post
    Blog not using template shows everything but just plain white background.
    Thanks
    Will

  • Flash plugin won't work right with 31.0, works fine with 30.0, is there a fix coming?

    I have several Unitrends backup systems, which use flash for the Web GUI.
    After upgrading to Firefox 31.0, only one of four of these will load the GUI.
    This all works with IE, Chrome, and Firefox 30.0.
    My guess is that there is some legacy flash logic that does not work properly in 31.0.
    Currently, I have had to downgrade to Firefox 30.0 (no change to flash version, BTW).

    This problem isn't about the flash plugin, everything else was the same, the flash plugin, the web GUIs using it, etc. The only difference that caused the problem was the upgrade to Firefox 31.0, and the only way I was able to resolve it was by downgrading to Firefox 30.0.
    Furthermore, every other browser (IE, Chrome, etc.) works fine on this system using the same flash plugin, same web GUIs. The problem is specific to Firefox 31.0, so the problem needs to be resolved in Firefox.

  • Aperture won't work right because iphoto needs to upgrade. it still won't work, because it says to upgrade  iphoto above to a least 9.1 which i have, but it still won't work

    Please help?

    I recently installed Mountain Lion & I've aways had Iphoto 9.2.1, but now I've down loaded Iphoto 9.3.2, but it won't allow me to upgrade to to 9.3.2. It says that I need at least 9.1 which I have. I can't figure out why.
    I currently have Aperture 3.3.2

  • HT4906 App store won't work right!

    I've tried to download an update for iPhoto 5-6 times and it will not install. What's the deal?

    You have a problem with the App store - contact them via the link on the right side of the App store window for App store support
    LN

Maybe you are looking for