JTabbedPane and one Button for all Tabs

Hello everybody,
im new here an would say HELLOOO to everyone
So ive got an issue.
I am creating in "class A"  tabs for a JTabbedPane. In "class B" i create the JTabbedPane and creat instances of class A and add them to the TabbedPane.
in Class B i also create a button, for save actions. When i click the button, a method "save()" will be called and read from every tab the Strings out of textfields.
My problem now is, that it dont work, i call the save method with the instance from the tab, but it dont getText() from the textfield.
For example:
//create an instance tab, parameter is the save file
Tab myTab = new Tab(file);
     //other code
(Tab)myTab.save(); //here i eclipse cast to Tab automatically
the save-Method in class A (Tab):
save() {
sysout(texfield1.getText)
BTW how can i highlight code in this forum?

You can add syntax highlighting by going into the advanced editor, that will add a button for it. Unfortunately there are no quick code tags :/
After you find the button post your ACTUAL code. not just some random snippet which looks like your code. What you posted doesn't even compile.

Similar Messages

  • JTabbedPane with one close button for all tabs

    Hello,
    there have several solutions been posted for JTabbedPane subclasses that provide tabs with icons working as close buttons on each tab. I think this is not user friendly because the user can hit the close button accidentally when selecting a tab. And a "really close?" dialog is clumsy.
    Therefore I prefer the Netscape browser style: There's only one close button rightmost of the tabs that closes the selected tab. But I don't have an idea how to achieve this.
    Does anyone have a solution or an idea? Thanks in advance for help.

    This solution has been posted several times and is not what I wanted. But I rewrote the thing so that
    - the close buttons are on the right hand side of each tab so that it is conformant with Eclipse style, and
    - the close buttons work only with a left click (see code below).
    I just wonder how I can move the text a little bit to the left so that the appearence is a bit more balanced. Can someone help, please?
    import java.awt.Color;
    import java.awt.FontMetrics;
    import java.awt.Graphics;
    import java.awt.Rectangle;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.plaf.basic.BasicTabbedPaneUI;
    class TabbedPaneCloseButtonUI extends BasicTabbedPaneUI {
        public TabbedPaneCloseButtonUI() {
            super();
        protected void paintTab(
            Graphics g,
            int tabPlacement,
            Rectangle[] rects,
            int tabIndex,
            Rectangle iconRect,
            Rectangle textRect) {
            super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect);
            Rectangle rect = rects[tabIndex];
            g.setColor(Color.black);
            g.drawRect(rect.x + rect.width -19, rect.y + 4, 13, 12);
            g.drawLine(
                rect.x + rect.width -16,
                rect.y + 7,
                rect.x + rect.width -10,
                rect.y + 13);
            g.drawLine(
                rect.x + rect.width -10,
                rect.y + 7,
                rect.x + rect.width -16,
                rect.y + 13);
            g.drawLine(
                rect.x + rect.width -15,
                rect.y + 7,
                rect.x + rect.width -9,
                rect.y + 13);
            g.drawLine(
                rect.x + rect.width -9,
                rect.y + 7,
                rect.x + rect.width -15,
                rect.y + 13);
        protected int calculateTabWidth(
            int tabPlacement,
            int tabIndex,
            FontMetrics metrics) {
            return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + 24;
        protected MouseListener createMouseListener() {
            return new MyMouseHandler();
        class MyMouseHandler extends MouseHandler {
            public MyMouseHandler() {
                super();
            public void mouseReleased(MouseEvent e) {
                int x = e.getX();
                int y = e.getY();
                int tabIndex = -1;
                int tabCount = tabPane.getTabCount();
                for (int i = 0; i < tabCount; i++) {
                    if (rects.contains(x, y)) {
    tabIndex = i;
    break;
         if (tabIndex >= 0 && ! e.isPopupTrigger()) {
    Rectangle tabRect = rects[tabIndex];
    y = y - tabRect.y;
    if ((x >= tabRect.x + tabRect.width - 18)
    && (x <= tabRect.x + tabRect.width - 8)
    && (y >= 5)
    && (y <= 15)) {
    tabPane.remove(tabIndex);
    import java.awt.BorderLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTabbedPane;
    public class TabbedPaneWithCloseButtons {
    JFrame frame;
    JTabbedPane tabPane;
    public TabbedPaneWithCloseButtons() throws Exception {
    frame=new JFrame();
    frame.getContentPane().setLayout(new BorderLayout());
    tabPane=new JTabbedPane();
    tabPane.addTab("test1xxxxxxxxxxxxxx", new JLabel("1"));
    tabPane.addTab("test2xxxxxxxxxxxxxxxxxxx", new ImageIcon("images/icon.gif"), new JLabel("2"));
    tabPane.addTab("test3xxxxxxxx", new JLabel("3"));
    tabPane.setUI(new TabbedPaneCloseButtonUI());
    frame.getContentPane().add(tabPane);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200,200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    public static void main(String[] args) throws Exception {
    TabbedPaneWithCloseButtons test=new TabbedPaneWithCloseButtons();

  • How to create one Oprations button (Create Button Or CreateInsert Button )for all master And Detail block?

              hi
       I have master And Detail with 4 level ,I want to have on operations button for all block in data control .
      (similar to Oracle form toolbar)
    how to do it ?

    Well, if you tell us your jdev version and what exactly you try to do, without just telling us 'as in forms' we might be able to help.
    Most of us don't know how it's done in forms. So be specific when you describe your use case.
    Timo

  • Can I use One Hard Drive for 2x Time Machine Back Ups and another partition for all my data?

    Hi Forum,
    I am planning to but a RAID disc set up, but if i get a 2 disc set up, on one disc, can i have:
    Time Machine back up for one Mac
    Time Machine back up for 2nd Mac
    Anothe partition for all my data.
    then have that RAID'd to second disc?

    no one?
    and if this set up was on one disc, and one partition for one TM was for the Mini that has this drive attached, would TM back up this whole drive 2x TM Partitions and 1x partitions with data on, ok? it wouldn't get confused by trying to back itself up

  • Have iPad, iPod Touch and iPhone 4s. Can I use one charger for all

    I have and iPad, iPhone 4S and iPod 4. Can I use one charger for all 3 and if so, which one. TZ all

    You can use the iPad charger for all.

  • HT201274 what should i do if i interrupted the erase all content process from my ipod i pressed sleep button and menu button for 10 seconds

    please help here i just interrupted the process of erasing all content from my ipod it took almost 10 hours then i got worried from waiting i pressed both sleep button and menu button for 10 seconds while in process what should i do?

    After charging the iPod for at least an hour try:
    - Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Connect to computer and restore via iTunes
    - Next see if placing the iPod in Recovery mode will allow a restore.
    - Then try DFU mode and a restore.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings

  • Using Firefox 26. How do I get a close button for each tab at the top of the screen?

    Some time ago, I had a close tab button for each tab on the top of the screen. I want that back. I have no additional add ons and the close tab is set to 1. Changing it to 2 does nothing.

    Do you have installed this extension?
    *Firefox/Tools > Add-ons > Extensions
    If you do not have the extension and also have no need for the feature that it provides then you can ignore this.
    If it works in Safe Mode and in normal mode with all extensions (Firefox/Tools > Add-ons > Extensions) disabled then try to find which extension is causing it by enabling one extension at a time until the problem reappears.
    Close and restart Firefox after each change via "Firefox > Exit" (Windows: Firefox/File > Exit; Mac: Firefox > Quit Firefox; Linux: Firefox/File > Quit)
    You can use one of these to start Firefox in <u>Safe Mode</u>:
    *On Windows, hold down the Shift key while starting Firefox with a double-click on the Firefox desktop shortcut
    *On Mac, hold down the Options key while starting Firefox
    *Help > Restart with Add-ons Disabled
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • I opened my iPod Touch up to fix my home button. When i closed it back up it had a white screen. I tried pressing lock and home button for 10 seconds and it worked but while i'm using it it goes white with lines on the screen. Help please

    I opened my iPod Touch up to fix my home button. When i closed it back up it had a white screen. I tried pressing lock and home button for 10 seconds and it worked but while i'm using it it goes white with lines on the screen. Help please. This has been happening for a while and i've tried everything but it doesn't work.

    Try:
    fix for Home button
    iPhone Home Button Not Working or Unresponsive? Try This Fix
    - If you have iOS 5 and later you can turn on Assistive Touch it add the Home and other buttons to the iPods screen. Settings>General>Accessibility>Assistive Touch
    - If not under warranty Apple will exchange your iPod for a refurbished one for:
    Apple - Support - iPod - Repair pricing
    You can do it an an Apple store by:
    Apple Retail Store - Genius Bar
    or sent it in to Apple. See:
    Apple - Support - iPod - Service FAQ
    - There are third-party places like the following that will repair the Home button. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens

  • My iphone 4 wont turn on. it justr randomnly turned off and i have tried to hold the home and sleep buttons for a minute and also tried to put it into recovery mode but nothing is working?

    my iphone 4 wont turn on. it justr randomnly turned off and i have tried to hold the home and sleep buttons for a minute and also tried to put it into recovery mode but nothing is working?

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...
    Be sure to Follow ALL the Steps...
    But... if the Device has been Modified... this will Not necessarily work.

  • For the first time, I downloaded a podcast in the podcast app by clicking on the cloud icon. Now, every single play button for all of my podcast episodes is grayed out. Why can't I play any of my podcasts any more?

    For the first time, I downloaded a podcast in the podcast app by clicking on the cloud icon. Now, every single play button for all of my podcast episodes is grayed out. Why can't I play any of my podcasts any more?

    Greetings Heather,
    After reading your post, it sounds like you are experiencing an error with the Podcasts app. You may want to consider restarting the device first, and then resetting if that does not work. This article provides detailed instructions for Restarting, and Reseting:
    Turn your iOS device off and on (restart) and reset
    How to restart
    Press and hold the Sleep/Wake button on the top of your device until the red slider appears. Then drag the slider to turn your device completely off.
    After the device turns off, press and hold the Sleep/Wake button again until you see the Apple logo.
    How to reset
    You should reset your device as a last resort and only if you can't restart it.
    To reset, press and hold both the Sleep/Wake and Home buttons for at least 10 seconds, until you see the Apple logo.
    Thank you for contributing to Apple Support Communities,
    BobbyD

  • HT1212 my iphone is frozen on the lock screen and will not let me enter my passcode, I have held the home button and power button for up to 1 minute and plugged it up to itunes because its locked it wont work? i need help

    i have connected it to itunes like i was told to do and it wont do anything because its locked with a passcode and its frozen on the lock screen and will not let me enter myt passcode and after a while it just shuts off, it has been doing this for almost 48 hours. I was told to hold the home button and power button to shut it down and that I could then restart it and it would work... Nothing has helped, What can I try???

    Reset the device by pressing and holding the home and power buttons for 15-20 seconds until the white Apple logo appears.
    If that does not resolve, restore the device via iTunes on the computer.
    If all else fails, take the device to Apple (or whomever provides support in your country) for evaluation and possible replacement.

  • Generate one instance for all users in a Group

    Hi All,
    We have BO 3.1 with  FP 2.6.
    There is a report that needs to be schedule in such a way that it will generate only one instance for all the users belonging to u201CGlobalu201D community while for rest of the users wonu2019t see any instance of it. They will simply run the report on demand providing the prompt values.
    I am able to run the report for whole u201CGlobalu201D group (using u2018schedule foru2019) option but the problem is it creates as many instances as the number of users I have in this group. As users of this group have same data level access, so primarily theyu2019ll get same report output. That is why it is not desirable to run this report for all of them instead there should be a way it creates one instance after each schedule for the whole community.
    Please suggest.
    Thanks,
    Chandra

    Hi Chandra,
    I think there are still ways to use publications to achieve what you want.
    For instance, I created the below scenario:
    - Created 3 users (pub1, pub2, pub3) and put them in group (publication users)
    - I created a publication and specified the "publication users" group as the enterprise recipients
    - Set the destination to be Default & BusinessObjects Inbox.  Set the "Send As" option to Shortcut instead of copy.
    - Under Advanced, I set it to one db fetch for all recipients.
    - Scheduled this and it ran the report once, and created a shortcut to that object in each users inbox (user in the group specified)
    This meets most of your criteria.  The rest of it should be handled by security on the objects/folders.
    Another option may be Object Packages with the proper security setup.
    Thanks
    JB

  • I have 3 computers in my home and would like for all to b...

    i have 3 computers in my home and would like for all to be able yto connect to the internet using my linksys router.  the only one currently able to connect is the one he router is connected yto.  can you help

    Are the other two computers desktops or are they laptops with wireless cards inside?
    Message Edited by Deluxe8520 on 08-27-2007 12:32 PM

  • My iphone keeps blocking in a "boot" mode... blackscreen with apple logo... the restarting (home and power button for 10 sec) doesn't work.

    my iphone keeps blocking in a "boot" mode... blackscreen with apple logo... the restarting (home and power button for 10 sec) doesn't work. when i get it in DFU mode and try restoring with itunes it remains the same... provider already "fixed" this problem twice with a "software update" only to get the same problem again... it just "reboots" this time it happened @ night while charging... previous time in my jacket pocket... this is the 3th time it happens, and my provider (Mobistar belgium) doesn't wish to exchange or refund my iphone witch clearly has something wrong 3 times same problem in 3 months...

    imanfromsweden wrote:
    Please apple support do you people have a convincing answer for us? Is there a solution? My phone is only 2 years old and was (2 hours ago), in top condition!!
    Please help....
    On belhalf of my fellow volunteers, the answer is, "We'll try our best." 
    My advice is to try not to treat this like it is a paid service provided by compensated professionals.  Ask nicely and one of the nice folks here might take some time out of their weekend to offer advice.

  • My Ipod will not turn on. I held down the power and home button for several seconds, and the apple sign shows up. Itunes doesn't even recognize my Ipod. HELP!!!!

    My Ipod will not turn on. I held down the power and home button for several seconds, and the apple sign shows up. Itunes doesn't even recognize my Ipod. HELP!!!!
    How do I restore my Ipod when Itunes doesn't even recognize it???
    I don't care even if I loose all my songs and apps, I just want me Ipod to work again!!!
    PLEASE HELP!!!! THANKS IN ADVANCE

    I ended up on this link, which related to my problem:
    http://support.apple.com/kb/ht1808
    When I got to step #3 (While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.) my Ipod would not turn on, and Itunes did not recognize my Ipod. :S

Maybe you are looking for

  • How do i replace my hard drive? dv4

    I have a Pavilion DV4 Entertainment Laptop.  I replaced the hard drive and now it is acting like the drive isn't installed.  When I check BIOS, it says no HDD exists.  Is there something I am missing?  I made sure the drive is seated, it has 3 screws

  • I'm trying to create a PDF from iPhoto

    I saved the files as JPG using the export function, and got them down to around 45 Kb each. I imported them into the library, selected them all, and checked the info; it showed a total of 1.3 MB. So I selected print, saved a PDF, and the result was 2

  • IDoc Scenario - how to jump in context

    Hello, I need help for my iDoc -> XML scenario. follow situation IDOC ---SEC1 VAL1=11 VAL2=aa ---SEC1 VAL1=22 VAL2=bb ---SEC1 VAL1=33 VAL2=cc ---SEC2 SEC2.1 VAL1=11 VAL2=ab SEC2.1 VAL1=22 VAL2=bc SEC2.1 VAL1=33 VAL2=cd SEC2.2 VAL1=22 VAL2=xyz I have

  • Documents massive upload Solution manager

    Hi, I am trying to make a massive upload of documentation to Sap Solution Manager, i can upload the documentation into the KW but when i try to save the documentation in SOLAR02 estructure with the function solar_appl_save_items does not work. Here i

  • Indesign and other for £19.95 each.... Legit?!?!?!?!

    sorry to bother this forum, but just found a website ( URL deleted by host) on which you can buy Indesign and other for £19.95 a piece. sounds like a fraud and just wanted to check with others whether to trust this kind of thing and how to find out w