java

Joined
Mar 20, 2013
Messages
3
Reaction score
0
Points
1
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.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
What versions of Java are you running on each? Do you have a piece of sample code that we can try?
 
OP
B
Joined
Mar 20, 2013
Messages
3
Reaction score
0
Points
1
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.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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.
 
OP
B
Joined
Mar 20, 2013
Messages
3
Reaction score
0
Points
1
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("disable extra"))
{
jtp.setEnabledAt(2, false);
}
else
if (jtp.getTitleAt(jtp.getSelectedIndex()).equals("enable extra"))
{
jtp.setEnabledAt(2, true);
}
else
if (jtp.getTitleAt(jtp.getSelectedIndex()).equals("extra"))
{
}
}

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);
}
}
}
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top