Results 1 to 5 of 5

Thread: java

  1. #1
    java

    Member Since
    Mar 20, 2013
    Posts
    3
    Question java
    I use Mac computers and I have a small java application that works fine on my Mac running Snow Leopard.

    When I take this application onto my Macbook Air running Lion the application doesnít render itself the way it does under Snow Leopard.

    The problem is with JTabbedPane. It looses the default blue color when a tab is selected or has the focus (under Snow Leopard itís blue under Lion itís gray) and also it is not possible to see which tabs are enabled or disabled under Lion.

    I was wondering if someone might have some suggestions of how to fix this JTabbedPane problem.

  2. #2
    java
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,395
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    What versions of Java are you running on each? Do you have a piece of sample code that we can try?
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  3. #3
    java

    Member Since
    Mar 20, 2013
    Posts
    3
    java
    my imac is running snow leopard version: 10.6.8 and my mackbook air i just upgraded to mountain lion version: 10.8.3 and the same problem on mountain lion it won't render JTabbedPane properly.

    i am attaching zipped files with code.

  4. #4
    java
    vansmith's Avatar
    Member Since
    Oct 19, 2008
    Location
    Toronto
    Posts
    19,395
    Specs:
    2012 13" MBP (2.5 i5, 8GB)
    Thanks but I need to know which versions of Java you're running on each machine.

    No zip file is available. Can you post a short snippet that demonstrates the tabbed pane issue?

    Mod note: I'm going to move this to a more appropriate forum since this is more of a development question.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  5. #5
    java

    Member Since
    Mar 20, 2013
    Posts
    3
    java
    snow leopard is running:

    Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-10M4203)
    Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)

    mountain lion is running:

    Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-11M4203)
    Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)

    here is the code:

    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;

    public class Grade extends JFrame
    {
    static JMenu myMenu;
    static TabOne tabOne;
    static TabTwo tabTwo;
    static TabTre tabTre;

    static int SW = 800;
    static int SH = 550;

    static JDesktopPane desk = new JDesktopPane();

    static JTabbedPane jtp = new JTabbedPane();
    static JMenuBar jmb = new JMenuBar();
    static JPanel panel = new JPanel();;

    public static void main(String[] args)
    {
    final Grade f = new Grade();

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    int w = (d.width-SW)/2;
    int h = (d.height-SH)/2;
    f.setBounds(w, h, SW,SH);

    f.setVisible(true);
    f.addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent e)
    {
    System.exit(0);
    }
    });
    }

    public Grade()
    {
    super();

    this.setTitle("java");

    mkGui();

    panel.setLayout(new BorderLayout());

    setContentPane(desk);
    desk.addComponentListener(new ComponentAdapter()
    {
    public void componentResized(ComponentEvent e)
    {
    Dimension d = desk.getSize();
    panel.setBounds(0,0, d.width, d.height);
    panel.validate();
    }
    });
    desk.add(panel);
    }

    public void mkGui()
    {
    Thread w = new Thread()
    {
    public void run()
    {
    mkMenu();
    SwingUtilities.invokeLater(new Runnable()
    {
    public void run()
    {
    mkTab();
    mkTabListener();
    }
    });
    }
    };
    w.start();
    try
    {
    w.join();
    }
    catch (InterruptedException e) {}
    }

    public void mkMenu()
    {
    JMenuItem myItem = new JMenuItem("Essentials");
    myItem.addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    }
    });

    myMenu = new JMenu("Input");

    jmb.add(myMenu);
    setJMenuBar(jmb);
    }

    public void mkTab()
    {
    jtp.addTab("disable extra", null, tabOne = new TabOne(), "");
    jtp.addTab("enable extra", null, tabTwo = new TabTwo(), "");
    jtp.addTab("extra", null, tabTre = new TabTre(), "");

    jtp.setEnabledAt(2, false);

    jtp.setTabPlacement(SwingConstants.TOP);
    jtp.setBackground(Color.white);
    panel.add(jtp);
    }

    public void mkTabListener()
    {
    jtp.addChangeListener(new ChangeListener()
    {
    public void stateChanged(ChangeEvent e)
    {
    tabHit();
    }
    });
    }

    public void tabHit()
    {
    if (jtp.getTitleAt(jtp.getSelectedIndex()).equals("di sable extra"))
    {
    jtp.setEnabledAt(2, false);
    }
    else
    if (jtp.getTitleAt(jtp.getSelectedIndex()).equals("en able extra"))
    {
    jtp.setEnabledAt(2, true);
    }
    else
    if (jtp.getTitleAt(jtp.getSelectedIndex()).equals("ex tra"))
    {
    }
    }

    public class TabOne extends JPanel
    {
    public TabOne()
    {
    JPanel p1 = new JPanel();
    p1.setLayout(new BorderLayout());
    p1.add(new JLabel(""), BorderLayout.CENTER);

    this.setLayout(new BorderLayout());
    this.add(p1, BorderLayout.CENTER);
    }
    }

    public class TabTwo extends JPanel
    {
    public TabTwo()
    {
    JPanel p1 = new JPanel();
    p1.setLayout(new BorderLayout());
    p1.add(new JLabel(""), BorderLayout.CENTER);

    this.setLayout(new BorderLayout());
    this.add(p1, BorderLayout.CENTER);
    }
    }

    public class TabTre extends JPanel
    {
    public TabTre()
    {
    JPanel p1 = new JPanel();
    p1.setLayout(new BorderLayout());
    p1.add(new JLabel(""), BorderLayout.CENTER);

    this.setLayout(new BorderLayout());
    this.add(p1, BorderLayout.CENTER);
    }
    }
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java for Mac OS X 10.6 Update 17 latest java version?
    By Applet in forum OS X - Operating System
    Replies: 2
    Last Post: 09-12-2014, 02:07 AM
  2. Difference between Java and Java Script?
    By AliOop in forum OS X - Apps and Games
    Replies: 14
    Last Post: 02-25-2013, 08:42 AM
  3. From where should I disable Java (Java preferences or Safari?)
    By dacoolest in forum OS X - Operating System
    Replies: 10
    Last Post: 04-24-2012, 01:43 PM
  4. Taking screenshot with java applet using java robot class not working
    By sagngh8 in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 07-06-2011, 08:53 AM
  5. Java Problem! Java games freezing!!
    By L33t Walrus in forum Apple Desktops
    Replies: 1
    Last Post: 02-28-2010, 02:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •