JTabbedPane switching from within added component
Hey guys,
Anyone know how/if its possible to change between JTabbedPanes
by using a button within a component added to one of the Panes?
Class A has a JtabbedPane in it
and Class B extends JPanel and is added to the TabbedPane
as a Component
Is there anyway to have a buttonclick in class b to switch to
another tab in the parent class?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AddingATab
public static void main(String[] args)
BasicGUI gui = new BasicGUI();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(gui.getUIChanger(), "North");
f.getContentPane().add(gui.getMainUI());
f.setSize(400,400);
f.setVisible(true);
class BasicGUI
JTabbedPane tabbedPane;
public BasicGUI()
tabbedPane = new JTabbedPane();
public JTabbedPane getMainUI()
JPanel
redPanel = new JPanel(),
bluePanel = new JPanel();
redPanel.setBackground(Color.red);
bluePanel.setBackground(Color.blue);
tabbedPane.addTab("red", redPanel);
tabbedPane.addTab("blue", bluePanel);
return tabbedPane;
public JPanel getUIChanger()
JButton add = new JButton("add tab");
add.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
String nextTab = "tab " + String.valueOf(tabbedPane.getTabCount()+1);
tabbedPane.addTab(nextTab, new AddOnPanel(tabbedPane));
JPanel panel = new JPanel();
panel.add(add);
return panel;
class AddOnPanel extends JPanel
JTabbedPane tabbedPane;
public AddOnPanel(JTabbedPane tp)
tabbedPane = tp;
addNavButtons();
private void addNavButtons()
int numberTabs = tabbedPane.getTabCount();
JButton[] buttons = new JButton[numberTabs];
ActionListener l = new ActionListener()
public void actionPerformed(ActionEvent e)
JButton button = (JButton)e.getSource();
int index = tabbedPane.indexOfTab(button.getActionCommand());
tabbedPane.setSelectedIndex(index);
for(int i = 0; i < buttons.length; i++)
String ac = tabbedPane.getTitleAt(i);
buttons[i] = new JButton(ac);
buttons.setActionCommand(ac);
buttons[i].addActionListener(l);
add(buttons[i]);
Similar Messages
-
Changing states from within a component
Let's say that I have a TileList that is rendering data in a
VBox. Eventually the TileList fills up and starts scrolling. I want
to change states when clicking on item in the TileList.
I don't want to place the click-attribute in the TileList,
because it will change states when I am scrolling the list without
actually selecting anything.
I want to say click="currentState='state2'" inside the VBox,
but that does not work because state2 is at the root level, and I
don't know how to get to the root-level (in lack of a better word)
from withing the component.
This is not the proper syntax, so misunderstand me the right
way here... Is there an equivallence to
click="currentState='_root.state2'" in mxml?
Thanks for any suggestions or best practices. I want the easy
way out.
This is the general structure...
<mx:Application>
<mx:states>
<mx:State id="state1"/>
<mx:State id="state2"/>
<mx:State id="state3"/>
</mx:states>
<mx:TileList dataprovider="{...}">
<mx:itemRenderer>
<mx:component>
<mx:VBox id="ClickThisBoxToChangeStates">
<mx:Image/>
<mx:Label/>
</mx:Vbox>
</mx:component>
</mx:itemRenderer>
</mx:TileList>
</mx:Application>Your assumption is right.
It doesn't work because there is no state2-state defined
within the mx:component.
In the documentation about changing states it says that I can
go from application level and change states within a component;
like this: click="currentState='mycomponent.anotherstate'" but not
how I can change a state at application level from within a state.
When I try, it says (at runtime) that the state is not defined.
So I don't know why <mx:VBox
click="currentState='state2'"/> doesn't work.
I apprechiate your expertese a lot. -
Determining Edit/Display Mode from Within Freestyle Component
I am new to FPM. We are running ESS.
I have enhanced a new Web Dynpro Component onto an Edit page of an OVP (as a Freestyle Component).
I want the new WDC to behave differently based on the mode I am in.
How, from within the new WDC, can I tell if I have entered the Edit page in Edit (pencil) or Display mode?
Thanks...
...MikeHello Mike,
Firstly, welcome to the wonderful world of FPM
Well, usually with FPM, you have an Edit (or Read-only) button in the top, underneath the title (Identification Region, IDR). This, being standard, has some standard FPM events behind it.
In your freestyle WD component, you implemented IF_FPM_BUILDING_BLOCK interface, and with it you have some additional methods in your COMPONENT CONTROLLER, such as FLUSH, PROCESS_EVENT, and so on...
In your PROCESS_EVENT method, you can basically catch all FPM events at application level. Usually you have a big CASE, something like:
case io_event->mv_event_id.
when ...
when 'FPM_EDIT'. "you can find some constants behind CL_FPM_EVENT=>GC... Right now I'm not sure how it's called exactly. But it's advised to use this constants!
You can write your code here in order to change the behavior, basically, you can do whatever.
also, it's the same with 'FPM_READ_ONLY'
when others.
return.
endcase.
I strongly recommend you download the latest version of FPM Cookbook, or the one that is suited with your SAP NW version.
FPM Developer's Handbook SAP NetWeaver 7.03/7.31 SP4
Hope I made things a little more clear!
Tudor -
Cross-component: Call method of using component from within used component?
Hi,
I began diving into cross-component programming.
Meanwhile after having digged into some scenarios some questions came up to my mind that I am not able to answer myself. I would appreciate your help here!
Say we have to components. Comp A uses Comp B (hence, B is a component usage in A)
1) How to make them communicate not on a data level (via context binding) but on a process level, thus...
a) can I call A's method from within B? How is the approach on a general level? - as B can be used from totally different components (like A, A1, A2 ...)
b) perhaps the only way to do this is by firing events? If so, how can I react in A when an event in B (marked as interface event) gets fired? As it seems they do not get registered within A directly...
I guess the question seems to be a bit tricky. Nevertheless, I think there will be plenty of you out there who used to asked them the same questions before and came up with an approach. Would be nice to hear from you.
Best wishes,
Marc @sap1Hi,
thanks for your reply!
Indeed, I think the nature of WDA would be just to somehow map the context from the used component to the other back and forth.
Nevertheless, what if I would like to invoke a method of the using component from inside the used component.
One sample for this requirement could be e.g.:
Component B offers a tree item and a send/verify button.
Component A uses B and has some restraints regarding what the selection should look like.
The user taps the button in B (at runtime in the view container of A), the context gets updated in A and B and in Component A the verifyWithOwnConstraints() method gets called (through B).
Thanks again,
Marc -
I can't call up a URL from within a component?
Hi all. Hope you can help.
I have a flash site that contains a component. The component
is for a scroll bar that shows image slices of my work. The image
slices are buttons that when clicked should call up a seperate web
(URL) window to display the work. However when clicked the button
doesn't work. The button im using is on (release) {getURL
("work.htm")} this is fom the browser/network submenu in the global
functions menu. I think that I should be looking in the components
menu but have no idea what function or code to use.
Any advice would be massively helpful.
Cheers
RobThe images are added within the component as buttons. I don't
know how to check wether the button is accessable or not? IF you
could advise on this that would be really good. I don't think its
tracing anything.
Basically just want it to open a javascript URL window.
Cheers in advance
Rob -
Creating form element from within a component
Hi all,
I am trying to create a form element within a component
function which is then called from a .cfm page which has the cfform
tags. I keep getting a context validation error for the form
element tag. Here is some sample code:
<cfcomponent name="yourComponent">
<cffunction name="createTag" returntype="string"
access="public">
<cfsavecontent variable="returnContent">
<cfselect name="thisSelect">
<option value="0">Value 1</option>
</cfselect>
</cfsaveconten>
<cfreturn returnContent>
</cffunction>
</cfcomponent>
And in the .cfm page:
<cfform>
<cfinvoke component="yourComponent" method="createTag"
returnVariable="returnContent"/>
<cfoutput>#returnContent#</cfoutput>
</cfform>
The error occurs in the function and it says the cfselect
must be within a cfform. I tried the function without the save
content and just set the output="yes" but the same error occurs.
Any help appreciated in how to get around this. Just putting
the code in the .cfm is not an option for this.
Any help appreciated.
Jimquote:
Originally posted by:
jim1234
Thanks for the reply. Yes, that works. So it looks like it
has to do with the function call.
After some further investigation, I found out that a regular
<select> works, it's just the <cfselect> that does not.
ColdFusion wants it directly within the <cfform> tag.
Something does not make sense. If the cfsavecontent worked in
the cfm file, there is no reason for it not to work in a cfc.
If you want to persue this, the next troubleshooting step is
to copy the function to your cfm file and see if it works. I
suspect that you are trying something simple as a proof of concept. -
How can I include a javaScript files from within jsf component
Is there any way using which I can include javascript files from my jsf component. Because otherwise I have to write all the javascript commands using writer.write which is very tedious rather than this I just want to include the javascript file which contains all the functions required. Also I want that this file should be included only once irrespective of the number of components included.
Thanx in advanceThis doesn't depend on JSF. You need to include a script tag, like:
<script src="/path/script.js"
language="JavaScript" type="text/javascript"></script>
If you want to include this only once, make a file included into every page, into which you can put other resources to be included along with this script.
HTH,
rs. -
Java:comp/env namespace is only available from within J2EE component
HI
I am writing a standalone application program to access the bean using jdk1.3.1 and it's giving me the namespace error.
I deployed the bean and included the .jar file in CLASSPATH. In the program, I specify the correct namespace to lookup since it's already registered through deployment
When I run the application, I get the exception error with namespace only available withing j2ee component.
Does anyone know what's the problem?Hi,
When you deploy your bean ( im assuming you are using deploytool ) have you added your client application as a component in deploytool ?
If you haven't done this then the client app code won't be able to lookup the java:comp/env name space. The reason is, that to access this namespace ( at least with j2sdkee1.3 ) you need a "client container". This client container is generated by the deploytool automatically if you add the client application into deploytool. Sun's sample application "Dukes Bank App" is a good place to see an example of this -
Creating a button that leads back into the main Pages/States from a custom component
Hello Y'all! isnt F.C. awesome!
BUT... just cant get a button that leads from a custom component ive made back into the main bulk of pages and states ive created to work.
it runs a bit like this:
Main title page...
Photography...
Nature (on which theres a Custom Component which when clicked leads to...)
20 different custom component states each with different pics, linked via buttons
from each of which id love a button that led back to Photography, exiting the custom component
ive tried the basics: Add interaction.. when clicked.. play transition to.. state: Photography
but to no avail
any ideas? im at a loss!
thanks in advance,
TomCross component communications are an issue in Flash Catalyst 1.0. Thankfully, in Flash Catalyst 5.5 the team addressed some of those issues.
The only idea I have for remove the 'return' button from within the component, then it should be able to get you back to the home state.
Or, you might be able to wait a few weeks for the new version of Flash Catalyst to ship (or you can play with the older preview release on labs.adobe.com)
Chris -
Changing state of application from within a custom component
Hello, I have several custom components all of which are included in the parent application.
When I try to change state from a custom component, I get an error saying "undefined state: state name". How do I change the state of the application from within a custom component ? All the states are defined in the parent application.@linrsvp,
If you are using Flex3 try Application.application.currentState = "somestate";
If you are using Flex4 try FlexGlobas.topLevelApplication.currentState = "somestate";
Don't forget to import the corresponding namespaces for the above.
Thanks,
Bhasker -
When adding tags to documents from within the document using the menu, after typing a few letters and then selecting a tag it then resets and you have to go back to the beginning. This is especially annoying when trying to edit a large number of documents quickly.
It seems you have to wait up to 5 secs after typing a tag before trying to add it again. The problem appears to be some system wide delay in editing the tag into the file.
I checked the problem against my new MacBook Air and it occurs there as wel.
Anyone else come across this?Hi VikingOSX,
The method you described is the current way I am doing it, my apologies I probably wasn't clear enough.
The tagging works, but the issue is that as I start to edit in the tag area, after choosing a tag(s) it resets to blank after a couple of seconds and I have to tag again. After the second time the tags stay there and I can save the document.
The tags I am choosing are from existing tags and it doesn't matter whether I click on them from the list or start typing a few characters and they appear, the problem is the same. It might seem trivial, but I regularly scan in a large number of documents and then edit their name and tags from the Preview title bar.
I would be interested if you can recreate the issue yourself, I have it on two different Mac computers so thought it was something that was a bug in Mavericks. -
Adding custom css classes from within edge animate
is it possible to add CSS classes from within Edge Animate, im not talking about adding your own stylesheet by ex. manually editing the .html document, but rather adding classes via ex. the code window ?, it would be immensely helpful to have everything in one place.
any suggestions on this one ?Yes - you can use addclass() and you can use UI.
1- UI
Select elements in elements panel. Click the C button in the property panel.
Use this for example
sym.$('.classname').css({'color':'red'});
2- addclaas()
sym.$("name').addclass('classname');
Use same as above.
On Sat, Apr 25, 2015 at 8:56 AM mads18950258 <[email protected]> -
Fireing outbound plug of interface view from within component
Hi all,
is there a better way of firing an outbound plug of an wd component interface view than from within the interface view controller itself?
The problem is, that you easly get a cyclic reference if you evaluate inbound component plugs in the interface controller (usage from int view ctrl --> int ctrl needed) and then try to fire an outbound plug from this interface controller (usage comp int --> comp int view usage needed).
One workaround is to use some custom controller with usage of the interface view, but this doesn't seem to be a nice solution.
So is it possible to fire outbound comp plugs from, lets say the component controller - without any usage releation to the comp int view - instead, maybe via wdComponentAPI? If yes, could you provide a code snippet?
Thanks you and best regards,
ChristianHi Christian,
this is not possible by using the public API only, i'm afraid. It is of course possible, if you decide to forget about the possible drawbacks of using methods and classes reserved for internal use. But you have to use it at your own risk. I hacked this together some weeks ago, don't know whether it still works
* Fires an outbound plug of an interface view with parameters.
* @param wdComponentAPI Component API "owning" the interface view.
* @param windowName Name of window
* @param plugName Name of outbound plug
* @param callerParameterMap optional Map of plug parameters.
public static final void fireOutboundPlug(
IWDComponent wdComponentAPI,
String windowName,
String plugName,
Map callerParameterMap)
throws WDRuntimeException {
// Find window requested
IWDWindowInfo windowInfo = wdComponentAPI.getComponent().getComponentInfo().findInWindows(windowName);
if (windowInfo == null) {
throw new WDRuntimeException(
"Can't find window: " + windowName + " in component: " + wdComponentAPI.getQualifiedName());
// Get info of interface view
IWDInterfaceViewInfo ifViewInfo = windowInfo.getInterfaceView();
if (ifViewInfo == null) {
throw new WDRuntimeException("Window: " + windowName + ", no interface view info found");
// Find outbound plug
IWDOutboundPlugInfo outboundPlug = ifViewInfo.findInOutboundPlugs(plugName);
if (outboundPlug == null) {
throw new WDRuntimeException(
"The interface view: " + ifViewInfo.getName() + " has no outbound plug: " + plugName);
// Parameter passing
Collection plugParameters = outboundPlug.getParameters();
// TODO make check optional, check caller map parameter keys against existing
if (plugParameters == null || plugParameters.isEmpty()) {
// No caller parameters allowed.
if (callerParameterMap != null && !callerParameterMap.isEmpty()) {
throw new WDRuntimeException(
"The outbound plug: " + plugName + " has no parameters, callerParams must be empty/null.");
// TODO This is a hack, use of internal WD runtime classes and methods (don't use productive).
InterfaceView ifViewController =
(InterfaceView) ((Component) wdComponentAPI.getComponent()).getController(ifViewInfo.getName());
ifViewController.navigate(outboundPlug.getName(), callerParameterMap);
Please remember, that not everything which is technically possible, makes sense
Regards
Stefan -
Having switched from iPhoto to ICloud Photo I find that their are many, many double and triple photos. Just added a small folder of photoes and all are showing in photos as doubles. What am I doing wrong?
Martin,
I am not sure, however you may want to post in the Photos forum, please click Photos for Mac to get there. -
Hi,
Just switched from CS6 to PS CC. I am very comfortable using ACR in previous versions. I liked to use the preview checkbox located in the upper right-hand corner to see before and afters. That checkbox is no longer in my version of PS CC. I see that they have side-by-side, top and bottom and right and left before and after options in the lower right-hand corner in this version. Is there anyway to get that legacy preview checkbox back so that I can use it?Hi Warunicorn,
Thank you very much. I just could not find it on my own. I will have more questions as I get into it.
Jim
Maybe you are looking for
-
Trying to update two chasis's firmware to 2.0 3c. When I filter on bios the first chasis display's all b200 m3 servers. But the 2nd chasis with two b440 m2's is not visible at all to update. But when I filter on cimc/io modules etc
-
I updated my iPhone 4S to iOS 6 just fine, although it wasn't on the beta. My iPad on the other hand... When I check for the update OTA and when it's plugged into my computer, both say it's up to date. When I try to restore it I get "There was a prob
-
Java encoding on OSX Mountain Lion
Hi all! I noticed since Mountain Lion, every app I run has the incorrect encoding: Instead of MacRoman, every app running Java uses the encoding "USA-ASCII", which is a pain for european users. This happens both when I run my desktop apps, made in ja
-
Guys please help? My MacBook Pro won't start up. I have tried the resetting Mac's PRAM and NVRAM procedure with no success. All I see is just the black or grey screen although I hear the drive running.
-
I just purchased a HP touch screen. I am trying to import music from a jump drive. How do I do this??? Please help.