本文整理了Java中javax.swing.JTabbedPane.setSelectedIndex()
方法的一些代码示例,展示了JTabbedPane.setSelectedIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTabbedPane.setSelectedIndex()
方法的具体详情如下:
包路径:javax.swing.JTabbedPane
类名称:JTabbedPane
方法名:setSelectedIndex
暂无
代码示例来源:origin: 4thline/cling
@Override
public boolean switchDeviceView(Device device) {
for (DeviceView deviceView : tabs.keySet()) {
if (deviceView.getDevice().equals(device)) {
Component comp = tabs.get(deviceView);
tabbedPane.setSelectedIndex(tabbedPane.indexOfComponent(comp));
return true;
}
}
return false;
}
}
代码示例来源:origin: 4thline/cling
@Override
public void addDeviceView(DeviceView deviceView) {
Component comp = deviceView.asUIComponent();
if (tabbedPane.indexOfComponent(comp) != -1) {
tabbedPane.setSelectedIndex(tabbedPane.indexOfComponent(comp));
} else {
tabs.put(deviceView, comp);
tabbedPane.addTab(deviceView.getTitle(), comp);
tabbedPane.setSelectedComponent(comp);
}
}
代码示例来源:origin: chewiebug/GCViewer
private void updateTabDisplay(GCResource gcResource) {
// enable only "parser" panel, as long as model contains no data
boolean modelHasData = gcResource.getModel() != null && gcResource.getModel().size() > 0;
for (int i = 0; i < modelChartAndDetailsPanel.getTabCount(); ++i) {
modelChartAndDetailsPanel.setEnabledAt(i,
modelHasData
|| modelChartAndDetailsPanel.getTitleAt(i).equals(
LocalisationHelper.getString("data_panel_tab_parser")));
}
if (!gcResource.isReload()) {
if (modelHasData) {
modelChartAndDetailsPanel.setSelectedIndex(0);
}
else {
modelChartAndDetailsPanel.setSelectedIndex(modelChartAndDetailsPanel.getTabCount()-1);
}
}
}
代码示例来源:origin: deathmarine/Luyten
@Override
public void run() {
try {
final String title = open.name;
RTextScrollPane rTextScrollPane = open.scrollPane;
if (house.indexOfTab(title) < 0) {
house.addTab(title, rTextScrollPane);
house.setSelectedIndex(house.indexOfTab(title));
int index = house.indexOfTab(title);
Tab ct = new Tab(title);
ct.getButton().addMouseListener(new CloseTab(title));
house.setTabComponentAt(index, ct);
} else {
house.setSelectedIndex(house.indexOfTab(title));
}
open.onAddedToScreen();
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
});
代码示例来源:origin: deathmarine/Luyten
public void run() {
try {
Thread.sleep(500);
String internalName = FindBox.class.getName();
TypeReference type = metadataSystem.lookupType(internalName);
TypeDefinition resolvedType = null;
if ((type == null) || ((resolvedType = type.resolve()) == null)) {
return;
}
StringWriter stringwriter = new StringWriter();
PlainTextOutput plainTextOutput = new PlainTextOutput(stringwriter);
plainTextOutput
.setUnicodeOutputEnabled(decompilationOptions.getSettings().isUnicodeOutputEnabled());
settings.getLanguage().decompileType(resolvedType, plainTextOutput, decompilationOptions);
String decompiledSource = stringwriter.toString();
OpenFile open = new OpenFile(internalName, "*/" + internalName, getTheme(), mainWindow);
open.setContent(decompiledSource);
JTabbedPane pane = new JTabbedPane();
pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
pane.addTab("title", open.scrollPane);
pane.setSelectedIndex(pane.indexOfTab("title"));
} catch (Exception e) {
Luyten.showExceptionDialog("Exception!", e);
}
}
}.start();
代码示例来源:origin: magefree/mage
public void reset() {
tabsPanel.setSelectedIndex(0);
}
代码示例来源:origin: magefree/mage
private static void openTab(int index) {
try {
if (index > 0) {
dialog.tabsPanel.setSelectedIndex(index);
}
} catch (Exception e) {
logger.error("Error during open tab", e);
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void actionPerformed(ActionEvent e) {
if (valuesTabbedPane.getTabCount() > 0) {
int selectedIndex = valuesTabbedPane.getSelectedIndex();
if (selectedIndex + 1 < valuesTabbedPane.getTabCount()) {
valuesTabbedPane.setSelectedIndex(selectedIndex + 1);
} else {
valuesTabbedPane.setSelectedIndex(0);
}
}
}
};
代码示例来源:origin: ron190/jsql-injection
@Override
public void actionPerformed(ActionEvent e) {
if (valuesTabbedPane.getTabCount() > 0) {
int selectedIndex = valuesTabbedPane.getSelectedIndex();
if (selectedIndex - 1 > -1) {
valuesTabbedPane.setSelectedIndex(selectedIndex - 1);
} else {
valuesTabbedPane.setSelectedIndex(valuesTabbedPane.getTabCount() - 1);
}
}
}
};
代码示例来源:origin: ron190/jsql-injection
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
JTabbedPane tabPane = (JTabbedPane) e.getSource();
int dir = -e.getWheelRotation();
int selIndex = tabPane.getSelectedIndex();
int maxIndex = tabPane.getTabCount() - 1;
if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
selIndex = maxIndex - selIndex;
} else {
selIndex += dir;
}
if (0 <= selIndex && selIndex < tabPane.getTabCount()) {
// Fix #54575: NullPointerException on setSelectedIndex()
try {
tabPane.setSelectedIndex(selIndex);
} catch (NullPointerException err) {
LOGGER.error(err, err);
}
}
}
代码示例来源:origin: winder/Universal-G-Code-Sender
private void showCommandTable(Boolean enabled) {
if (enabled && (backend.isConnected() && !backend.isIdle())) {
displayErrorDialog(Localization.getString("mainWindow.error.showTableActive"));
showCommandTableCheckBox.setSelected(false);
return;
}
this.commandTable.clear();
this.bottomTabbedPane.setEnabledAt(1, enabled);
commandTableScrollPane.setEnabled(enabled);
if (!enabled) {
this.bottomTabbedPane.setSelectedIndex(0);
} else {
this.bottomTabbedPane.setSelectedIndex(1);
}
}
代码示例来源:origin: ron190/jsql-injection
protected DnDTabbedPane() {
super();
Handler h = new Handler();
this.addMouseListener(h);
this.addMouseMotionListener(h);
this.addPropertyChangeListener(h);
this.addMouseWheelListener(mouseWheelEvent -> {
JTabbedPane tabPane = (JTabbedPane) mouseWheelEvent.getSource();
int dir = -mouseWheelEvent.getWheelRotation();
int selIndex = tabPane.getSelectedIndex();
int maxIndex = tabPane.getTabCount() - 1;
if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
selIndex = maxIndex - selIndex;
} else {
selIndex += dir;
}
if (0 <= selIndex && selIndex < tabPane.getTabCount()) {
tabPane.setSelectedIndex(selIndex);
}
});
// UIManager.put() is not enough
this.setUI(new CustomMetalTabbedPaneUI());
this.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, HelperUi.COLOR_COMPONENT_BORDER));
}
代码示例来源:origin: Audiveris/audiveris
@Override
public void actionPerformed (ActionEvent e)
{
int tabIndex = stubsPane.getSelectedIndex();
if (tabIndex > 0) {
stubsPane.setSelectedIndex(tabIndex - 1);
}
}
代码示例来源:origin: protegeproject/protege
public void setSelectedEditor(OWLClassExpressionEditor editor) {
int index = activeEditors.indexOf(editor);
if (index >= 0) {
tabbedPane.setSelectedIndex(index);
}
}
代码示例来源:origin: ron190/jsql-injection
public void exportTab(int dragIndex, JTabbedPane target, int targetIndex) {
Component cmp = this.getComponentAt(dragIndex);
Component tab = this.getTabComponentAt(dragIndex);
String title = this.getTitleAt(dragIndex);
Icon icon = this.getIconAt(dragIndex);
String tip = this.getToolTipTextAt(dragIndex);
boolean isEnabled = this.isEnabledAt(dragIndex);
this.remove(dragIndex);
target.insertTab(title, icon, cmp, tip, targetIndex);
target.setEnabledAt(targetIndex, isEnabled);
target.setTabComponentAt(targetIndex, tab);
target.setSelectedIndex(targetIndex);
if (tab instanceof JComponent) {
((JComponent) tab).scrollRectToVisible(tab.getBounds());
}
}
代码示例来源:origin: chatty/chatty
public void setSelectedPrevious() {
int index = tabs.getSelectedIndex();
int count = tabs.getTabCount();
if (count > 0) {
if (index-1 >= 0) {
tabs.setSelectedIndex(index-1);
} else {
tabs.setSelectedIndex(count -1);
}
}
}
代码示例来源:origin: Audiveris/audiveris
@Override
public void actionPerformed (ActionEvent e)
{
int tabIndex = stubsPane.getSelectedIndex();
if (tabIndex < (stubsPane.getComponentCount() - 1)) {
stubsPane.setSelectedIndex(tabIndex + 1);
}
}
代码示例来源:origin: protegeproject/protege
public void addPanel(OWLClassExpressionEditor editorPanel){
editors.add(editorPanel);
if (editorPanel.setDescription(expression)){
activeEditors.add(editorPanel);
tabbedPane.add(editorPanel.getEditorName(), editorPanel.getComponent());
editorPanel.addStatusChangedListener(inputListener);
tabbedPane.setSelectedIndex(0);
}
}
代码示例来源:origin: otros-systems/otroslogviewer
private void switchPane(int indexChange) {
if (pane.getTabCount() < 2) {
return;
}
int selectedIndex = pane.getSelectedIndex();
int nextPane = (pane.getTabCount() + selectedIndex + indexChange) % pane.getTabCount();
pane.setSelectedIndex(nextPane);
}
}
代码示例来源:origin: JetBrains/jediterm
@Override
public void setSelectedIndex(int index) {
previousSelectedIndex = getSelectedIndex();
super.setSelectedIndex(index);
updateSelectedTabForeground();
revalidate();
repaint();
}
内容来源于网络,如有侵权,请联系作者删除!