Hi,
I have a JideTabbedPane. I want to flash a particular tab(say 2nd tab) for 5 seconds. How do I do that? Can you please reply ASAP.
Moderator: JIDE Support
/*
* @(#)TabbedPaneFlashable.java 3/16/2007
*
* Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
*/
package com.jidesoft.swing;
import javax.swing.*;
import java.awt.*;
public class TabbedPaneFlashable extends Flashable {
private int _tabIndex;
private Color _background;
private Color _foreground;
private Color _savedBackground;
private Color _savedForeground;
public TabbedPaneFlashable(JTabbedPane component) {
super(component);
}
public TabbedPaneFlashable(JTabbedPane component, int tabIndex, Color background, Color foreground) {
super(component);
_tabIndex = tabIndex;
_background = background;
_foreground = foreground;
if (getComponent() instanceof JTabbedPane) {
JTabbedPane tabbedPane = (JTabbedPane) getComponent();
_savedBackground = tabbedPane.getBackgroundAt(_tabIndex);
_savedForeground = tabbedPane.getForegroundAt(_tabIndex);
}
}
public void flash() {
boolean flashOn = getSynchronizedFlashFlag();
if (getComponent() instanceof JTabbedPane) {
JTabbedPane tabbedPane = (JTabbedPane) getComponent();
if (flashOn) {
if (_foreground != null) {
tabbedPane.setForegroundAt(_tabIndex, _foreground);
}
if (_background != null) {
tabbedPane.setBackgroundAt(_tabIndex, _background);
}
}
else {
if (_savedForeground != null) {
tabbedPane.setForegroundAt(_tabIndex, _savedForeground);
}
if (_savedBackground != null) {
tabbedPane.setBackgroundAt(_tabIndex, _savedBackground);
}
}
if (tabbedPane instanceof JideTabbedPane) {
((JideTabbedPane) tabbedPane).repaintTabAreaAndContentBorder();
}
}
}
public void clearFlashing() {
if (getComponent() instanceof JTabbedPane) {
JTabbedPane tabbedPane = (JTabbedPane) getComponent();
tabbedPane.setForegroundAt(_tabIndex, _savedForeground);
tabbedPane.setBackgroundAt(_tabIndex, _savedBackground);
}
}
}
/*
* @(#)TabbedPaneFlashableDemo.java 3/16/2007
*
* Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
*/
import com.jidesoft.dialog.ButtonPanel;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.swing.Flashable;
import com.jidesoft.swing.JideTabbedPane;
import com.jidesoft.swing.TabbedPaneFlashable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
/**
* Demoed Component: {@link com.jidesoft.grid.HierarchicalTable} <br> Required jar files:
* jide-common.jar, jide-grids.jar <br> Required L&F: Jide L&F extension required
*/
public class TabbedPaneFlashableDemo extends AbstractDemo {
protected static final Color BG1 = new Color(255, 255, 255);
private JTabbedPane _tabbedPane;
public TabbedPaneFlashableDemo() {
}
public String getName() {
return "TabbedPane Demo (Flashing)";
}
public String getProduct() {
return PRODUCT_NAME_COMMON;
}
public Component getDemoPanel() {
_tabbedPane = createTabbedPane();
return _tabbedPane;
}
@Override
public String getDescription() {
return "";
}
@Override
public String getDemoFolder() {
return "G17. StyleTable";
}
public static void main(String[] args) {
LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
showAsFrame(new TabbedPaneFlashableDemo());
}
@Override
public Component getOptionsPanel() {
ButtonPanel buttonPanel = new ButtonPanel(SwingConstants.TOP);
buttonPanel.addButton(new JButton(new AbstractAction("Start Flashing") {
public void actionPerformed(ActionEvent e) {
Flashable flashable;
if (!Flashable.isFlashableInstalled(_tabbedPane)) {
flashable = new TabbedPaneFlashable(_tabbedPane, 1, Color.RED, Color.WHITE);
}
else {
flashable = Flashable.getFlashable(_tabbedPane);
}
if (flashable.isFlashing()) {
flashable.stopFlashing();
putValue(Action.NAME, "Start Flashing");
}
else {
flashable.startFlashing();
putValue(Action.NAME, "Stop Flashing");
}
}
}));
return buttonPanel;
}
private JTabbedPane createTabbedPane() {
JTabbedPane tabbedPane = new JideTabbedPane();
tabbedPane.addTab("Mail", createPanel());
tabbedPane.addTab("Calendar", createPanel());
tabbedPane.addTab("Contacts", createPanel());
tabbedPane.addTab("Tasks", createPanel());
tabbedPane.addTab("Notes", createPanel());
tabbedPane.addTab("Folders", createPanel());
tabbedPane.addTab("Shortcuts", createPanel());
tabbedPane.setPreferredSize(new Dimension(500, 200));
return tabbedPane;
}
private JScrollPane createPanel() {
return new JScrollPane(new JTextArea());
}
}
Users browsing this forum: No registered users and 22 guests