Remove component from JFrame with absolute layout

I have a JFrame and JPanel inside the JFrame with absolute layout. I wanted to have a button when clicked the JPanel will be removed. I called jFrame.remove(jPanel);
jFrame.repaint();
jFrame.validate();
I can't call jFrame.revalidate(), since JFrame doesn't provide revalidate() method. I try everything, but I can't get that JPanel removed. Could somebody help me please. Oh I tried jPanel.setBounds( 0,0,0,0); and the jPanel is disappeared, but I don't think this is the right solution. Is my problem with the absolute layout?
Thanks

public class MainGame
     public void game()
          GridBagLayout gridBagLayout = new GridBagLayout();
          GridBagConstraints constraints = new GridBagConstraints();
          final MainFrame mainFrame = new MainFrame();
          mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          mainFrame.setLayout( gridBagLayout );
          JPanel mainGamePanel = new JPanel();
          mainGamePanel.setLayout( new BorderLayout() );
          mainGamePanel.setBackground( Color.black );
          final Room mainEntrance = new Room( "at the main entrance of the deep forest" );
          mainEntrance.setBackground( Color.white );
          mainEntrance.setLayout( null );
          mainEntrance.setExit( Direction.UP, null );
          mainGamePanel.add( mainEntrance, BorderLayout.CENTER );
//          c.fill = GridBagConstraints.CENTER;
          constraints.ipady = 800;      //make this component tall
          constraints.ipadx = 600;
          constraints.anchor = GridBagConstraints.WEST;
          constraints.gridx = 0;
          constraints.gridy = 0;
          gridBagLayout.setConstraints( mainGamePanel, constraints );
          mainFrame.getContentPane().add( mainGamePanel );
          thePlayer = new Human( "Cloud" , "The player" );
          thePlayer.setMaximumWeight( MAXIMUM_WEIGHT );
          thePlayer.setImage( Constants.CHARACTER_FRONT );
          thePlayer.setBounds(0 , 0, 40, 30 );
          thePlayer.setBorder( BorderFactory.createLineBorder( Color.black ) );
          mainEntrance.add( thePlayer );
          apple = new EdibleItem( "apple" , "Give more 10 HP" );
          apple.setHp( 100 );
          apple.setImage( Constants.APPLE );
          apple.setBounds( 40, 0, 40, 30 );
          apple.setBorder( BorderFactory.createLineBorder( Color.black ) );
          mainEntrance.add( apple );
          thePlayer.addItem( apple );
          apple1 = new JPanelWithBackground();
          apple1.setImage( Constants.APPLE );
          apple1.setBounds( 80, 60, 40, 30 );
          apple1.setBorder( BorderFactory.createLineBorder( Color.black ) );
          mainEntrance.add( apple1 );
