Button to frame | button going back to the main frame (please help)
these are the codes, by clicking the "FCFS" button it will generate another frame and from that frame another button will be pressed "accept" and it will go to another frame....
my problem is that i nid to put codes on the "back" button to go back to the main frame were it started... please help me... thnks
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Oscon extends JFrame
private JButton fcfsB, priorityB, sjfB, rrB, exitB, creditsB;
private fcfsButtonHandler fbHandler;
private priorityButtonHandler pbHandler;
private sjfButtonHandler sbHandler;
private rrButtonHandler rbHandler;
private exitButtonHandler ebHandler;
private creditsButtonHandler cbHandler;
public Oscon()// main frame
fcfsB = new JButton ("FCFS");
fbHandler = new fcfsButtonHandler();
fcfsB.addActionListener(fbHandler);
priorityB = new JButton ("PRIORITY");
pbHandler = new priorityButtonHandler();
priorityB.addActionListener(pbHandler);
sjfB = new JButton ("SJF");
sbHandler = new sjfButtonHandler();
sjfB.addActionListener(sbHandler);
rrB = new JButton ("RR");
rbHandler = new rrButtonHandler();
rrB.addActionListener(rbHandler);
exitB = new JButton ("EXIT");
ebHandler = new exitButtonHandler();
exitB.addActionListener(ebHandler);
creditsB = new JButton ("CREDITS");
cbHandler = new creditsButtonHandler();
creditsB.addActionListener(cbHandler);
setTitle("CPU SCHEDULING");
Container pane =getContentPane ();
pane.setLayout(new GridLayout(2,3));
pane.add(fcfsB);
pane.add(priorityB);
pane.add(sjfB);
pane.add(rrB);
pane.add(exitB);
pane.add(creditsB);
setSize(500,100);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public class fcfsButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
JFrame frame = new JFrame("FCFCS setting");
final JLabel FCFSProcessL, FCFSp1L,FCFSp2L,FCFSp3L,FCFSp4L, FCFSbt;
final JTextField FCFSp1TF,FCFSp2TF,FCFSp3TF,FCFSp4TF;
FCFSProcessL = new JLabel("PROCESS", SwingConstants.CENTER);
FCFSp1L = new JLabel("P1:", SwingConstants.CENTER);
FCFSp2L = new JLabel("P2:", SwingConstants.CENTER);
FCFSp3L = new JLabel("P3:", SwingConstants.CENTER);
FCFSp4L = new JLabel("P4:", SwingConstants.CENTER);
FCFSbt = new JLabel("BT:", SwingConstants.CENTER);
FCFSp1TF= new JTextField (10);
FCFSp2TF= new JTextField (10);
FCFSp3TF= new JTextField (10);
FCFSp4TF= new JTextField (10);
JButton FCFSokB = new JButton ("Accept");
FCFSokB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
JFrame frame2 = new JFrame("FCFCS");
frame2.setSize(500,500);
frame2.setVisible(true);
frame2.setDefaultCloseOperation(EXIT_ON_CLOSE);
JButton FCFSclearB = new JButton ("clear");
FCFSclearB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
FCFSp1TF.setText("");
FCFSp2TF.setText("");
FCFSp3TF.setText("");
FCFSp4TF.setText("");
JButton FCFSBackB = new JButton ("Back");
FCFSBackB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
setTitle("CPU SCHEDULING");
frame.setLayout(new GridLayout(7,2));
frame.add(FCFSProcessL);
frame.add(FCFSbt);
frame.add(FCFSp1L);
frame.add(FCFSp1TF);
frame.add(FCFSp2L);
frame.add(FCFSp2TF);
frame.add(FCFSp3L);
frame.add(FCFSp3TF);
frame.add(FCFSp4L);
frame.add(FCFSp4TF);
frame.add(FCFSokB);
frame.add(FCFSclearB);
frame.add(FCFSBackB);
frame.setSize(200,250);
frame.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
public class priorityButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
public class sjfButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit (0);
public class rrButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit (0);
public class exitButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit (0);
public class creditsButtonHandler implements ActionListener
public void actionPerformed(ActionEvent e)
System.exit (0);
public static void main (String [] args)
Oscon O = new Oscon();
}
please help me revise my program, im almost done, i just nid to set the progress bar that it will run according to the waiting time, or set the progress bar to run in order.. these are the variable names of the progress bar(current1, then current2, then current3 then current4).
i looked it up on the site and i cant really understand it... i just did the part where i included the progress bar to the interface. ijust want the 4 progress bars to run after clicking the accept button.... Please help me!!! its for my project and i didnt slept last night just working on this... i just nid help sir... thnks...
these are the codes i made:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JProgressBar;
public class CPUSched
public CPUSched()
JFrame frame = new JFrame();
JProgressBar current1, current2, current3, current4;
Thread runner;
int num = 0;
final JLabel ProcessL, p1L,p2L,p3L,p4L, bt, prioL, tqL, wtL, awtL, awtLA;
final JTextField p1TF,p2TF,p3TF,p4TF, prio1TF, prio2TF,prio3TF,prio4TF, tqTF ;
final JLabel blank1, blank2, blank3, blank4, blank5, blank6, blank7, blank8, blank9, blank10, blank11,
blank12, blank13, blank14, blank15;
final JLabel blank16, blank17, blank18, blank19, blank20, blank21, blank22, blank23, blank24, blank25,
blank26, blank27, blank28, blank29, blank30;
current1 = new JProgressBar(0, 2000);
current1.setValue(0);
current1.setStringPainted(true);
current2 = new JProgressBar(0, 2000);
current2.setValue(0);
current2.setStringPainted(true);
current3= new JProgressBar(0, 2000);
current3.setValue(0);
current3.setStringPainted(true);
current4 = new JProgressBar(0, 2000);
current4.setValue(0);
current4.setStringPainted(true);
ProcessL = new JLabel("PROCESS", SwingConstants.CENTER);
p1L = new JLabel("P1:", SwingConstants.CENTER);
p2L = new JLabel("P2:", SwingConstants.CENTER);
p3L = new JLabel("P3:", SwingConstants.CENTER);
p4L = new JLabel("P4:", SwingConstants.CENTER);
bt = new JLabel("Burst Time:", SwingConstants.CENTER);
prioL= new JLabel("Priority (1-4):", SwingConstants.CENTER);
tqL= new JLabel("Time Quantum:", SwingConstants.CENTER);
wtL= new JLabel("Waiting time:", SwingConstants.CENTER);
awtL= new JLabel("Average Waiting time:");
awtLA= new JLabel("");
blank1= new JLabel("");
blank2= new JLabel("");
blank3= new JLabel("" ,SwingConstants.CENTER);
blank4= new JLabel("");
blank5= new JLabel("", SwingConstants.CENTER);
blank6= new JLabel("");
blank7= new JLabel("");
blank8= new JLabel("" ,SwingConstants.CENTER);
blank9= new JLabel("");
blank10= new JLabel("");
blank11= new JLabel("", SwingConstants.CENTER);
blank12= new JLabel("");
blank13= new JLabel("");
blank14= new JLabel("");
blank15= new JLabel("");
blank16= new JLabel("");
blank17= new JLabel("");
blank18= new JLabel("");
blank19= new JLabel("");
blank20= new JLabel("");
blank21= new JLabel("");
blank22= new JLabel("");
blank23= new JLabel("");
blank24= new JLabel("");
blank25= new JLabel("");
blank26= new JLabel("");
blank27= new JLabel("");
blank28= new JLabel("");
blank29= new JLabel("");
blank30= new JLabel("");
p1TF= new JTextField (2);
p2TF= new JTextField (2);
p3TF= new JTextField (2);
p4TF= new JTextField (2);
prio1TF= new JTextField (2);
prio2TF= new JTextField (2);
prio3TF= new JTextField (2);
prio4TF= new JTextField (2);
tqTF= new JTextField (2);
prio1TF.setEditable(false);
prio2TF.setEditable(false);
prio3TF.setEditable(false);
prio4TF.setEditable(false);
tqTF.setEditable(false);
JButton okB = new JButton ("Accept");
okB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
double iw=0, wtp1, wtp2, wtp3, wtp4;
double bt1, bt2, bt3, bt4;
double averageWT, sumWT;
bt1=Double.parseDouble(p1TF.getText());
bt2=Double.parseDouble(p2TF.getText());
bt3=Double.parseDouble(p3TF.getText());
bt4=Double.parseDouble(p4TF.getText());
wtp1 = iw;
wtp2 = wtp1+bt1;
wtp3 = wtp2+bt2;
wtp4 = wtp3+bt3;
sumWT = wtp1+wtp2+wtp3+wtp4;
averageWT = sumWT/4;
awtLA.setText(""+averageWT);
blank3.setText(""+wtp1);
blank5.setText(""+wtp2);
blank8.setText(""+wtp3);
blank11.setText(""+wtp4);
JButton clearB = new JButton ("Clear");
clearB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
p1TF.setText("");
p2TF.setText("");
p3TF.setText("");
p4TF.setText("");
awtLA.setText("");
blank3.setText("");
blank5.setText("");
blank8.setText("");
blank11.setText("");
frame.setTitle("First Come First Serve");
frame.setLayout(new GridLayout(6,6));
frame.add(ProcessL);
frame.add(blank1);
frame.add(wtL);
frame.add(bt);
frame.add(prioL);
frame.add(tqL);
frame.add(p1L);
frame.add(current1);
frame.add(blank3);
frame.add(p1TF);
frame.add(prio1TF);
frame.add(tqTF);
frame.add(p2L);
frame.add(current2);
frame.add(blank5);
frame.add(p2TF);
frame.add(prio2TF);
frame.add(blank6);
frame.add(p3L);
frame.add(current3);
frame.add(blank8);
frame.add(p3TF);
frame.add(prio3TF);
frame.add(blank9);
frame.add(p4L);
frame.add(current4);
frame.add(blank11);
frame.add(p4TF);
frame.add(prio4TF);
frame.add(blank12);
frame.add(blank13);
frame.add(blank14);
frame.add(okB);
frame.add(clearB);
frame.add(awtL);
frame.add(awtLA);
frame.setSize(800,200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public static void main (String [] args)
CPUSched O = new CPUSched();
}
Similar Messages
-
Going Back to the main frame, from inside a movie clip time line.
In flash CS5 I want to go back to the main time line, from inside a movie clip button, so when i click the the movie clip it goes to another frame on the main time line..
Can anyone help me?
Thanks
Daniel Derrickyour can use _root to reference the main timeline from anywhere though that can lead to problems if your swf is loaded by another swf. because of that eventuality, it would be better to use a relative path back to the main timeline.
so, from a movieclip's timeline (when the movieclip is on the main timeline), you can use _parent to reference the main timeline.
but even better would be to use no code on that movieclip's timeline and keep all your code on one timeline (the main one). -
Right now my ipod classic is set on 'music'. When I push the munu button, it will not go back to the main menus, but it will still go forward and select and play music normally. I tried resetting it by holding the menu and center buttons until the apple logo appeared, but the problem is still there.
If your battery level is low, recharge it first for at least 2 hours, preferably 4 hours.
After the Apple Logo, you release the buttons, what do you see on the iPod screen? (language selection?)
Have a nice day! -
I can't figure out how to get the music on my iPhone5s to shuffle. If I use the arrows to skip a song, it shuffles through a handful of the same songs then goes back to the song menu. Help please!
Un-sync all your music to remove it from the device, then restart (hold down the home button along with the sleep/wake button until you see the apple, then let go). Now re-sync your music.
-
My iPad is going back to the main screen with many of my applications. I have several desk tops, laptop and a Nook Color and none of them have any problems, so it is not my internet. Any idea how to fix the iPad or should I just toss it?
How to Fix a Slow iPad
http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-A-Slow-iPad.htm
iPad running slow? How to speed up a slow iPad
http://appletoolbox.com/2012/07/ipad-running-slow-how-to-speed-up-a-slow-ipad/
If You Think iOS 7 Feels Slow Here’s How to Speed It Up
http://osxdaily.com/2013/09/23/ios-7-slow-speed-it-up/
You may have many apps open which can possibly cause the slowdown and possibly the loss of wifi. In iOS 4-6 double tap your Home button & at the bottom of the screen you will see the icons of all open apps. Close those you are not using by pressing on an icon until all icons wiggle - then tap the minus sign. For iOS 7 users, there’s an easy way to see which apps are open in order to close them. By double-tapping the home button on your iPhone or iPad, the new multitasking feature in iOS 7 shows full page previews of all your open apps. Simply scroll horizontally to see all your apps, and close the apps with a simple flick towards the top of the screen.
Cheers, Tom -
Has anybody got some advice? I can't open any apps on my iPad. Everything goes back to the main menu immediately.
Perform a Reset... Try again...
Reset ( No Data will be Lost )
Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
Wait for the Apple logo to Appear...
Usually takes about 15 - 20 Seconds... ( But can take Longer...)
Release the Buttons...
Note:
Also consider Deleting any Apps you have Purchased / Downloaded but you now never use... -
My IPAD keeps going back to the main menu screen everytime I try to access my email or FB or intertnet
Try this:
1. Double-click the Home button and hold apps in the Task Bar down until they all wiggle then tap the minus sign to close apps. Tap the home button to return to Home screen.
2. Hold the Sleep/Wake and Home button down until you see the Apple Logo. -
Preventing the User from going back to the main page after logging out.
Hi all,
In my project I want to prevent the User from going back to the Main page, by clicking the back button of the browser, after the user has loggged out.I had invalidated the session so the user will not be able to do any operations, but he can vew the infos. I want to redirect to the login page if the user tries to go back using the back button after he has logged out.
I tried the same in this forum after loging out. Surprisingly it is the same. I can browse through all the operations i did even after logging out from here.
Is it not possible to do that in Servlets?Could somebody help?
Thanks,
Zach.Hi,
You can use a servlet filter to do this , as it can interceptany request to your application you can decide to allow user access or not to any page/servlet.
public class Test implements Filter{
public void destroy() {
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException,
ServletException {
System.out.println("filter");
HttpServletRequest request = (HttpServletRequest) arg0;
if(!request.getRequestURI().contains("index")){ // set condition that will be checked to verify if the user is logged in
System.out.println("redirecting ... ");
RequestDispatcher d = arg0.getRequestDispatcher("/index.jsp");
d.forward(arg0, arg1);
arg2.doFilter(arg0, arg1);
public void init(FilterConfig arg0) throws ServletException {
}in you web.xml add :
<filter>
<filter-name>test</filter-name>
<filter-class>test.Test</filter-class>
</filter>
<filter-mapping>
<filter-name>test</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> -
Every app I try to open goes back to the home page. Help!
Every app I try to open goes back to the home page. Help!
Hello Cacisme,
Have you tried a hard reset of the iPod? T o do this, press and hold both the Sleep/Wake and Home buttons together long enough for the Apple logo to appear.
If the problem still persists, try restoring your iPod from backup via iTunes. See this article for more assistance.
http://support.apple.com/kb/ht1414
B-rock -
When I try to play a song on my iPod Touch, it shows the information screen for the song and then skips to a new song but then goes back to the main playlist page without ever playing a song! Help!
thats tough man, yeah exchanging it is the best option. But why do people always leave a message saying" i'll probably just by an ipod" and it's usually followed by, "even though i don't like apple or ipod" . I mean fine, if u feel like giving up on the zen micro thats fine, i personally don't care if you're going to buy an ipod. for god sakes ipod isn't even the next alternati've mp3 players, theres plenty. Are u just trying to get the creative people saying "oh man we lost another one to ipod" cuz i'm sure they don't lose sleep over u wanting to buy an ipod instead of a zen. *done ranting*
Message Edited by bleakreserve on 02-3-2005 06:34 AM -
Hi, I've been playing Smurf's village for a year now and just last week, i tried to get into the app but it keeps rejecting and goes back to the main page. Is there any reason for this? I've been updating the app everytime and now it's not letting me in. Pls advise. Tq
Reset the device, restart the device, try downloading any other app.
All of these are basic steps that could have been found by a simple search of the forums as a resolution for the issue. -
I hve an ipad1 and i rented a movie and each time i try to play the movie it goes back to the main menu and it did download properly how can i watch it its from itunes? I
Did you make sure that your security software is not blocking the contact to Apple servers? iTunes for Windows: Troubleshooting security software issues
-
I have an iphone 5 which was bought in the UAE, I cannot find the FACETIME button/option, and cannot find also on the contacts details, please help! thanks!
The UAE and several other mostly Middle Eastern Countries ban FaceTime. Because of this all devices manufactured for sale in those countries does not have FaceTime and FaceTime cannot be installed on those devices.
-
I have different desktops open on my mac, but when I try to go to a different desktop, my mac automatically goes back to the main desktop
Unfortunately, when I open applications, adobe photoshop elements 13 folder does not appear in the adobe folder. It appears as a disk on the desktop, only.
-
Re: after updating the app Flight Tycoon, I cannot access the game. Each time I click on the app it goes back to the main page.
Send a bug report. And wait for an update.
OR
uninstall and re-instal the game all over.
Maybe you are looking for
-
Crystal report 10 export to MAPI does not work in Windows 7
hi: I am using CR10 10.0.5.1025 in Windows 7. I tried to export a report to MAPI and got error: Error 2147500037 returned by function <MAPIResolveName> This error occurs both Office 2007 and 2003 Any one see this error before?
-
BYOD Onboarding issue with Redirects on ISE 1.2
Hi there, I'm having intermittent issues with onboarding endpoints (both wired and wireless) with ISE 1.2 (Patch 12). I get three differing scenarios upon attempting: 1). I get redirected to the ISE Self Registration Portal, register, download the su
-
How to connect database using type4 driver(dsn or dsnless connection)
please send any one reply answer
-
ASDM multiple network objects vs group for rules
I was just curious if there are any performance benefits of using multiple network objects on multiple rules vs consolidating them into fewer rules by grouping them? For example, I have about 10 lines of NAT exempt rules from the same source to mult
-
Help! My Debit card will not be accepted! :(
Hey, I recently got A Ipad Mini for Christmas And My Apple account has been Set up and I have bought some apps recently but now I have tried to get a free app and it says Sign-In Required I Sign in correctly and at the top of the page it says There i