Improvements to a code! Help!
I have a code and the question is how do i make these three improvements to the code. Here is the code...
import javax.swing.JOptionPane;
public class FibonacciNumber
public static void main (String[] args)
String inputString;
String outputString;
int previous1;
int previous2;
int current = 0;
int counter;
int nthFibonacci;
inputString =
JOptionPane.showInputDialog("Enter the first "
+ "Fibonacci number:");
previous1 = Integer.parseInt(inputString);
inputString =
JOptionPane.showInputDialog("Enter the second "
+ "Fibonacci number: ");
previous2 = Integer.parseInt(inputString);
outputString = "The first two numbers of the "
+ "Fibonacci sequence are: "
+ previous1 + " and " + previous2;
inputString =
JOptionPane.showInputDialog("Enter the position "
+ "of the desired number in "
+ "the Fibonacci sequence: ");
nthFibonacci = Integer.parseInt(inputString);
if (nthFibonacci == 1)
current = previous1;
else if (nthFibonacci == 2)
current = previous2;
else
counter = 3;
while (counter <= nthFibonacci)
current = previous2 + previous1;
previous1 = previous2;
previous2 = current;
counter++;
outputString = outputString + "\nThe "
+ nthFibonacci
+ "th Fibonacci number of "
+ "the sequence is: "
+ current;
JOptionPane.showMessageDialog(null, outputString,
"Fibonacci Number",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
The three improvements are...
1. check whether the first number entered by the use is less or equal to the second number.
2. check that both numbers are nonnegative.
3. Check whether the user entered a valid value for the position of the desired number in the Fibonacci sequence.
Could someone please help!
So this is how I did it...
if (previous1 <= previous2)
System.out.println("Good number choice!")
else
System.out.println("Choose a different number!")
if (previous1 < 0)
previous1 = -previous1;
if (previous2 < 0)
previous2 = -previous2;
if (nthFibonacci == 1)
current = previous1;
else if (nthFibonacci == 2)
current = previous2;
else
Is that the correct way? For finding out whether the entered value is okay for the position of the number in the Fibonacci sequence..would I use an IF statement also?
Similar Messages
-
Survey creation abap code help needed
hello experts,
I need to create a survey in crm, by taking values from end-user from a webpage
A sample code help is needed.
Thanks in advanceTake a look at this SAP note - It does a pretty good job of detailing the steps for you. No coding necessary, it worked out of the box for us after patching this note.
https://service.sap.com/sap/support/notes/638320 -
Inquiring minds may find this error code helpful: 0x207
Hopefully I'm asking this in the right forum. I just downloaded the update for Microsoft Remote Desktop for Windows Phone 8.1 (I am actually running Denim on a 1520 but that may not matter). The version is 8.1.8.13 released 3/4/2015. I am trying to connect
to a RemoteApp application but I am receiving the following error message shortly after it tries the redirection process (I think it fails at the securing remote connection part after it attemps the redirction to the RemoteApp application collection server):
Connection error
We couldn't connect to the remote PC. This might be due to an expired password. If this keeps happening, ask your admin or tech support for help.
Inquiring minds may find this error code helpful: 0x207
I am able to connect directly to both the broker server as well as the RemoteApp collection server with this application with the same credentials and am only experiencing this when trying to connect to a RemoteApp application.
We are running Server 2012 R2 for both the broker/web and the collection servers. We are not using a gateway server as we use an SSL VPN concentrator instead for access outside of our network. We have server farms set up as well in the RemoteApp topology.
Any info would help or let me know if I'm not posting in the right forum for this issue. I know this is a very recent release so I'm trying to figure out if I should wait for a bug fix or if there's something that I can do on my end.
Thank you in advance for your time!Hi Scott,
Please check your configuration once again and the certificate must be well configured. Also for accessing RemoteApp there might be the permission issue for your use, recheck once and verify. You can also got through
this article for information.
Hope it helps!
Thanks.
Dharmesh Solanki
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Redemption code help that you keep sending everyone to is NOT HELPING. It just tells you to put in the redemption code. IF I HAD THE CODE I WOULD HAVE PUT IT IN!! How do I find the code?
Version 5.5 was/is not part of the Cloud, so you could not have subscribed to that version
You install version 5.5 on a 2nd computer exactly the same way you did the 1st time... put the disc in the drive and enter your serial number when asked
Does your serial number show on your account page?
https://www.adobe.com/account.html for serial numbers on your Adobe page... or
Lost serial # http://helpx.adobe.com/x-productkb/global/find-serial-number.html -
Code help in writing report Program
Hello experts
I have to write a selection screen program based on the following requirements (only for sales Org:5090, plant:9000, Outbound delivery type= "LF")
Selection parameters:
Material (lips-matnr)
Sold to party(likp-kunag): can hardcode it to 5090
Sales Org(likp-vkorg)
Plant(lips-werks) : hard code it to plant:9000
Sales order(likp-vbeln)
Actual goods movement dates(likp-wadat_ist)
Invoice number
Sales order
Output
material numberlips~matnr ( should Display only S* materials and material type FERT)
Serial number of the device shipped (objk-sernr)
Delivery number (lips~vbeln)
Invoice number (vbrp-vbeln)
Invoice price=Vbrp-vbeln/quantity (invoice price)
Notification number (Viqmel-QMNUm)
KBB Repair Level(VIQMEL-QMTXT from QMCOD )
KBC Repair level(VIQMMA-MNCOD from KBC-SM07 code group(VIQMMA-MNGRP))
code help is higly appreciated,
Thanks
SpHi anurag,
Code is going like this, i could able to display it but when i run it ABAP Dump is coming.
what could be the reason?
Tahnks
SP
*& Report ZSDR_PRICING_KSE_RPT *
REPORT ZSDR_PRICING_KSE_RPT .
TABLES: likp, lips, vbfa, vbak.
TYPE-POOLS: slis.
*/ Selection and Input Parameters
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-003.
SELECT-OPTIONS: s_matnr FOR lips-matnr,
s_kunag FOR likp-kunag.
SELECT-OPTIONS: s_vkorg FOR likp-vkorg NO INTERVALS,
s_werks FOR lips-werks.
SELECT-OPTIONS: s_vbeln FOR likp-vbeln,
s_waist FOR likp-wadat_ist.
SELECT-OPTIONS: s_vgbel FOR lips-vgbel.
SELECTION-SCREEN END OF BLOCK block2.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
TYPES: BEGIN OF ty_data,
matnr TYPE lips-matnr,
sernr TYPE equi-sernr,
vbeln TYPE lips-vbeln,
invno TYPE vbfa-vbeln,
qmnum TYPE vbak-qmnum,
netwr type vbrp-netwr,
END OF ty_data.
DATA: gt_data TYPE TABLE OF ty_data WITH HEADER LINE.
TYPES: BEGIN OF ty_lips,
vbeln TYPE likp-vbeln,
matnr TYPE lips-matnr,
wersk TYPE lips-werks,
vgbel TYPE lips-vgbel,
END OF ty_lips.
DATA: gt_lips TYPE TABLE OF ty_lips WITH HEADER LINE.
DATA: gt_vbfa TYPE TABLE OF vbfa WITH HEADER LINE.
DATA: gt_vbrp TYPE TABLE OF vbrp WITH HEADER LINE.
TYPES: BEGIN OF ty_ser01,
lief_nr TYPE ser01-lief_nr,
obknr TYPE ser01-obknr,
sernr TYPE objk-obknr,
END OF ty_ser01.
DATA: gt_ser01 TYPE TABLE OF ty_ser01 WITH HEADER LINE.
START-OF-SELECTION.
PERFORM get_data.
PERFORM display_data.
*& Form get_data
FORM get_data.
SELECT likpvbeln lipsmatnr lipswerks lipsvgbel
INTO CORRESPONDING FIELDS OF TABLE gt_lips
FROM likp INNER JOIN lips ON lipsvbeln = likpvbeln
WHERE lips~matnr IN s_matnr
AND lips~werks IN s_werks
AND likp~kunag IN s_kunag
AND likp~wadat_ist IN s_waist
AND lips~vgbel IN s_vgbel
AND likp~vkorg IN s_vkorg.
IF NOT gt_lips[] IS INITIAL.
SELECT vbeln vbelv INTO CORRESPONDING FIELDS OF TABLE gt_vbfa
FROM vbfa
FOR ALL ENTRIES IN gt_lips
WHERE vbelv = gt_lips-vgbel
AND vbtyp_n = 'M'.
IF NOT gt_vbfa[] IS INITIAL.
SELECT vbeln matnr netwr
INTO CORRESPONDING FIELDS OF TABLE gt_vbrp
FROM vbrp FOR ALL ENTRIES IN gt_vbfa
WHERE vbeln = gt_vbfa-vbeln.
SELECT ser01lief_nr ser01obknr objk~sernr
INTO CORRESPONDING FIELDS OF TABLE gt_ser01
FROM ser01 INNER JOIN objk ON objkobknr = ser01obknr
FOR ALL entries IN gt_vbfa
WHERE ser01~lief_nr = gt_vbfa-vbeln
AND taser EQ 'SER01'.
ENDIF.
ENDIF.
clear: gt_data[].
LOOP AT gt_lips.
LOOP AT gt_vbfa WHERE vbelv = gt_lips-vgbel.
READ TABLE gt_vbrp WITH KEY vbeln = gt_vbfa-vbeln
matnr = gt_lips-matnr.
LOOP AT gt_ser01 WHERE lief_nr = gt_vbfa-vbeln.
gt_data-matnr = gt_lips-matnr.
gt_data-sernr = gt_ser01-sernr.
gt_data-vbeln = gt_lips-vbeln.
gt_data-invno = gt_vbfa-vbeln.
gt_data-netwr = gt_vbrp-netwr.
APPEND gt_data.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDFORM. " get_data
*& Form display_data
FORM display_data.
DATA: lv_repid TYPE sy-repid.
lv_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = lv_repid
I_INTERNAL_TABNAME =
i_structure_name = gt_data
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = lv_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT =
it_fieldcat = gt_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = gt_data
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. -
I was messing around with my iPad and put in a in app purchese and forgot the pass code help!
I was messing around with my iPad and put in a in app purchese and forgot the pass code help!
Do you mean you forgot the passcode for your iPad? If so you need to restore it through the recovery mode described in http://support.apple.com/kb/HT1808
-
Redemption Code Help, where do I locate it?
Redemption Code Help, where do I locate it?
You have activate the subscription only once in the month of August 2014, so you can activate it one more time, if the Cc is asking for serial number then please follow the steps:
Creative cloud do not need a serial number. it will be using your Adobe ID on which you have purchased the creative cloud membership.
So you need to login with your Adobe ID and password to activate the cloud membership.
Log out & log back in of the CC Desktop App.
In case it is not signing in successfully please try the following:
I don't know which operating system you are working on so i am giving you some steps windows and MAC OS:
Windows:
In windows 7 navigate to following location:
/windows/system32/drivers/etc
1. look out for "Hosts" file
2. Open it with notepad
3. Check if you have any entry for Adobe
4. Remove the entries and try again launching any product from CC
On Windows XP navigate to following location:
\windows\system32\drivers\etc
1. look out for "Hosts" file
2. Open it with notepad
3. Check if you have any entry for Adobe
4. Remove the entries and try again launching any product from CC
Mac:
1. Please click on "Go" and navigate to /private/etc
2. Open "hosts" file and check out for any entries for Adobe.com
3. Remove the entries and save the file
4. try again launching any product from CC
You can refer :
http://helpx.adobe.com/creative-cloud/kb/ccm-prompt-serial-number.html
http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-i ssues.html.
Please let us know if it worked.
Regards,
Rajshree -
I cannot get .arw or jpeg files from my Sony A6000 to be taken into my Lightroom 4.4 via the normal "synchronise" process. I have updated my Pc to Adobe RAW/DNG 8.4 with no improvement. Can you help please?
With regards to your .arw files:
You need to either purchase and install Lightroom 5.4 -- OR -- download and install and use the FREE Adobe DNG Converter version 8.4, did you actually launch and use the DNG Converter?
There should be no problem importing JPG files into Lightroom from your camera, what happens when you try? Is there an error message? -
HT201209 When I try to redeem it says error invalid code help me please.
When I try to redeem it says error invalid code help me please.
Contact iTunes Customer Service and request assistance
Use this Link > Apple Support iTunes Store Contact
Note: iTunes Gift Cards are only Valid in Country of issue -
I just had to buy a new computer because my "vintage" Mac died. After migrating my backup drive over to my New mac book my Adobe CS no longer works. I get a 150:30 error code HELP!
You need to reinstall it properly, not use migration.
Mylenium -
Can you please help me improve on this code
Here is code for a drag and drop activituy where there are 4 questions, each question is on a separate frame of a movieclip mentorquestions. I am trying to have the frame picked at random and then have either the yes target or the no target visible for the right answer to correspond with the question. yesplay is a little animation to let you know you got the correct answer. My code is a bit hit and miss I think.. I am doing something (or many things) wrong
any suggestions?
cheers
sub
import flash.events.MouseEvent;
yesplay.addEventListener(Event.ENTER_FRAME, checkit);
function checkit (myevent:Event):void {
if (yesplay.currentFrame == 27)
{reset1();
var incorrect:Number=0;
var correct:Number=0;
targetYes.visible=false;
targetNo.visible=false;
var Qmove:Array = [1,2,3,4];
var b:Number=4;
var a:Number;
var c:Number;
function pickquestion(){
a=Math.floor(Math.random() * b);
mentorquestions.gotoAndStop(Qmove[a]);
c=Qmove[a];
trace(c);
setanswer();
Qmove.splice(a,1);
b=b-1;
trace(a);
trace(Qmove);
trace(b);
pickquestion();
function setanswer(){;
if (c==3){
targetYes.visible=true;
targetNo.visible=false;
}else{
targetYes.visible=false;
targetNo.visible=true;
AbackBT.addEventListener(MouseEvent.CLICK, Abacker);
function Abacker(e:MouseEvent){
visible=false;
var Yx:Number=843;
var Yy:Number=295;
var Nx:Number=843;
var Ny:Number=394;
function reset1(){
yes.x=Yx;
yes.y=Yy;
no.x=Nx;
no.y=Ny;
pickquestion();
var startX:Number;
var startY:Number;
this.yes.addEventListener(MouseEvent.MOUSE_DOWN, pickMe);
this.yes.addEventListener(MouseEvent.MOUSE_UP,dropMe);
function pickMe(event:MouseEvent):void {
event.target.startDrag();
startX = event.target.x;
startY = event.target.y;
function dropMe(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "yes" + event.target.name;
if (event.target.dropTarget != null && event.target.dropTarget.parent == targetYes){
event.target.x = targetYes.x;
event.target.y = targetYes.y;
yesplay.play();
}else{
event.target.x = startX;
event.target.y = startY;
wrongun.play();
this.yes.buttonMode = true;
this.no.addEventListener(MouseEvent.MOUSE_DOWN, pickMe1);
this.no.addEventListener(MouseEvent.MOUSE_UP,dropMe1);
function pickMe1(event:MouseEvent):void {
event.target.startDrag();
startX = event.target.x;
startY = event.target.y;
function dropMe1(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "no" + event.target.name;
if (event.target.dropTarget != null && event.target.dropTarget.parent == targetNo){
event.target.x = targetNo.x;
event.target.y = targetNo.y;
yesplay.play();
}else{
event.target.x = startX;
event.target.y = startY;
wrongun.play();
this.no.buttonMode = true;You'll need to be more specific with presenting your problems insteasd of just putting up a bunch of code and asking others to fix it for you. Try to keep what you present focused on a specific problem.
-
Improvements to status code explanations requested
There are some status code explanations in the 9.0.4.x
CSDK that could probably use some refinement to be more
useful to application developers.
Two examples:
1."CAPI_STAT_LIBRARY_INTERNAL_DATA = There was a corruption of data in the library."
This might not always indicate that data in the
calendar store is corrupted - which is the way we
initially interpreted this error - but rather that
data provided to be stored is in some way invalid.
Example: calling storeEvents() with an
iCalendar whose DTSTART property was after
DTEND (i.e. start date after ending date),
returned the status "CAPI_STAT_LIBRARY_INTERNAL_DATA".
Example: calling Session.storeEvents() with an iCalendar
whose start and end dates are in a non-UTC TZ in a format
similar to "DTSTART;TZID=US/Pacific:20040517T101500",
that method returned "CAPI_STAT_LIBRARY_INTERNAL_DATA".
Fix: include an appropriate VTIMEZONE component
for that timezone in the submitted iCalendar.
2. Any of the explanations below, which begin with
"Information about ..."
These often seem to indicate that a data format error
has occurred, and that the application developer
needs to modify the format of the data to have it
accepted. The "Information about ..." explanation
doesn't adequately convey that.
Examples:
When calling storeEvents() with an iCalendar with a
missing CR/LF between VEVENT components, that method
returned the status "CAPI_STAT_DATA_ICAL".
Some of the relevant status explanations include:
CAPI_STAT_DATA_COOKIE = Information about the supplied cookie.
CAPI_STAT_DATA_DATE = Information about a date.
CAPI_STAT_DATA_EMAIL = Information about email.
CAPI_STAT_DATA_ENCODING = Information about the encoding of supplied data.
CAPI_STAT_DATA_HOSTNAME = Information about a hostname.
CAPI_STAT_DATA_ICAL = Information about iCalendar data.
CAPI_STAT_DATA_MIME = Information about MIME data.
CAPI_STAT_DATA_UID = Information about a UID.
CAPI_STAT_DATA_USERID = Information about a userID.
In contrast, explanations like the following are much
clearer:
CAPI_STAT_DATA_USERID_FORMAT = The format of the UserId string was wrong.
CAPI_STAT_DATA_USERID_ID = There was a problem with the Id part of the UserId string.
Any improvements such as these in the status code
explanations returned would be welcome, and might help
save debugging time for those new to the CSDK.Thanks Aaron,
Some notable improvements are coming in the next version of the Oracle Calendar application developer's guide, and your comments will be added for consideration.
Best regards,
Product Management -
Guys,
Thanks first of all to those of you who have been a great help over the past few days. I have one last problem that i'm not sure how to tackle.
I'm doing a theatre booking system which has a GUI. My main screen is using a card layout.
I have a theatre class, a booking class, performance and seating classes. I want to implement code for making a booking which will display a graphical representation of the seats for a particular section of the theatre. My seating is divided into stalls, royal circle, upper circle etc. Each of these blocks of seating has x rows and y columns.
I want to show on a panel all seats. Booked ones coloured red, free ones coloured green - or some other approach which would be just as effective. I want to click a seat or several seats to book them for one customer.
What approach is best for this problem? How should I draw the seats? Line drawings? Components? Suggestions on how to tackle this problem please.
Many thanks.How bout this:
Create your own subclas of Shape (sub class Rectangle if you just want your seats as rectangles or if they need to be a more complicated shape use Polygon) but add your own field colour (of type Color!, defaulted to green) which has a getter and a setter method for colour (or just setred, setgreen methods) and just one constuctor which takes a location. size and colour are set by default in the constructor. Iterate over your x and y axis creating these and storing them in an array, something line:
int xmax = 5;
int ymax = 3;
int gap = 5;
Seat[] seats = new Seat[xmax * ymax]; //Where seat is you Shape (also array should be class level)
int count = 0;
for (int x = 0; x < xmax; x++){
for (int y = 0; y < ymax; y++){
seats[count] = new Seat( gap * x, gap * y); //Obviously this would be alot more complicated if you use Polygon as all points would need offsetting by x, y.
}then in your draw method:
for (allseats using i) {
Seat seat = seats;
g2.setColor(seat.getColour());
g2.draw(seat)
Add a mouselistener to the component you are drawing on which checks if a seat was clicked on:
mouseClicked(MouseEvent me {
for (allseats using i) {
Seat seat = seats;
if (seat.contains(me.getPoint()) {
seat.setColour(Color.RED);
//And anything else you want to do
repaint();
None of this is very thought through and all just typed straight into reply box so probably loads of little mistakes and improvements but somewhere to start from perhaps.
Hope this helps,
Alex. -
Command in ABAP Editor to improve the source code
Which command in ABAP Editor to be used to improve the readability of the program code ?plzz tell
Edited by: Alvaro Tejada Galindo on Feb 13, 2008 3:48 PMUse Pretty Printer or do a CTRL+F1.
Also u can change the settings of the way u want preety printer to behave by
going in the Settings->Abap Editor -> Pretty Printer -
Problem with JTextArea or is it my code, Help!!!
Hi,
I am going crazy. I am sending a message to a JTextArea and I get some very wierd things happening? I really need help because this is driving me crazy. Please see the following code to see my annotations for the problems. Has anyone else experienced problems with this component?
Thanks,
Steve
// THIS IS THE CLASS THAT HANDLES ALL OF THE WORK
public class UpdateDataFields implements ActionListener { // 400
JTextArea msg;
JPanel frameForCardPane;
CardLayout cardPane;
TestQuestionPanel fromRadio;
public UpdateDataFields( JTextArea msgout ) { // 100
msg = msgout;
} // 100
public void actionPerformed(ActionEvent evt) { // 200
String command = evt.getActionCommand();
String reset = "Test of reset.";
try{
if (command.equals("TestMe")){ // 300
msg.append("\nSuccessful");
Interface.changeCards();
} // 300
catch(Exception e){
e.printStackTrace();
try{
if (command.equals("ButtonA")){ // 300
// WHEN I CALL BOTH OF THE FOLLOWING METHODS THE DISPLAY WORKS
// BUT THE CHANGECARDS METHOD DOES NOT WORK. WHEN I COMMENT OUT
// THE CALL TO THE DISPLAYMESSAGE METHOD THEN THE CHANGECARDS WORKS
// FINE. PLEASE THE INTERFACE CLASS NEXT.
Interface.changeCards();
Interface.displayMessage("test of xyz");
} // 300
catch(Exception e){
e.printStackTrace();
} // 200
} // 400
// END OF UPDATEDATAFIELS END END END
public class Interface extends JFrame { // 300
static JPanel frameForCardPane;
static CardLayout cardPane;
static JTextArea msgout;
TestQuestionPanel radio;
Interface () { // 100
super("This is a JFrame");
setSize(800, 400); // width, height
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// set-up card layout
cardPane = new CardLayout();
frameForCardPane = new JPanel(); // for CardLayout
frameForCardPane.setLayout(cardPane); // set the layout to cardPane = CardLayout
TestQuestionPanel cardOne = new TestQuestionPanel("ABC", "DEF", msgout, radio);
TestQuestionPanel cardTwo = new TestQuestionPanel("GHI", "JKL", msgout, radio);
frameForCardPane.add(cardOne, "first");
frameForCardPane.add(cardTwo, "second");
// end set-up card layout
// set-up main pane
// declare components
msgout = new JTextArea( 8, 40 );
ButtonPanel commandButtons = new ButtonPanel(msgout);
JPanel pane = new JPanel();
pane.setLayout(new GridLayout(2, 4, 5, 15)); pane.setBorder(BorderFactory.createEmptyBorder(30, 20, 10, 30));
pane.add(frameForCardPane);
pane.add( new JScrollPane(msgout));
pane.add(commandButtons);
msgout.append("Successful");
setContentPane(pane);
setVisible(true);
} // 100
// HERE ARE THE METHODS THAT SHOULD HANDLE THE UPDATING
static void changeCards() { // 200
cardPane.next(frameForCardPane);
System.out.println("Calling methods works!");
} // 200
static void displayMessage(String test) { // 200
String reset = "Test of reset.";
String passMessage = test;
cardPane.next(frameForCardPane);
System.out.println("Calling methods works!");
msgout.append("\n"+ test);
} // 200
} // 300Hi,
I instantiate it in this class. Does that change your opinion or the advice you gave me? Please help!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class CardLayoutQuestionsv2 {
public static void main(String[] arguments) {
JFrame frame = new Interface();
frame.show();
}
Maybe you are looking for
-
I am trying to create an apple ID for my son but when I do I get this message. "This email address is already in use or you may already have an Apple ID associated with this email address. Please try again or sign in using your existing Apple ID." th
-
Got Quicktime Pro with my Mac Pro, where do I find my registration code?
When I bought my Mac Pro two years ago it came with QT Pro. I've now reinstalled my computer, how do I get my QT to be Pro again?
-
I'm trying to decide which toolkit to stick to and become proficient in. Though I'm sure it would be good to learn multiple toolkits, I rather to stick to just one. I'm debating between gtk and tk. No qt because I've yet to get a qt application worki
-
i wanted to install java plugin for netscape. i found plugins for Windows ans solaris everuwhere, but could not find one for mac. i was wondering if the pulgin for mac would be same as those for solaris! ooppss!! thasts where im stuck! i will appreti
-
So every night and sometimes during the day I get this nice blue screen about how I have to do an update, and can accept it or defer it.... well when I press okay lets update it will take about 20 minutes in "updating" but when it comes to "installi