I am making a custom title bar in swing, and when I use a letter "x" for the close button, it works fine. But when I replace it with an icon, the whole title bar disappears, until I hover the close button, which makes only the close button appear. Here is a snippet of my code:
// Create title bar
JPanel titleBar = new JPanel();
titleBar.setBackground(new Color(0x343434));
titleBar.setSize(screenSize.width, 36);
JButton closeButton = new JButton();
closeButton.setBackground(new Color(0, 0, 0, 0));
closeButton.setIcon(new ImageIcon(ImageIO.read(new File("src/close.png")).getScaledInstance(16, 16, Image.SCALE_SMOOTH)));
closeButton.setSize(50, 36);
closeButton.setLocation(screenSize.width - 50, 0);
closeButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
}
});
closeButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(MouseEvent e) {
closeButton.setBackground(Color.RED);
}
public void mouseExited(MouseEvent e) {
closeButton.setBackground(new Color(0x343434));
}
});
closeButton.setBorder(null);
closeButton.setFocusPainted(false);
titleBar.add(closeButton);
window.add(titleBar);
Edit: it works sometimes now, but sometimes it doesn't. Here is the new code:
public class Main {
public static void main(String[] args) throws IOException {
// Get screen size
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
// Create window
JFrame window = new JFrame();
//Get taskbar size
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(window.getGraphicsConfiguration());
int taskBarHeight = screenInsets.bottom;
// Configure window
window.setSize(screenSize.width, screenSize.height - taskBarHeight);
window.getContentPane().setBackground(new Color(0x232323));
window.setUndecorated(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
// Create title bar
JPanel titleBar = new JPanel();
titleBar.setBackground(new Color(0x343434));
titleBar.setSize(screenSize.width, 36);
JButton closeButton = new JButton();
closeButton.setBackground(new Color(0x343434));
Image closeImg = ImageIO.read(new File("src/close.png")).getScaledInstance(16, 16, 4);
closeButton.setIcon(new ImageIcon(closeImg));
closeButton.setSize(50, 36);
closeButton.setLocation(screenSize.width - 50, 0);
closeButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
}
});
closeButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(MouseEvent e) {
closeButton.setBackground(Color.RED);
}
public void mouseExited(MouseEvent e) {
closeButton.setBackground(new Color(0x343434));
}
});
closeButton.setBorder(null);
closeButton.setFocusPainted(false);
titleBar.add(closeButton);
window.add(titleBar);
}
}
closeButton.setBackground(new Color(0, 0, 0, 0));
Don't use a transparent background. Swing doesn't paint components properly when you use transparency.
For full transparency you simply use:
closeButton.setOpaque( false );
Swing was designed to be used with layout managers:
closeButton.setSize(50, 36);
closeButton.setLocation(screenSize.width - 50, 0);
The above code will do nothing (so get rid of it). The default layout manager of a JPanel is the FlowLayout. Once the frame is visible the layout manager will be invoked and the size/location will be reset by the layout manager.
So let the layout manager do it's job. In your case you can use:
//JPanel titleBar = new JPanel();
JPanel titleBar = new JPanel( new FlowLayout(FlowLayout.RIGHT) );
Now any components you add to the panel will be aligned to the right edge.
window.add(titleBar);
The default layout manager for a JFrame is the BorderLayout. When you don't specify a constraint, the component is added to the CENTER.
For a title bar you would want that added to the top of the Frame. So you should be using:
//window.add(titleBar);
window.add(titleBar, BorderLayout.PAGE_START);
Read the Swing tutorial on Layout Managers for more information and working examples for both the FlowLayout and the BorderLayout.
Also, Swing components need to be added to the frame BEFORE the frame is made visible. The layout manager is initially invoked when the frame is "packed" or made "visible".
Related
I am trying to add a JTextField at a position where a mouse click happens.The size of the text field should be variable based on the text entered. Below is my code.
public class Paint {
public static void main(String[] args) {
final JFrame frame = new JFrame("Test TextField");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.setSize(400, 250);
final JTextField text = new JTextField();
frame.addMouseListener(new MouseListener() {
#Override
public void mouseClicked(MouseEvent me) {
}
});
frame.setVisible(true);
}
}
I want to add the text field at the position where the mouse click happened. The size of the text field should increase based on the text entered in the text field. Can someone let me know how to implement the mouse click method to achieve the same?
I tried to set bounds of the text box using the event x and y positions like
text.setBounds(event.getX(), event.getY(), event.getX(), event.getY());
but with this the size of textField is same as the full frame. but i want a small text box with varying size
First, we need to remove the layout to be able to add component where we want
frame.setLayout(null);
Then, we can check the result of the event with :
frame.addMouseListener(new MouseAdapter() {
#Override
public void mouseClicked(MouseEvent event) {
System.out.println(event.getX() + " " + event.getY());
}
}
we can notice if we click on the upper left corner that we can't get a (0,0) coordinate. Because A frame is the complete screen, so we need to use the ContentPane or we can simply use a JPanel keep it simple.
final JPanel panel = new JPanel();
panel.setLayout(null);
frame.getContentPane().add(panel);
panel.addMouseListener(new MouseAdapter() {}); //Use the MouseAdapter to not be force to override the full interface of MouseListener.
Now, let's add a component on click. First, we create it during the event (to create a new one each time and we set the size :
final JTextField text = new JTextField();
text.setSize(new Dimension(50, 18)); //I took those randomly...
The important part is the location, set it to the component like :
text.setLocation(event.getX(), event.getY());
And add it to the panel
panel.add(text);
The result is a new JTextField added at the specific position of the click.
Full test code
public static void main(String[] args) {
final JFrame frame = new JFrame("Test TextField");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 250);
final JPanel panel = new JPanel();
panel.setLayout(null);
panel.addMouseListener(new MouseAdapter() {
#Override
public void mouseClicked(MouseEvent event) {
final JTextField text = new JTextField("abc");
text.setLocation(event.getX(), event.getY());
text.setSize(new Dimension(50, 18));
panel.add(text);
}
});
frame.getContentPane().add(panel);
frame.setVisible(true);
}
Note that this is not the best usage a Swing, layouts are there to build efficient screen easily.
My question is how to display buttons on top of a circle which created with Graphics. My code is :
public class Grafik extends JFrame {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Grafik frame = new Grafik();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Grafik() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 784, 419);
JPanel contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JButton btnNewButton = new JButton("Click");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fire();
}
});
btnNewButton.setBounds(64, 73, 32, 32);
contentPane.add(btnNewButton);
}
public void fire()
{
JPanel panel = new JPanel(){
#Override
public void paint(Graphics g)
{
g.setColor(Color.black);
g.drawOval(20, 20, 400, 400);
g.fillOval(20,20,400,400);
g.setColor(Color.white);
g.drawOval(60, 60, 300, 300);
g.fillOval(60,60,300,300);
}
};
panel.setBounds(10, 27, 383, 233);
setContentPane(panel);
JButton btn = new JButton();
btn.setIcon(new ImageIcon("C:\\Users\\nuria\\Desktop\\icon1.png"));
btn.setBounds(75, 76, 32, 32);
panel.add(btn);
}
}
This code is a little part of my project. I have a lot of panels in my project and my fire method isn't called firstly. I mean the fire method is called by sixth panel. I have to draw two circles with buttons. These buttons should be between two circles. But i cant display buttons directly. When i hover the buttons, they show. I want to show buttons instantly when the sixth panel opens.
I have two buttons above. When the first button is clicked, another panel should open and show circles(which created with Graphics) and another button(with a icon) between them.
JPanel panel = new JPanel(){
#Override
public void paint(Graphics g)
{
Don't override paint(). Custom painting is done by overriding paintComponent() and don't forget to invoke super.paintComponent() as the first statement.
The problem with your current code is that by overriding paint you have changed the default painting logic of the panel and the child components are never painted.
Take a look at the section from the Swing tutorial on Custom Painting for more information and examples, especially the section on A Closer Look at the Paint Mechanism.
When I set the window to non-opaque,the font look like changed!Who can tell me why and help me ,thanks!
I guess this is affected by the "RenderingHints.KEY_ANTIALIASING",but I test in many way,and ther is no my desired result.
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setUndecorated(true);
AWTUtilities.setWindowOpaque(frame, false);
JPanel mainPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 10));
mainPanel.add(new JLabel("Why this changed?"));
JLabel lbl2 = new JLabel() {
#Override
public void paint(Graphics g) {
// super.paint(g);
// ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.drawString("There is no change", 0, 15);
}
};
lbl2.setPreferredSize(new Dimension(240, 22));
mainPanel.add(lbl2);
JPanel toolPanel = new JPanel(new FlowLayout());
final JCheckBox ckxWindowOpaque = new JCheckBox("WindowOpaque");
ckxWindowOpaque.setSelected(!AWTUtilities.isWindowOpaque(frame));
ActionListener al = new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
boolean b = AWTUtilities.isWindowOpaque(frame);
if (b == !ckxWindowOpaque.isSelected()) return;
if (b) {
AWTUtilities.setWindowOpaque(frame, false);
} else {
AWTUtilities.setWindowOpaque(frame, true);
}
}
};
ckxWindowOpaque.addActionListener(al);
toolPanel.add(ckxWindowOpaque);
toolPanel.add(new JButton(new AbstractAction("Exit") {
#Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}));
frame.getContentPane().add(toolPanel, BorderLayout.NORTH);
frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
((JComponent) frame.getContentPane()).setBorder(BorderFactory.createLineBorder(Color.black));
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setBounds(200, 200, 200, 200);
frame.setVisible(true);
}
This will have to do with how Swing/AWT deals with the different requirements between an opaque and transparent window and changes being made internally to the anti aliasing.
For example, if I use
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
To render the text, I can get it to appear the same way when it's made transparent
I also get the same result from VALUE_TEXT_ANTIALIAS_DEFAULT, VALUE_TEXT_ANTIALIAS_GASP
But if I use VALUE_TEXT_ANTIALIAS_LCD_HBGR or VALUE_TEXT_ANTIALIAS_LCD_HRGB it will act the same as the JLabel in both modes
These are system level decisions and I don't think you can effect them (easily).
You might like to take a look at LCD Text: Anti-Aliasing on the Fringe, which is an interesting read, but I'm not sure it will help much...
I have been debugging and tracing my program,and I found the key code here:SwingUtilities2.drawString/drawChars/drawTextAntialiased.
So,I modified the JRE's code in the "SwingUtilities2.drawString/drawChars",I add code like this :
if (UIManager.getBoolean("MYLAF.AATextInfo.Disable")) {
g.drawChars(data, offset, length, x, y);
return nextX;
}
Finally,on the begin of my program,I add the setting "UIManager.put("MYLAF.AATextInfo.Disable",true)".
If you wan't modify the SwingUtilities2,you can use "myJComponent.setClientProperty(AA_TEXT_PROPERTY_KEY,null)".
I've created a modal dialog inside a JFrame using the glass pane. My display method is quite simple: it creates a JPanel as glass pane with some alpha background and adds the JLabel and an ok and close button. Then the glass pane is set and displayed via frame.getGlassPane().setVisible(true);.
Everything works fine: if I call the method the pane is displayed and I can click ok or cancel and the glass pane hides. But the method returns directly after showing the glass pane. But I want it to behave like the JOptionPane methods: they block until the dialog is closed.
But everytime I'm trying to insert any kind of busy waiting at the end of my show method the GUI is frozen if I click the open button. I've also tried to get the mechanism from JDialog#show() but that's a bit to complicated for me.
So how to block the show method while the glass pane is visible?
Here is a simple example:
public class GlassPaneSSCE extends JPanel {
private JFrame parentFrame;
public GlassPaneSSCE(JFrame parent) {
parentFrame = parent;
addKeyListener(new KeyAdapter() {});
addMouseListener(new MouseAdapter() {});
setBackground(new Color(0, 0, 0, 100));
initGui();
}
#Override
protected void paintComponent(Graphics g) {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
super.paintComponent(g);
}
private void initGui() {
setLayout(new FlowLayout(FlowLayout.CENTER));
setOpaque(false);
final JPanel content = new JPanel(new BorderLayout(4, 4));
content.setOpaque(true);
content.setBorder(new EmptyBorder(8, 8, 8, 8));
JLabel top = new JLabel("Title of this little modal dialog");
content.add(top, BorderLayout.NORTH);
JPanel inner = new JPanel(new BorderLayout());
content.add(inner, BorderLayout.CENTER);
inner.add(new JScrollPane(new JList(new String[] {
"Item 1 ",
"Item 2", "Item 3"
})));
Box ctrlButtons = Box.createHorizontalBox();
ctrlButtons.setBorder(new EmptyBorder(0, 4, 4, 4));
ctrlButtons.add(Box.createHorizontalGlue());
ctrlButtons.add(new JButton(new AbstractAction("OK") {
#Override
public void actionPerformed(ActionEvent e) {
parentFrame.getGlassPane().setVisible(false);
parentFrame.setGlassPane(new JPanel());
}
}));
content.add(ctrlButtons, BorderLayout.SOUTH);
add(content);
}
public void display() {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
parentFrame.setGlassPane(GlassPaneSSCE.this);
parentFrame.getGlassPane().setVisible(true);
// Set the focus on the glass pane
requestFocus();
setFocusCycleRoot(true);
}
});
// The next line should be executed only if
// the ok button is clicked and not before
System.out.println("End of display()");
}
public static void main(String[] args) {
final JFrame f = new JFrame();
f.setLayout(new FlowLayout(FlowLayout.CENTER));
JTextArea tp = new JTextArea(10, 10);
for (int i = 0; i < 20; i++) {
JButton b = new JButton("Open");
b.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
GlassPaneSSCE gp = new GlassPaneSSCE(f);
gp.display();
}
});
f.add(b);
tp.append("Item " + (i+1) + "\n");
}
f.add(new JScrollPane(tp));
f.setSize(600, 600);
f.setVisible(true);
}
}
I'm working in with a JTabbedPane, I need to add a close button in the tabs to close the current one.
I have been searching and as I understand I must extend from JPanel and add the close button as they say here
But, is there a way to add the close buttons extending JTabbedPane or is there a easier way to do it?
Thanks in advance, I really appreciate your time and your help.
Essentially, you're going to need to supply a "renderer" for the tab. Take a look at JTabbedPane.setTabComponentAt(...) for more information.
The basic idea is to supply a component that will be laid out on the tab.
I typically create a JPanel, onto which I add a JLabel (for the title) and, depending on what I want to display, some kind of control that acts as the close action.
tabPane.addTab(title, tabBody);
int index = tabPane.indexOfTab(title);
JPanel pnlTab = new JPanel(new GridBagLayout());
pnlTab.setOpaque(false);
JLabel lblTitle = new JLabel(title);
JButton btnClose = new JButton("x");
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1;
pnlTab.add(lblTitle, gbc);
gbc.gridx++;
gbc.weightx = 0;
pnlTab.add(btnClose, gbc);
tabPane.setTabComponentAt(index, pnlTab);
btnClose.addActionListener(myCloseActionHandler);
Now somewhere else, I establish the action handler...
public class MyCloseActionHandler implements ActionListener {
public void actionPerformed(ActionEvent evt) {
Component selected = tabPane.getSelectedComponent();
if (selected != null) {
tabPane.remove(selected);
// It would probably be worthwhile getting the source
// casting it back to a JButton and removing
// the action handler reference ;)
}
}
}
Now, you just as easily use any component you like and attach a mouse listener to it and monitor the mouse clicks...
Updated
The above example will only remove the currently active tab, there are a couple of ways to fix this.
The best is to probably provide some means for the action to find the tab it's associated with...
public class MyCloseActionHandler implements ActionListener {
private String tabName;
public MyCloseActionHandler(String tabName) {
this.tabName = tabName;
}
public String getTabName() {
return tabName;
}
public void actionPerformed(ActionEvent evt) {
int index = tabPane.indexOfTab(getTabName());
if (index >= 0) {
tabPane.removeTabAt(index);
// It would probably be worthwhile getting the source
// casting it back to a JButton and removing
// the action handler reference ;)
}
}
}
This uses the name of tab (as used with JTabbedPane#addTab) to find and then remove the tab and its associated component...
I found a tab example (from the java site) that appears to do that, at least in theirs. (Though I thought, when I tried it in the past, that it also closed the currently selected tab, though it works properly when you run their example, though I think when I updated it to work on a tabbed java notepad, it was closing the currently selected tab, though maybe I did it wrong.
http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TabComponentsDemoProject/src/components/ButtonTabComponent.java
Yes, my thing is working now! This WILL work for the actual tab, rather than the currently selected tab!
Hopefully you have got the answer to your question. I want to give a link that was very useful for me.
JTabbedPane with a close button
Here is some code as well.
public static void createAndShowGUI()
{
JFrame frame = new JFrame("Tabs");
frame.setMinimumSize(new Dimension(500, 200));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTabbedPane tabbedPane = new JTabbedPane();
JPanel panel = new JPanel();
panel.setOpaque(false);
tabbedPane.add(panel);
tabbedPane.setTabComponentAt(tabbedPane.indexOfComponent(panel), getTitlePanel(tabbedPane, panel, "Tab1"));
JPanel panel1 = new JPanel();
panel1.setOpaque(false);
tabbedPane.add(panel1);
tabbedPane.setTabComponentAt(tabbedPane.indexOfComponent(panel1), getTitlePanel(tabbedPane, panel1, "Tab2"));
JPanel panel2 = new JPanel();
panel2.setOpaque(false);
tabbedPane.add(panel2);
tabbedPane.setTabComponentAt(tabbedPane.indexOfComponent(panel2), getTitlePanel(tabbedPane, panel2, "Tab3"));
JPanel panel3 = new JPanel();
panel3.setOpaque(false);
tabbedPane.add(panel3);
tabbedPane.setTabComponentAt(tabbedPane.indexOfComponent(panel3), getTitlePanel(tabbedPane, panel3, "Tab4"));
frame.add(tabbedPane);
// Display the window.
frame.pack();
frame.setVisible(true);
}
I made some changes in the code of oracle.
http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TabComponentsDemoProject/src/components/ButtonTabComponent.java
Giving the possibility to add an icon to the tab , plus the close tab button. Hope that helps.
public static void addTag(JTabbedPane tab, String title, Icon icon, int index){
MouseListener close = new MouseAdapter() {
#Override
public void mouseClicked(MouseEvent e) {
//your code to remove component
//I use this way , because I use other methods of control than normal: tab.remove(int index);
}
};
final ButtonClose buttonClose = new ButtonClose (title, icon, close );
tab.setTabComponentAt(index, buttonClose);
tab.validate();
tab.setSelectedIndex(index);
}
public class ButtonClose extends JPanel {
public ButtonClose(final String title, Icon icon, MouseListener e) {
JLabel ic = new JLabel(icon);
ic.setSize(icone.getIconWidth(), icone.getIconHeight());
JLabel text= new JLabel(title);
text.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
ButtonTab button = new ButtonTab();
button.addMouseListener(e);
button.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
JPanel p = new JPanel();
p.setSize(getWidth() - icone.getIconWidth(), 15);
p.add(text);
p.add(button);
add(ic);
add(p);
}
private class ButtonTab extends JButton {
public ButtonTab() {
int size = 13;
setPreferredSize(new Dimension(size, size));
setToolTipText("Close");
setUI(new BasicButtonUI());
setFocusable(false);
setBorderPainted(false);
addMouseListener(listener);
setRolloverEnabled(true);
}
#Override
public void updateUI() {
}
#Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
if (getModel().isPressed()) {
g2.translate(1, 1);
}
g2.setStroke(new BasicStroke(2));
g2.setColor(new Color(126, 118, 91));
if (getModel().isRollover()) {
g2.setColor(Color.WHITE);
}
int delta = 3;
g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
g2.dispose();
}
}
private final MouseListener listener = new MouseAdapter() {
#Override
public void mouseEntered(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setContentAreaFilled(true);
button.setBackground(new Color(215, 65, 35));
}
}
#Override
public void mouseExited(MouseEvent e) {
Component component = e.getComponent();
if (component instanceof AbstractButton) {
AbstractButton button = (AbstractButton) component;
button.setContentAreaFilled(false); //transparent
}
}
};
}
Check out Peter-Swing here. It has a JClosableTabbedPane class in it, as well as many others.
When you download the jar file you can run it and have examples of all the classes.
You can have a JLabel named "x" and use the mouseListener
private final JLabel l = new JLabel(); // this is the label for tabbedPane
private final JLabel b = new JLabel("x");//Close Button
if (closeable)
{
b.setToolTipText("Click to close");
b.setOpaque(false);
b.setBackground(Color.gray);
b.addMouseListener(new MouseAdapter()
{
#Override
public void mouseExited(MouseEvent e)
{
b.setBorder(bordere);
b.setOpaque(false);
}
#Override
public void mouseEntered(MouseEvent e)
{
b.setBorder(borderl);
}
#Override
public void mouseReleased(MouseEvent e)
{
b.setOpaque(false);
b.repaint();
if (b.contains(e.getPoint()))
{
b.setBorder(borderl);
if (confirmTabClosing())
{
tab.remove(tabIndex());
if(tab.getTabCount() == 0)
spacialTabComponent.maximizeOrRestore.doClick();
}
}
else
b.setBorder(bordere);
}
#Override
public void mousePressed(MouseEvent e)
{
b.setOpaque(true);
b.repaint();
}
});
b.setBorder(bordere);
add(b, getLeftAlignedBothFilledGBC(1, 0, new Insets(0, 0, 0, 0), 0, 0));
}
}
jbCloseButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
int index = jtbMainTabbedPane.indexOfTabComponent(jbCloseButton);
jtbMainTabbedPane.remove(index);
}
});