//          final Room forest = new Room( "at the main entrance of the deep forest" );
//          forest.setBounds( 0, 0, 800, 600 );
//          forest.setBackground( Color.white );
//          forest.setLayout( null );
//          forest.setExit( Direction.UP, null );
//          // Add to list
          listOfItems.add( apple );
          listOfItems.add( apple1 );
           * Main Control Panel to control character and actions
          JPanel controlPanel = new JPanel();
          controlPanel.setBackground( Color.black );
          controlPanel.setBounds( 1000, 0, 600, 600 );
          controlPanel.setLayout( new GridLayout( 0, 1 ) );
          JButton eatButton = new JButton( "EAT" );
          // Set this button to setFocusable(false) to prevent this button being focused
          // So the focus will stay at JFrame
          eatButton.setFocusable( false );
          eatButton.addActionListener( new ActionListener()
               @Override
               public void actionPerformed(ActionEvent e)
                    JPanelWithBackground currentObject = mainGame.getFacingObject();
                    if( currentObject instanceof EdibleItem )
                         //EdibleItem apple = ( EdibleItem )currentObject;
          controlPanel.add( eatButton );
          JButton attackButton = new JButton( "ATTACK" );
          attackButton.setFocusable( false );
          attackButton.addActionListener( new ActionListener()
               @Override
               public void actionPerformed(ActionEvent e)
                    System.out.println( "Remove" );
                    mainFrame.getContentPane().remove( mainEntrance );
                    mainEntrance.setBounds( 0,0,0,0);
//                    mainFrame.add( forest );
                    mainFrame.validate();
                    mainFrame.repaint();
          controlPanel.add( attackButton );
          mainFrame.setVisible( true );
          mainFrame.requestFocusInWindow();
}I know that my code is a mess, because it is connected with many classes and the quality of the format is not very good. But I will refactor it later when I solved the problem.
The problem is I have a JPanel with a character and an apple in it. I could not use any other layout, I have to use absolute layout, because I the user can control the character but arrow keys. And the character moves in pixels.
Here what I wanted to do.
final Room mainEntrance = new Room( "at the main entrance of the deep forest" );
          mainEntrance.setBackground( Color.white );
          mainEntrance.setLayout( null );
          mainEntrance.setExit( Direction.UP, null );Room extends JPanel, I wanted to delete this panel when I clicked this button
          JButton attackButton = new JButton( "ATTACK" );
          attackButton.setFocusable( false );
          attackButton.addActionListener( new ActionListener()
               @Override
               public void actionPerformed(ActionEvent e)
                    System.out.println( "Remove" );
                    mainFrame.getContentPane().remove( mainEntrance );
                    mainEntrance.setBounds( 0,0,0,0);
//                    mainFrame.add( forest );
                    mainFrame.validate();
                    mainFrame.repaint();
          controlPanel.add( attackButton );Like I said before, I tried validate, repaint and setBounds to all 0s. Nothing happened with the Room class. How do I delete that Room.
Thank you so much.

Similar Messages

  • Remove Applications from "Open With..." List

    Ever since I installed Adobe Creative Suite, there have been countless applications available in the Open With... list for image file types (JPEGs, PNGs, etc.).
    How do I remove applications from that list for a given file type?
    Thanks!

    There are a whole bunch of mostly useless little droplets that are installed by Photoshop and ImageReady. You can either toss them all, toss all but the one or two you might use, or just zip them and then if you ever want one unzip, take what you want and rezip the others (I kept Make Sepia Tone.exe and zipped all the others, and put a text file with a list of them all in the parent folder). Here's the location:
    "/Applications/Adobe Photoshop CS/Samples/Droplets"
    There is one folder full of ImageReady ones, and another folder of the Photoshop ones. If you trash them you can also get them back from the install disk. After you zip or trash them restart the computer and your Open with list will be back to normal.
    Francine
    Francine
    Schwieder

  • Problem removing bundles from group with ZLMAN

    I am having trouble removing a bundle from a bundlegroup with the zlman utility. The syntax I am using seems correct and the groups and bundle name are also.
    Here is the command and it's output from the command with the debug option: (if I use a bogus name for the package the output will tell me that the bundle was removed successfully :-)
    This ZLM72IR2 with Hot-Patch 3
    Any ideas?
    Thanks
    command:
    zlman bgr -U administrator -P xxxxxx -V -d Patches/Servers/sles10-sp1/Pre-Prod-security patch-slesp1-yast2-core-4623_SLES10-SP1-Updates
    output:
    com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIFault={_Message=An error occurred while trying to remove the grouping data.,_Type=5}
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:274)
    at java.lang.Class.newInstance0(Class.java:308)
    at java.lang.Class.newInstance(Class.java:261)
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIFaultMarshaler.deserialize(CoreAPIFaultMarsh aler.java:35)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:433)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:410)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:372)
    at com.sssw.jbroker.web.core.InputStreamImpl.readObje ct(InputStreamImpl.java:278)
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIBinding_Stub.removeMembers(CoreAPIBinding_St ub.java:2682)
    at com.novell.zenworks.zlman.commands.Commands.groupR emove(Commands.java:598)
    at com.novell.zenworks.zlman.commands.BundleCommands. execute(BundleCommands.java:1286)
    at com.novell.zenworks.zlman.ZLMan.main(ZLMan.java:28 0)
    Caused by: com.sssw.jbroker.web.portable.ApplicationException
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIBinding_Stub.removeMembers(CoreAPIBinding_St ub.java:2689)
    ... 3 more
    [5] Fatal Error: An error occurred while trying to remove the grouping data.

    brunold,
    I created a bundlegroup called Testbundle directly under the /Bundles container and tried to remove a couple of different patches. The results were the same. My server is SLES10SP2 64-bit by the way.
    Thanks,
    Frank
    zlman bgr -U administrator -P dnctl2RA -V -d Testbundle patch-slesp1-915resolution-4728_SLES10-SP1-Updates
    com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIFault={_Message=An error occurred while trying to remove the grouping data.,_Type=5}
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:274)
    at java.lang.Class.newInstance0(Class.java:308)
    at java.lang.Class.newInstance(Class.java:261)
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIFaultMarshaler.deserialize(CoreAPIFaultMarsh aler.java:35)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:433)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:410)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:372)
    at com.sssw.jbroker.web.core.InputStreamImpl.readObje ct(InputStreamImpl.java:278)
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIBinding_Stub.removeMembers(CoreAPIBinding_St ub.java:2682)
    at com.novell.zenworks.zlman.commands.Commands.groupR emove(Commands.java:598)
    at com.novell.zenworks.zlman.commands.BundleCommands. execute(BundleCommands.java:1286)
    at com.novell.zenworks.zlman.ZLMan.main(ZLMan.java:28 0)
    Caused by: com.sssw.jbroker.web.portable.ApplicationException
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIBinding_Stub.removeMembers(CoreAPIBinding_St ub.java:2689)
    ... 3 more
    [5] Fatal Error: An error occurred while trying to remove the grouping data.
    zlmprd1:/var/opt/novell/zenworks/scripts/movepatches # zlman bgr -U administrator -P dnctl2RA -V -d Testbundle patch-slesp1-915resolution-4728_SLES10-SP1-Updates
    com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIFault={_Message=An error occurred while trying to remove the grouping data.,_Type=5}
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:274)
    at java.lang.Class.newInstance0(Class.java:308)
    at java.lang.Class.newInstance(Class.java:261)
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIFaultMarshaler.deserialize(CoreAPIFaultMarsh aler.java:35)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:433)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:410)
    at com.sssw.jbroker.web.soap.LiteralEncodingStyle.rea dObject(LiteralEncodingStyle.java:372)
    at com.sssw.jbroker.web.core.InputStreamImpl.readObje ct(InputStreamImpl.java:278)
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIBinding_Stub.removeMembers(CoreAPIBinding_St ub.java:2682)
    at com.novell.zenworks.zlman.commands.Commands.groupR emove(Commands.java:598)
    at com.novell.zenworks.zlman.commands.BundleCommands. execute(BundleCommands.java:1286)
    at com.novell.zenworks.zlman.ZLMan.main(ZLMan.java:28 0)
    Caused by: com.sssw.jbroker.web.portable.ApplicationException
    at com.novell.zenworks.zlman.services.coreapi.admin.C oreAPIBinding_Stub.removeMembers(CoreAPIBinding_St ub.java:2689)
    ... 3 more
    [5] Fatal Error: An error occurred while trying to remove the grouping data.

  • Error removing object from cache with write behind

    We have a cache with a DB for a backing store. The cache has a write-behind delay of about 10 seconds.
    We see an error when we:
    - Write new object to the cache
    - Remove object from cache before it gets written to cachestore (because we're still within the 10 secs and the object has not made it to the db yet).
    At first i was thinking "coherence should know if the object is in the db or not, and do the right thing", but i guess that's not the case?

    Hi Ron,
    The configuration for <local-scheme> allows you to add a cache store but you cannot use write-behind, only write-through.
    Presumably you do not want the data to be shared by the different WLS nodes, i.e. if one node puts data in the cache and that is eventually written to a RAC node, that data cannot be seen in the cache by other WLS nodes. Or do you want all the WLS nodes to share the data but just write it to different RAC nodes?
    If you use a local-scheme then the data will only be local to that WLS node and not shared.
    I can think of a possible way to do what you want but it depends on the answer to the above question.
    JK

  • Remove component from JPanel

    Hi,
    i've to remove a component from the center (BorderLayout.CENTER) of a JPanel without knowing the name of the component at runtime. I know only that the component is in the center position of the panel. How can i do?
    Thanks
    Luca

    normally what i will do i removeall first and then i add the north or south component so you dont have to worry what is in your center of the panel

  • Remove user from group with MaxL

    hello,is it possible to remove a user from all groups he belongs to without knowing these groups?I want to execute a command such as "alter user my_user remove from ALL_GROUPS;"thanks for your help/

    Not sure if it's feesible, but you could use the 'drop user' command to remove the user from the system, which would of course remove them from all groups, then use the 'create user' command to recreate the user and reassign them to the proper groups.Good luck

  • Is there a way to remove items from "Open With" list?

    I have an interesting dilemma that I have not yet found an answer to in all of my internet/discussion forum searches.  Maybe I'm asking the wrong questions or searching in the wrong places, but I've given up and now have to post the question in hopes there's an answer out there.
    My issue is that whenever I want to use the "Open With" feature for an image/jpeg file, the list of choices is massive! Looking at it now, it lists over 30 applications, but at most I would only ever want to open this type of file in one of maybe four applications.
    Starting off, I used to have Parallels on my computer.  Have since purchased VMWare Fusion 4 and now use that as my virtual machine to run Windows for some of my design work.  As far as I know, I had removed ALL of Parallels from my computer when I uninstalled the app.  I followed all of the instructions in the uninstall process, but there seems to be something left behind.
    It may seem that mentioning that wouldn't have anything to do with the "Open With" function, but here is a screen shot to show what happens whenever I right-click an image file:
    http://www.virtuosocreative.com/apple/openwith1.jpg
    Most of the time, if I right click the image, it'd be to open in Photoshop or Set as Desktop.  On occasion I have had to open a jpeg file in Illustrator, but that's it.
    For some reason, there are still Parallels applications showing on the "Open With" list, even though it was uninstalled and removed from my computer.  But like I said earlier, it looks like I missed something. 
    In addition, although I am not logged into Windows or have Fusion running in the background, the "Open With" list includes all of the suggested Windows apps as well.  why???
    As much as I appreciate there being such an abundance of options to choose from, this gets extremely annoying when using the feature and I wanted to see if there was any way to modify this list. 
    More than anything, I really want to get rid of all the Parallels extras that are left on my system.  But also, I wanted to see if there was a setting to tweak so that whenever I click on "Open With" on my Mac, it'll only list applications that are my Mac applications and nothing through Fusion or Parallels or anything else.  And to take it a step further, it'd be nice to shorten the list to only applications I would personally use for opening a jpeg file. (i.e. Preview (default), Photoshop, Illustrator, Safari).
    My system is a 2010 iMac i5 2.8GHz/8GB RAM. Lion OS X 10.7.3
    Thanks!

    The Open With menu is built by LaunchServices which collects the information from each app as to what it says it can open. VMWare appears to be registering every app to open jpegs.
    You might try rebuilding the LaunchServices database. I believe this command still works in Lion. Or, you could use a utility like OnyX to call it:
    /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user

  • How to remove application from Open With?

    Hi,
    I added by accident a wrong application to a file type in Finder. Now I would like to remove this entry from the files Open With list. How could this be done?
    Thanks and best regards
    Ralph

    Is it just that specific document you want to open with another application or is it all documents of the same format?
    #1 Hold down Ctrl key and choose Open with. Choose the application you want to open the document with. IF you want to always open this one document with another app then the pre-chosen one hold down both the CTRl and the Option key and choose application.
    #2 When you want a certain format of documents to open with another application, let us say all .rtf should open with Pages instead of Textedit, select one rtf document and use Command (apple) key and I to get the information window for this document. Somewhere in the middle you can choose with which app. to open this document with and right beneath there is another button that gives you the opportunity to open all document of the same format with the same application.
    Pardon my Swenglish, but I hope you are helped by this!

  • Remove password from PDF with Reader 9.0?

    Hi,
    We would like to know if a user opens a protected PDF (with 128/256 bits encryption) in Acrobat Reader 9.0,
    can the user save a copy of the protected PDF and the new PDF is no longer password protected.
    That means I would like to check if the reader 9.0 can allow user to remove the password (Of course, permission
    should be granted when creating the protected PDF in Acrobat 9.0) from the protected PDF file.
    Thanks for your attention in advance,
    Raymond

    Reader cannot remove password protection. It only reads files.

  • How to remove programs from "open with".

    Recently I installed VM Fusion on my new MBP with SnowLeopard. The annoying issue is that when I right click on a file from SL and select "open with" I get a long list with windows programs that I don't intend to use. Is there a way to remove those programs when I select "open with". Thank you
    Juan

    Juan2009 wrote:
    Recently I installed VM Fusion on my new MBP with SnowLeopard. The annoying issue is that when I right click on a file from SL and select "open with" I get a long list with windows programs that I don't intend to use. Is there a way to remove those programs when I select "open with".
    no, there isn't. this list is generated by the launch services database and you can't control it manually.
    Juan
    Message was edited by: V.K.

  • Remove applications from 'Open With' dialog

    I have searched seemingly everywhere for an answer to this question. When I right click on an html file (or really any other file) and to go the 'open with' dialog there is a huge laundry list of applications listed. For the html files there are DivX converters, Big Bang games, etc.
    How can I remove all of the applications that I know can not open an html file and others that I would never use to open those files either? I like the ability to easily open the file with different browsers but really dislike scrolling through 30 different applications to find them.
    I have deleted the "com.apple.LaunchServices" file and rebooted.
    I have run "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServ ices.framework/Support/lsregister -kill -r -domain local -domain system -domain user" and rebooted.
    Neither of these solutions are helping the problem at all. I even tried some Onyx program. Is there a way to "trim the fat" from that window?

    The command you ran "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServ ices.framework/Support/lsregister -kill -r -domain local -domain system -domain user" is for 10.4, it is not the correct command to rebuild LaunchServices in 10.5.
    Launch /Utilities/Terminal and copy & paste this at the command line to rebuild LaunchServices:
    Code:
    <pre class="alt2" style="margin:0px; padding:3px; border:1px inset; width:640px; height:34px; overflow:auto">/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchSe rvices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user</pre>
    Then press return. Wait until terminal returns to the command line. Quit Terminal. After that, log out and back in or restart. That should solve it. Let us know
    -mj

  • A component within JTabbedPane with overlay layout

    Hi, I use the following solution to have a component within the upper right corner of the JTabbedPane: [http://forums.sun.com/thread.jspa?forumID=57&threadID=636289&start=2|http://forums.sun.com/thread.jspa?forumID=57&threadID=636289&start=2] . It works great, but when I'm resizing a window with the JTabbedPane with the JTabbedPane.WRAP_TAB_LAYOUT and width of all of the tabs is higher than size of the window the tabs are wrapped. But it should be wrapped when width of all tabs + width of the added component is higher than the size. I have no idea how to do this. Any ideas?
    Please see the screenshot: [http://img150.imageshack.us/img150/5629/btn.png|http://img150.imageshack.us/img150/5629/btn.png]

    Just a quick idea:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.*;
    class TabbedPaneTest {
      public JComponent makeUI() {
        UIManager.put("TabbedPane.tabAreaInsets",
                      new InsetsUIResource(6, 2, 0, 60));
        JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        sp.setTopComponent(makeTabPanel(new JTabbedPane()));
        sp.setBottomComponent(makeTabPanel(new ClippedTitleTabbedPane()));
        sp.setPreferredSize(new Dimension(320, 240));
        return sp;
      private JPanel makeTabPanel(final JTabbedPane tab) {
        tab.addTab("asdfasd", new JLabel("456746"));
        tab.addTab("1234123", new JScrollPane(new JTree()));
        tab.addTab("6780969", new JLabel("zxcvzxc"));
        tab.setAlignmentX(1.0f);
        tab.setAlignmentY(0.0f);
        JButton b = new JButton(new AbstractAction("add") {
          @Override public void actionPerformed(ActionEvent e) {
            tab.addTab("test", new JScrollPane(new JTree()));
        b.setAlignmentX(1.0f);
        b.setAlignmentY(0.0f);
        JPanel p = new JPanel();
        p.setLayout(new OverlayLayout(p));
        p.add(b);
        p.add(tab);
        return p;
      public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
          @Override public void run() { createAndShowGUI(); }
      public static void createAndShowGUI() {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new TabbedPaneTest().makeUI());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    class ClippedTitleTabbedPane extends JTabbedPane {
      //XXX Nimbus NPE
      Insets tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
      Insets tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
      public ClippedTitleTabbedPane() {
        super(JTabbedPane.TOP);
        setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        addComponentListener(new ComponentAdapter() {
          @Override public void componentResized(ComponentEvent e) {
            initTabWidth();
      @Override
      public void insertTab(String title, Icon icon, Component component,
                            String tip, int index) {
        super.insertTab(title, icon, component, tip==null?title:tip, index);
        JLabel label = new JLabel(title, JLabel.CENTER);
        Dimension dim = label.getPreferredSize();
        label.setPreferredSize(
            new Dimension(0, dim.height+tabInsets.top+tabInsets.bottom));
        setTabComponentAt(index, label);
        initTabWidth();
      private void initTabWidth() {
        Insets insets = getInsets();
        int areaWidth = getWidth() - tabAreaInsets.left - tabAreaInsets.right
                                   - insets.left        - insets.right;
        int tabCount = getTabCount();
        int tabWidth = 0;
        switch(getTabPlacement()) {
          case LEFT: case RIGHT:
          tabWidth = areaWidth/4;
          break;
          case BOTTOM: case TOP: default:
          tabWidth = areaWidth/tabCount;
        int gap = areaWidth - (tabWidth * tabCount);
        if(tabWidth>80) {
          tabWidth = 80;
          gap = 0;
        tabWidth = tabWidth - tabInsets.left - tabInsets.right - 3;
        for(int i=0;i<tabCount;i++) {
          JLabel l = (JLabel)getTabComponentAt(i);
          if(l==null) break;
          int h = l.getPreferredSize().height;
          l.setPreferredSize(new Dimension(tabWidth+((gap>0)?1:0), h));
          gap--;
        revalidate();
    }

  • Removing Zeros from Packed with decimals value

    Declaration is as follows:  var1(3) type p decimals 1
    i am passing value from database var1 value is 10.0
    In the above case i want to remove decimal value 0 in 10.0 if var1 value is 10.50 then my required value is 10.5 only.
    var1 is not used in clasical reports.
    I would like to export the variable var1 into smartforms and print.

    try this code and adopt it according to your needs:
    DATA:
      gv_p_init         TYPE p DECIMALS 2 VALUE '10.1',
      gv_dec_separator  TYPE char1,
      gv_tmp1           TYPE char1024,
      gv_len_dec        TYPE i,
      gv_tmp2           TYPE char1024,
      gr_dref           TYPE REF TO data,
      gr_datadescr      TYPE REF TO cl_abap_datadescr.
    FIELD-SYMBOLS:
      <gv_new_p>        TYPE p.
    * determine user specific decimal separator
    PERFORM get_dec_separator
      CHANGING gv_dec_separator.
    WRITE gv_p_init TO gv_tmp1.
    SEARCH gv_tmp1 FOR gv_dec_separator.
    * create new anonymous data object -> GR_DREF of type P with same length
    * as GV_P_INIT and decimals depending on relevant decimals of GV_P_INIT
    IF sy-subrc EQ 0.
      MOVE gv_tmp1+sy-fdpos TO gv_tmp2.
      SHIFT gv_tmp2 LEFT DELETING LEADING gv_dec_separator.
      SHIFT gv_tmp2 RIGHT DELETING TRAILING space.
      SHIFT gv_tmp2 RIGHT DELETING TRAILING '0'.
      SHIFT gv_tmp2 LEFT DELETING LEADING space.
      gv_len_dec = STRLEN( gv_tmp2 ).
      gr_datadescr ?= cl_abap_datadescr=>describe_by_data( gv_p_init ).
      gr_datadescr ?= cl_abap_elemdescr=>get_p(
                                        p_decimals = gv_len_dec
                                        p_length   = gr_datadescr->length ).
      CREATE DATA gr_dref TYPE HANDLE gr_datadescr.
      ASSIGN gr_dref->* TO <gv_new_p>.
      MOVE gv_p_init TO <gv_new_p>.
      WRITE: / gv_p_init,
             / <gv_new_p>.
    ENDIF.
    FORM get_dec_separator
      CHANGING cv_sep TYPE char1.
      DATA:
        lv_one_thousand TYPE i VALUE 1000,
        lv_tmp          TYPE char20.
      WRITE lv_one_thousand TO lv_tmp.
      IF lv_tmp CA '.'.
        MOVE ',' TO cv_sep.
      ELSE. "IF lv_tmp CA '.'
        MOVE '.' TO cv_sep.
      ENDIF. "IF lv_tmp CA '.'
    ENDFORM. "FORM get_dec_separator
    reward points if helpful

  • How can i manually remove songs from Ipod with itunes 11?  Please Help

    I am trying to remove a single song from my kids Ipod 5th gen ipod with itunes 11.0.1.2. With older versions of itunes i was able to right click on the content that i wanted to remove and select delete.  I for the life of me can not figure out how to remove content with itunes 11.  i have a lot of apple devices , iphone,ipad,ipod touch, and so on and so on. I am so frusterated that i feel like thowing it all in the garbage and starting over with another product.   

    Everything works the same in iTunes 11 as in previous versions.

  • Can we give UNIQUE ACCESS FOR THE SPECIFIC FILE IN THE LIBRARY in SP2013? How can we remove users from SHARED WITH link where files are shared with users?

    Hi,
    Any help on this?
    Thanks
    srabon

    Hi srabon,
    For giving unique access for a specific file in a library, you can go to the library, and select the file , and click FILES->Shared With->ADVANCED, under PERMISSION ribbon, click ‘Stop Inheriting Permissions’, then the file will have unique permissions.
    For removing the shared users for a file, firstly, like the above steps, select the file , and click FILES->Shared With->ADVANCED , make sure the file has unique access, then select the users that you want to remove, and click Remove User Persmissions
    under PERMISSIONS ribbon.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

Maybe you are looking for

  • Best practice for method calling on objects within a collection.

    Hi guys As you may be aware, based on my other thread here. I'm designing a card game in Java. I was hoping for some advice on the best practise on how methods should be called on a custom Object contained within a custom Collection. I have an instan

  • Akai MPD 16 or other sample controlling devices with Logic?

    I am aware that this topic has been discussed before in the forum, however the answer i was looking for was not presented too clearly. I am using an Akai MPD 16 with Logic Express 7. I am looking to assign samples to a sampler (most likely .wav drums

  • How to write copa0003 's pbo?

    hi,Dear professor: I am trying to add new fields to TC KO01/2/3. I've read the documentation and did not understand. I've already created my fields in the CI_AUFK structure. now  I can write the coas-zmenge into the table. but on the user-define scre

  • Re: Broadband down again - TIME TO LEAVE BT but ne...

    Nice to know that  AAISP are still persistent with BT OR  I can only imagine  what could of easily happened  if you have gone down the reporting a PTSN fault yourself, Typical scenario being  the remote tests carried out by your Telephony provider  w

  • A strange problem about InputStream

    I meet a strange problem. I have a data file named data.dat whose size is 16k. I write a passage of code to read the binary data from data.dat        byte[] gbData = new byte[8177 * 2];        // it's length equals to the size of data.dat        Inpu