Changing Tabs in a TabbedPane
I have created a JTabbedPane with four tabs each containing a panel with a JTable in a scrollpane. When i run i can only view first tab, clciing on the others show an empty tab. It's probably something simple! Another class adds this JPanel into a JFrame. Here is my code:
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EReg extends JPanel {
public EReg() {
JTabbedPane tabbedPane = new JTabbedPane();
String[] changeOptions = { "standard modules", "resit modules", "other modules",
"view all changes" };
JButton button1 = new JButton("Get Details");
JComboBox changes = new JComboBox(changeOptions);
changes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
String viewType = (String)cb.getSelectedItem();}
JPanel labelPanel1 = new JPanel(new GridLayout (2, 1));
JLabel iDLabel1 = new JLabel("Student ID:");
JLabel nameLabel1 = new JLabel("Name of Student:");
labelPanel1.add(iDLabel1);
labelPanel1.add(nameLabel1);
JPanel textPanel1 = new JPanel(new GridLayout (2, 1));
JTextField studID1 = new JTextField();
JTextField name1 = new JTextField();
textPanel1.add(studID1);
textPanel1.add(name1);
JPanel topPanel = new JPanel();
topPanel.setLayout(new GridLayout(1,4));
topPanel.add(labelPanel1);
topPanel.add(textPanel1);
topPanel.add(changes);
topPanel.add(button1);
JTable viewTable = new JTable();
JPanel viewPanel = new JPanel(new BorderLayout());
viewPanel.add(topPanel, BorderLayout.NORTH);
viewPanel.add(viewTable, BorderLayout.CENTER);
tabbedPane.addTab("View", viewPanel);
tabbedPane.setSelectedIndex(0);
JPanel updatePanel = new UpdatePanel();
tabbedPane.addTab("Update", viewPanel );
JPanel approvePanel = new ApprovePanel();
tabbedPane.addTab("Approve", viewPanel);
JPanel courseDetPanel = new CourseDetPanel();
tabbedPane.addTab("Course Details", viewPanel);
setLayout(new GridLayout(1, 1));
add(tabbedPane);
Here is the full code with the tabs...each class compiles but when run, it doesnt show the panel, "vPanel", it just shows an empty panel instead. Thanx.
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class EReg extends JPanel {
public EReg() {
ViewPanel vPanel = new ViewPanel( );
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("View",null, vPanel,"");
tabbedPane.setSelectedIndex(0);
setLayout(new GridLayout(1, 1));
add(tabbedPane);
public static void main(final String[] args) {
JFrame frame = new JFrame("e-Reg Logged in as " );
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
frame.getContentPane().add(new EReg(),
BorderLayout.CENTER);
frame.setSize(800, 500);
frame.setVisible(true);
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ViewPanel extends JPanel
{ JPanel viewPanel;
public JPanel ViewPanel()
{ String[] changeOptions = { "standard modules", "resit modules", "other modules",
"view all changes" };
JButton button1 = new JButton("Get Details");
JComboBox changes = new JComboBox(changeOptions);
changes.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
String viewType = (String)cb.getSelectedItem();}
JPanel labelPanel1 = new JPanel(new GridLayout (2, 1));
JLabel iDLabel1 = new JLabel("Student ID:");
JLabel nameLabel1 = new JLabel("Name of Student:");
labelPanel1.add(iDLabel1);
labelPanel1.add(nameLabel1);
JPanel textPanel1 = new JPanel(new GridLayout (2, 1));
JTextField studID1 = new JTextField();
JTextField name1 = new JTextField();
textPanel1.add(studID1);
textPanel1.add(name1);
JPanel topPanel = new JPanel();
topPanel.setLayout(new GridLayout(1,4));
topPanel.add(labelPanel1);
topPanel.add(textPanel1);
topPanel.add(changes);
topPanel.add(button1);
JTable viewTable = new JTable();
viewPanel = new JPanel(new BorderLayout());
viewPanel.add(topPanel, BorderLayout.NORTH);
viewPanel.add(viewTable, BorderLayout.CENTER);
return viewPanel;
}
Similar Messages
-
Is there a way to automatically change tabs with different times set for each tab?
I found a few add-ons that will automatically change tabs based on a configurable time. But all the tabs use the same time setting. What I need is the ability to have tabs displayed for different amounts of time. Ex, Tab 1 for 30 seconds, Tab 2 for 10 seconds, Tab 3 and 4 for 5 seconds. Ideally, I will have the ability to modify these settings as the amount of tabs and the content will change a couple times a week.
Currently I'm using Tab Slideshow with each tab displayed for 15 seconds. But it sounds like Tab Rotate and Auto Toggle Tabs essentially do the same. If there is already a solution that would be great but if not is there someone available for hire to help modify one of the existing add-ons? Thank you in advance for your time.
JohnCurrently Firefox don't have any options like that.
You can ask the Addon developers
*http://addons.mozilla.org/ -
Changing Tab color of SuperTabNavigator
Hi .
How to change tab color of the SuperTabNavigator.
Can any help me?
thanks
Raghu.No,
Modifying the CSS files directly is not a viable option. Everytime someone saves the theme, the CSS files will be overwritten.
Refer to this for a possible solution.
Unleash the power of the Portal Theme Editor
Thanks
Prashant -
In the web client, How do you go about changing tab page names. For instance, the tab page default on complaints transaction has a heading called technical analysis. I want to change it to just analysis. I looked in the tab groups I see the event with the tab name, however, it can't be modified there? can someone enlighten me on where this modification can be made?
Amory, in order to change the actual name of the tab (read: event), every tab is associated with an event, lookup Tab Group, CPL_ODC1, here you see a View Swith Group assigned 'S10_HD_ANA'. When you lookup this View Swith Group, you see the description 'Technical Analysis'. Copy both this entry and replace it's description accordingly. Then copy the tab group and refer to the newly created View Switch Group. After this create an entry in the BAB tables for your application for the event S10_HD_TREE_ANALYSIS and refer also to you newly created tab group. Hope this helpes, Tiest.
-
Changing tab focus with the keyboard
I've read about changing the tab focus from one page to another programmatically; however, I would like to have shortcut keys to change tabs (like many programs that use CTRL+Tab to change windows within the program).
I could use an event structure to capture keyboard button presses and then change the value of the tab control, but is there a more straightforward approach?
Thanks!
mlloydYou can set all other controls not to be tabbed through and the tab control to have its pages tabbed through. That way, when you use tab, only the tab control's pages will be on the tabbing list. This, however, is probably less straightforward.
I'm not sure what's the problem with the method you outlined. In most cases, if you want something to happen, you will have to code it. This appeares to be one of those cases. You can make a subVI to do the tabbing for you, if you don't want to have to code all of it in your VI. Pass the reference of the tab control into the VI after you detect the event and use that to decide whether to increase or decrease the tab value. Be sure to cycle the number back to the first page when it reaches the end.
Try to take over the world! -
Changed Tab name is showing old name some times
Hi Friends,
I had successfully changed the enhanced tab name from the screen painter using translation and it also reflected in the transaction.
When i am going to another tab within the same screen, changed tab name <b>'Safety Inf'</b> is again getting changed to old name <b>'Enhancemnt'</b>. when i go back again to the enhanced tab, again my changed name is coming as <b>'Safety inf'</b>.
User doesn't like this...
What could be the reason? any body has idea?
Regards,
SatishHi,
Nobody has any idea about this?
Regards,
Satish -
What is the role of Changing Tab infunction module se37
Hi. All,
Any body can help me that what is the role of changing tab in function module.
i am very confuse to take this. please tell me with code ( code implementation)
not only theritical.
Regards
Mohd
Moderator message: please search for information, these forums are no substitute for ABAP training.
Edited by: Thomas Zloch on Mar 1, 2012SAP help portal
ht[http://help.sap.com/saphelp_erp60_sp/helpdata/en/2d/351ee6448c11d189420000e829fbbd/frameset.htm|http://help.sap.com/saphelp_erp60_sp/helpdata/en/2d/351ee6448c11d189420000e829fbbd/frameset.htm]
Configuration for definition of formula parameter
Customizing > Quality Management > Quality Inspection > Results Recording > Define Parameters for Calculated Characteristics
As you know, you can assign the formula for inspection characteristic in inspection plan.
Regards
Luke -
Where is the "firefox button" that is used to change tab location ("click on the Firefox button, go over to the Options... arrow and uncheck Tabs on Top. ") (from article).
The "Tools" menu has an "Options" selection, but I cannot find in any of those menus a selection controlling the location of the tabs. Where is the "Firefox Button" referred to in the article "Why are tabs on Top?"If you turn on the classic menu bar, that replaces the orange Firefox button. To get the Firefox button back, right-click the menu bar to display the toolbars list, and uncheck Menu Bar.
You can always temporarily display the classic menu bar by tapping the Alt key or pressing F10.
The toolbar list pop-up also lets you control Tabs on Top. -
Can you change tabs on a tab control by using boolean buttons?
Need to change tabs by pressing a button instead of using the actual tabs.
Absolutely. First create a local variable for your tab control. Then poll your boolean to tell when its value has changed. Finally write a value to the tab's local variable to change its tab page programmatically.
Message Edited by Jarrod S. on 02-07-2007 05:46 PM
Jarrod S.
National Instruments
Attachments:
tab.PNG 17 KB -
Forcing Save when changing Tab Pages
Hi,
I have a form with four different tab pages
and a common "Save" button (that performs
the Form commit).
The problem is that I would like to force
the user to commit any changes they have
made in one tab pages before allowing them
to change tabs.
Sort of a PRE-TAB-CHANGE trigger.
Any ideas on how to solve this ?
Thanks in advance.
Regards,
Klas MalmstromHi
You may use trigger When-Tab-Page-Changed, asking for commit and if user answers 'NO' return him to previous Tab.
Andrew. -
windows 8.1 firefox 35.0.1 is chaning the color temperature across the whole screen(including the bottom start bar) while browsing(scrolling) and/or when changing tabs between a light(white) and darker pages.
I've searched google and firefox settings without finding any information about this. I'd like it removed as I find it somewhat annoying
but where are the settings?
-DavidIf this is only happening in Firefox then try to disable hardware acceleration in Firefox.
You can try to disable hardware acceleration in Firefox.
*Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
You need to close and restart Firefox after toggling this setting.
*https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
*https://support.mozilla.org/kb/upgrade-graphics-drivers-use-hardware-acceleration -
Can we change Tab Level of Application once created
Hi,
I have created one HTML DB Application having One Tab Level.
Now I realized that I need to change Tabs & requires Two Level Tab. I tried in many ways, I could not change settings to have Two Level Tab. Please can anybody help on this?
I do not wish to delete the application & recreated them back. Please suggest a method in altering the Levels for the tab of the existing application.
Thanks in advance,
Kind Regards,
PrabhakarIn the application shared objects, select 'themes' and click the edit icon by your theme. There is an option there to set the number of tab levels.
-
I cannot use the scroll, cannot change tabs, autocomplete for the URLs does not work
cannot use scroll, cannot change tabs, cannot use autocomplete in the URL tab. this was working
== This happened ==
A few times a weekDo you have that problem when running in the Firefox SafeMode?
[http://support.mozilla.com/en-US/kb/Safe+Mode]
''Don't select anything right now, just use "Continue in SafeMode."''
If not, see this:
[http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes] -
Change "tab.jsp" of "JSPTabContainerProvider" - no result
Hello.
I have to remove upper and bottom parts of JSPTabContainer (which is the upper container of sampleportal desktop). So I remove those lines from ".../desktop/default/tab.jsp":
<jsp:include page="header.jsp" flush="true"/>
<jsp:include page="menubar.jsp" flush="true"/>
<%@ include file="footer.html" %>
And saved changes, but they were not removed from portal desktop page.
What I must do in addintion ?I am sorry for silly question. I found JSPTabContainer channel and change tab.jsp there. All correct.
-
Control Click to Change Tab Order
I know there are new ways to move the field names around to change form fields, but I miss the ability to change tab order by control clicking on the field. I like the new ones, but would like to have the old way also.
You can get the coordinates of the mouse "drop" relative to the scene in the onDragDropped handler with
event.getSceneX() and event.getSceneY().
You can get the location of the top left of a node relative to the scene with
private Point2D getSceneLocation(Node node) {
if (node.getScene() == null) {
return new Point2D(0,0);
double x = 0 ;
double y = 0 ;
for (Node n = node ; n != null; n=n.getParent()) {
Bounds boundsInParent = n.getBoundsInParent();
x += boundsInParent.getMinX();
y += boundsInParent.getMinY();
return new Point2D(x, y);
(and you can get the other corners of the node simply by adding the width and/or height from node.getBoundsInLocal() to the result of that if you need.)
So if you ensure every tab has a graphic, you can iterate through the tabs and do something like
int dropIndex = 0 ;
for (Tab tab : tabPane.getTabs()) {
Point2D tabLocationInScene = getSceneLocation(tab.getGraphic());
if (tabLocationInScene.getX() > event.getSceneX()) {
break ;
} else {
dropIndex++ ;
tabPane.getTabs().add(dropIndex, tabToBeAdded);
Ensuring every tab has a graphic probably just means setting the text to an empty string and setting the graphic to a Label containing the text; or I guess you could just use a zero width and height Rectangle, or some such.
Maybe you are looking for
-
I synced my iphone and have now lost all of my contacts and calendar data. How do I get this back?
-
How to create a template for pages in a book
How to create a template in Pages to create camera ready pages for publishing a book?
-
when i use this code....image is not displaying in the pdf...why?. <cfdocument format="pdf"> <img src="images/site_logo.gif" alt="Site Logo" border="0"> </cfdocument> Any known bug?.
-
New Mac Mini OS-X 10.9.4 Pages 4.3 and 5.2 OCR-B-10 BT Bitstream TrueType TT0646Z_.TTF My license for OCR-B (Optical Character Recognition) font fails in Pages 5.2. The top illustration is what it's supposed to look like (Pages 4.3) and the bottom
-
I have LiveCycle 8 and was wondering if this product can create expandable forms. If so, how would I go about to make expandable forms, tables and rows? Please let me know. Thank you.