本文整理汇总了Java中javax.swing.JTabbedPane.getComponentAt方法的典型用法代码示例。如果您正苦于以下问题:Java JTabbedPane.getComponentAt方法的具体用法?Java JTabbedPane.getComponentAt怎么用?Java JTabbedPane.getComponentAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTabbedPane
的用法示例。
在下文中一共展示了JTabbedPane.getComponentAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: closeAllButCurrent
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
void closeAllButCurrent() {
Component comp = getComponent(0);
if (comp instanceof JTabbedPane) {
JTabbedPane tabs = (JTabbedPane) comp;
Component current = tabs.getSelectedComponent();
int tabCount = tabs.getTabCount();
// #172039: do not use tabs.getComponents()
Component[] c = new Component[tabCount - 1];
for (int i = 0, j = 0; i < tabCount; i++) {
Component tab = tabs.getComponentAt(i);
if (tab != current) {
c[j++] = tab;
}
}
for (int i = 0; i < c.length; i++) {
((RefactoringPanel) c[i]).close();
}
}
}
示例2: componentClosed
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
@Override
protected void componentClosed() {
isVisible = false;
if (getComponentCount() == 0) {
return ;
}
Component comp = getComponent(0);
if (comp instanceof JTabbedPane) {
JTabbedPane pane = (JTabbedPane) comp;
// #172039: do not use tabs.getComponents()
Component[] c = new Component[pane.getTabCount()];
for (int i = 0; i < c.length; i++) {
c[i] = pane.getComponentAt(i);
}
for (int i = 0; i < c.length; i++) {
((RefactoringPanel) c[i]).close();
}
} else if (comp instanceof RefactoringPanel) {
((RefactoringPanel) comp).close();
}
}
示例3: testTextualDiffContent
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
public void testTextualDiffContent () throws Exception {
File diffFile = new File(getDataDir(), "enhancedview/diff");
String goldenText = getFileContents(diffFile);
goldenText = MessageFormat.format(goldenText, new Object[] {"a/", "b/"});
final JTabbedPane tabbedPane = findTabbedPane(enhanced.getJComponent());
JPanel p = (JPanel) tabbedPane.getComponentAt(1);
tabbedPane.setSelectedIndex(1);
JEditorPane pane = findEditorPane(p);
assertFalse(pane == null);
String text = pane.getText();
for (int i = 0; i < 100; ++i) {
if (!text.isEmpty()) {
break;
}
Thread.sleep(100);
text = pane.getText();
}
assertEquals(goldenText, text);
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run () {
tabbedPane.setSelectedIndex(0);
}
});
}
示例4: setTabTitle
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
/**
* Sets the tab title.
*/
private void setTabTitle() {
String tabTitle = "";
if (this.getSeriesTableModels().size()==0) {
tabTitle = "Table (0)";
} else {
tabTitle = "Table (" + (currSeriesSelection+1) + "/" + this.getSeriesTableModels().size() + ")";
}
Container tableTab = this.myJTable.getParent().getParent().getParent();
JTabbedPane editorTabbedPane =(JTabbedPane) tableTab.getParent();
if (editorTabbedPane!=null) {
int tabPosIndex = 0;
for (tabPosIndex=0; tabPosIndex<editorTabbedPane.getTabCount(); tabPosIndex++) {
if (editorTabbedPane.getComponentAt(tabPosIndex)==tableTab) {
break;
}
}
editorTabbedPane.setTitleAt(tabPosIndex, tabTitle);
}
}
示例5: navigateToTestData
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
public Boolean navigateToTestData(String sheetName, String columnName) {
if (envTab.getSelectedComponent() instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) envTab.getSelectedComponent();
for (int i = 0; i < tab.getTabCount(); i++) {
if (tab.getComponentAt(i) instanceof TestDataTablePanel) {
TestDataTablePanel tdPanel = (TestDataTablePanel) tab.getComponentAt(i);
if (tdPanel.std.getName().equals(sheetName)) {
int colIndex = tdPanel.std.getColumnIndex(columnName);
if (colIndex != -1) {
tab.setSelectedIndex(i);
tdPanel.table.selectColumn(colIndex);
return true;
}
break;
}
}
}
}
return false;
}
示例6: test
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
private static void test() {
int N = 5;
JTabbedPane tabbedPane = new JTabbedPane();
for (int i = 0; i < N; i++) {
tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
}
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
Component child = tabbedPane.getComponentAt(i);
AccessibleContext ac = child.getAccessibleContext();
if (ac == null) {
throw new RuntimeException("Accessible Context is null!");
}
int index = ac.getAccessibleIndexInParent();
Accessible parent = ac.getAccessibleParent();
if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
throw new RuntimeException("Wrong getAccessibleIndexInParent!");
}
}
}
示例7: openTab
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
private void openTab(Component component, JTabbedPane pane) {
for (int i = 0; i < pane.getTabCount(); i++) {
if (component == pane.getComponentAt(i)) {
pane.setSelectedIndex(i);
break;
}
}
}
示例8: paintIcon
import javax.swing.JTabbedPane; //导入方法依赖的package包/类
/**
* Draw the icon at the specified location. Icon implementations may use
* the Component argument to get properties useful for painting, e.g.
* the foreground or background color.
*
* @param c the component which the icon belongs to
* @param g the graphic object to draw on
* @param x the upper left point of the icon in the x direction
* @param y the upper left point of the icon in the y direction
*/
public void paintIcon(Component c, Graphics g, int x, int y) {
boolean doPaintCloseIcon = true;
try {
// JComponent.putClientProperty("isClosable", new
// Boolean(false));
JTabbedPane tabbedpane = (JTabbedPane) c;
int tabNumber = tabbedpane.getUI().tabForCoordinate(tabbedpane,
x, y);
JComponent curPanel = (JComponent) tabbedpane
.getComponentAt(tabNumber);
Object prop = null;
if ((prop = curPanel.getClientProperty("isClosable")) != null) {
doPaintCloseIcon = (Boolean) prop;
}
} catch (Exception ignored) {/*
* Could probably be a
* ClassCastException
*/
}
if (doPaintCloseIcon) {
x_pos = x;
y_pos = y;
int y_p = y + 1;
if (normalCloseIcon != null && !mouseover) {
normalCloseIcon.paintIcon(c, g, x, y_p);
} else if (hooverCloseIcon != null && mouseover
&& !mousepressed) {
hooverCloseIcon.paintIcon(c, g, x, y_p);
} else if (pressedCloseIcon != null && mousepressed) {
pressedCloseIcon.paintIcon(c, g, x, y_p);
} else {
y_p++;
Color col = g.getColor();
if (mousepressed && mouseover) {
g.setColor(Color.WHITE);
g.fillRect(x + 1, y_p, 12, 13);
}
g.setColor(Color.black);
g.drawLine(x + 1, y_p, x + 12, y_p);
g.drawLine(x + 1, y_p + 13, x + 12, y_p + 13);
g.drawLine(x, y_p + 1, x, y_p + 12);
g.drawLine(x + 13, y_p + 1, x + 13, y_p + 12);
g.drawLine(x + 3, y_p + 3, x + 10, y_p + 10);
if (mouseover)
g.setColor(Color.GRAY);
g.drawLine(x + 3, y_p + 4, x + 9, y_p + 10);
g.drawLine(x + 4, y_p + 3, x + 10, y_p + 9);
g.drawLine(x + 10, y_p + 3, x + 3, y_p + 10);
g.drawLine(x + 10, y_p + 4, x + 4, y_p + 10);
g.drawLine(x + 9, y_p + 3, x + 3, y_p + 9);
g.setColor(col);
if (fileIcon != null) {
fileIcon.paintIcon(c, g, x + width, y_p);
}
}
}
}