Why wont this work as an applet??
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.SQLException;
import java.applet.*;
* This class creates a Swing GUI that allows the user to enter a SQL query.
* It then obtains a ResultSetTableModel for the query and uses it to display
* the results of the query in a scrolling JTable component.
public class QueryFrame extends JApplet {
ResultSetTableModelFactory factory; // A factory to obtain our table data
JTextField query; // A field to enter a query in
JTable table; // The table for displaying data
JLabel msgline; // For displaying messages
public void init(ResultSetTableModelFactory f) {
this.factory = f;
// Create the Swing components we'll be using
query = new JTextField(); // Lets the user enter a query
table = new JTable(); // Displays the table
msgline = new JLabel(); // Displays messages
// Place the components within this window
Container contentPane = getContentPane();
contentPane.add(query, BorderLayout.NORTH);
contentPane.add(new JScrollPane(table), BorderLayout.CENTER);
contentPane.add(msgline, BorderLayout.SOUTH);
// Now hook up the JTextField so that when the user types a query
// and hits ENTER, the query results get displayed in the JTable
query.addActionListener(new ActionListener() {
// This method is invoked when the user hits ENTER in the field
public void actionPerformed(ActionEvent e) {
// Get the user's query and pass to displayQueryResults()
displayQueryResults(query.getText());
* This method uses the supplied SQL query string, and the
* ResultSetTableModelFactory object to create a TableModel that holds
* the results of the database query. It passes that TableModel to the
* JTable component for display.
public void displayQueryResults(final String q) {
// It may take a while to get the results, so give the user some
// immediate feedback that their query was accepted.
msgline.setText("Contacting database...");
// In order to allow the feedback message to be displayed, we don't
// run the query directly, but instead place it on the event queue
// to be run after all pending events and redisplays are done.
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
table.setModel(factory.getResultSetTableModel(q));
msgline.setText(" ");
catch (SQLException ex) {
// If something goes wrong, clear the message line
msgline.setText(" ");
// Then display the error in a dialog box
JOptionPane.showMessageDialog(QueryFrame.this,
new String[] { // Display a 2-line message
ex.getClass().getName() + ": ",
ex.getMessage()
public static void main(String args[]) throws Exception {
// Create the factory object that holds the database connection using
// the data specified on the command line
ResultSetTableModelFactory factory =
new ResultSetTableModelFactory("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:InvoiceExpress_Metso", "sa", "Imagon");
// Create a QueryFrame component that uses the factory object.
QueryFrame qf = new QueryFrame(factory);
// Set the size of the QueryFrame, then pop it up
//qf.setSize(500, 600);
//qf.setVisible(true);
}
It won't, you have the main method, u have an application in the making, to turn it to an applet do the following:
1- remove the Main method
2- add init() method
Thanks
Similar Messages
-
Questions, Extreme begginer - Why wont this work.
/* My Java Program
Failing To Compile 2009 - CurrentDate()
/* Importing */
import java.util.Scanner;
import acm.graphics.*;
import acm.program.*;
class run {
public static void main(String args[]){
//Variables
Scanner ninjatext = new Scanner(System.in);
Scanner Clarinet_Request = new Scanner(System.in);
System.out.println(ninjatext.nextLine());
double pye, var1, ans;
String yodawg;
var1 = 2;
pye = 3.14;
yodawg ="I heard you like saxaphones ";
ans = var1/pye;
System.out.println("Hello Cruel World?");
System.out.print(yodawg);
System.out.print("So i bought you ");
System.out.print(ans);
System.out.println(" Saxxes");
System.out.println("So How many Clarinets Would you like????");
System.out.println("Enter Number::");
System.out.println("So " + Clarinet_Request.nextLine() + " Is how many clarinets You would like? Cool");
/*Please end up working*/
// Declaring Variables Semi-Randomly Works, Right?
String test1 = "Ok i hope this works";
int test2 = 10;
double test3 = 4.9;
int test4 = test2/test3; //Random Weird Awnser right???
System.out.println(test2 + "Divided by" + test3 + "Is Equal To" + test4);
/* This all should work, at least in theory.... But it wont right? */
/** What have i gotten myself into? Oh well it sounds like it should work */
Console console = System.console();
String username = console.readLine("Lets Do This?: ");
if (/* String? */username == "yes" || "Yes" || "YES"){
testingthiscrap LeroyJenkins = new testingthiscrap
LeroyJenkins.LetsDoThis()
/* Guaranteed to not work */
public class testingthiscrap extends GraphicsProgram {
/** Runs the program */
public void LetsDoThis() {
GRect rect = new GRect(100, 50, 100, 100 / PHI);
rect.setFilled(true);
rect.setColor(Color.RED);
add(rect);
GOval oval = new GOval(150, 50 + 50 / PHI, 100, 100 / PHI);
oval.setFilled(true);
oval.setColor(Color.GREEN);
add(oval);
/** Constant representing the golden ratio */
public static final double PHI = 1.618;
/* Standard Java entry point */
/* This method can be eliminated in most Java environments */
public static void main(String[] args) {
new FeltBoard().start(args);
}//If anything i just typed i now feel heroic.
// public static void
Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java.
So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.
Any clues what im doing wrong and what i should do instead?
BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.
also i dont even seem to have these acm packages im trying to import, any clue why?jman888 wrote:
Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java. Ok?
So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.I assume you got a compile time error, if so next time you post a question incorporate this piece of information.
Any clues what im doing wrong and what i should do instead?I can take a stab at your code.
BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.One step at a time
String yodawg;
yodawg ="I heard you like saxaphones ";This is not an error but plain weird IMHO, if you are declaring a variable then initializing it, you might as well do it all on one line.
if (/* String? */username == "yes" || "Yes" || "YES"){
testingthiscrap LeroyJenkins = new testingthiscrap
LeroyJenkins.LetsDoThis()
}This code will not compile and should produce one of possible many compiler errors. The condition inside the if statement requires each condition to be independent of one another. e.g. (username == "yes" || username = "Yes" || username == "YES").
This also represents one of the most common errors presented to new comers. Equivalence of Objects such as Strings are compared using a method .equals() and not the term "==". The latter actually compares two Strings by the address stored in memory.
class runBy convention all Class names begin with a capital letter
Also it appears that the class run contains main method and an inner class in which itself contains a main method. I will conclude right here that you are biting off far more then you can chew. Start with the basics, e.g. Google for Java tutorials and start from "hello world" then make your way from there. Tackle one problem at a time and learn the concepts of the tutorial which will hopefully stay with you, as these fundamental concepts will be your foundation to development using the Java language.
Mel
Edited by: Melanie_Green, apparently CODE tags don't like me tonight -
Why wont this work??
ive downloaded garage band, but when i try to open it it says i have no valid instrument library folder.... am i supposed to make one? why dont i have one?
Which os system do you have? Garage Band is part of the iLife package and came preinstalled on Mac when Tiger first came out. The application GB package is on the system disc that comes with all Macs. Where did you download it from?
-
Microsoft office is installed on two user accounts. My husbands account works fine, but my account keeps getting an error message every time I try to open up a new document. Why wont it work on both accounts? How do I fix this?
Hi Aubs,
Without knowing what the error is, there's not much help we can provide....
Cheers,
GB -
I have an ipod touch and now it doesnt sync properly. It gets to stage 1 of 3 of syncing( Which is 'backing up') Then it stops and itunes closes. Why wont this sync and what can I do about it?
Hello,
I am currently an owner of an Ipod Touch 4th generation. I see you are having problems with your Ipod Touch, so I will try to find a solution to your problem.
Restart the Computer. This sometimes happens to me when I keep my Windows 7 on Sleep, and I try to sync my Ipod
Make sure you have the latest version of Itunes
Hope that helps!
If none of the above solutions work, can you please respond back ASAP as I will try to find another solution to your problem (This might even help others with the same problem!)
Cheers!
Pizza98704 -
i have an iphone 4 and my internet has not worked for a good 10 months, why wont it work? My dad pays for my data plan, so its not that i dont pay the bill. I've even tried to rest my net work settings, and that did not work. I went to AT&T and they said that the only way to fix it was to buy a new phone, and im not going to buy a new phone with out my upgrade. someone, please help!
Hey lilmissindian!
I have an article for you here that will help you troubleshoot this issue:
iPhone: Troubleshooting a cellular data connection
http://support.apple.com/kb/ts3780
Thanks for coming to the Apple Support Communities!
Cheers,
Braden -
when I try to update to iOS5 i get error 3194 and my itunes is 10.5 so why wont it work?
Error 3194: Resolve error 3194 by updating to the latest version of iTunes. "This device is not eligible for the requested build" in the updater logs confirms this is the root of the issue. For more Error 3194 steps see: This device is not eligible for the requested build above.
This device is not eligible for the requested build: Also sometimes displayed as an "error 3194." If you receive this alert, update to the latest version of iTunes. Third-party security software or router security settings can also cause this issue. To resolve this, follow Troubleshooting security software issues.
Downgrading to a previous version of iOS is not supported. If you have installed software to performunauthorized modifications to your iOS device, that software may have redirected connections to the update server (gs.apple.com) within the Hosts file. First you must uninstall the unauthorized modification software from the computer, then edit out the "gs.apple.com" redirect from the hosts file, and then restart the computer for the host file changes to take affect. For steps to edit the Hosts file and allow iTunes to communicate with the update server, see iTunes: Troubleshooting iTunes Store on your computer, iPhone, iPad, or iPod—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > The hosts file may also be blocking the iTunes Store. If you do not uninstall the unauthorized modification software prior to editing the hosts file, that software may automatically modify the hosts file again on restart. Also, using an older or modified .ipsw file can cause this issue. Try moving the current .ipsw file, or try restoring in a new user to ensure that iTunes downloads a new .ipsw.
Above from:
http://support.apple.com/kb/TS3694 -
Why isnt this working urgent please help
why isnt this working im trying to connect a panel to a scrollpane the panel will contain several dozen text fields
the scrollpane shouls be about 350, 450 , but the pane is 350
by 1200 the problem now is that the scorllbar isnt created and even when I explictly create it it contains no knob, and it will
not scroll up or down please someone help this is urgent
import java.awt.*;
import com.sun.java.swing.*;
public class ScrollDemo extends JPanel {
private Rule columnView;
private Rule rowView;
private ScrollablePicture picture;
class UnitsListener implements ItemListener {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
// Turn it to metric.
rowView.setIsMetric(true);
columnView.setIsMetric(true);
} else {
// Turn it to inches.
rowView.setIsMetric(false);
columnView.setIsMetric(false);
picture.setMaxUnitIncrement(rowView.getIncrement());
public ScrollDemo() {
Two t = new Two(columnView.getIncrement());
JScrollPane pictureScrollPane = new JScrollPane(t);
pictureScrollPane.setPreferredSize(new Dimension(300, 250));
pictureScrollPane.setColumnHeaderView(columnView);
pictureScrollPane.setRowHeaderView(rowView);
public static void main(String s[]) {
JFrame frame = new JFrame("ScrollDemo");
frame.setContentPane(new ScrollDemo());
frame.setVisible(true);
import java.awt.*;
import com.sun.java.swing.*;
public class Two extends JPanel implements Scrollable{
private JPanel ivjJPanel3 = null;
private JScrollPane ivjJScrollPane1 = null;
private int maxUnitIncrement = 1;
public Two(int m)
getJPanel1();
maxUnitIncrement = m;
setSize(300,1200);
private void getJPanel1() {
setLayout(null);
setSize(250,1200);
add(getJLabel1(), getJLabel1().getName());
public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation,
int direction) {
if (orientation == SwingConstants.HORIZONTAL)
return visibleRect.width - maxUnitIncrement;
else
return visibleRect.height - maxUnitIncrement;
public boolean getScrollableTracksViewportHeight() {
return false;
public boolean getScrollableTracksViewportWidth() {
return false;
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction) {
//Get the current position.
int currentPosition = 0;
if (orientation == SwingConstants.HORIZONTAL)
currentPosition = visibleRect.x;
else
currentPosition = visibleRect.y;
//Return the number of pixels between currentPosition
//and the nearest tick mark in the indicated direction.
if (direction < 0) {
int newPosition = currentPosition -
(currentPosition / maxUnitIncrement) *
maxUnitIncrement;
return (newPosition == 0) ? maxUnitIncrement : newPosition;
} else {
return ((currentPosition / maxUnitIncrement) + 1) *
maxUnitIncrement - currentPosition;
public void setMaxUnitIncrement(int pixels) {
maxUnitIncrement = pixels;I personally didn't play with swing components when they were in the com.sun.java.swing state, but I have a strong feeling it is very buggy and could be causing your problem.
Before posting gui issues, please use a newer API, even jdk1.1 would be fine, anything would be better than what your using.
you wrote: I dont care if its javax.swing or
com.sun.java.swing
I would also gather from this statement that your attitude could be one of your other issues. -
i am downloading after effects and its will get to a different spot each time and say retry....... why wont it work!!!!????
you're probably losing connectivity.
you can try a different browser and/or a different wired connection and/or a download manager or if you follow all 7 steps you can directly download from prodesigntools.com
if you need a prodesigntools.com link, which version of ae do you need? -
Option Explicit
Sub BatchProcess()
Dim strFileName As String
Dim strPath As String
Dim oDoc As Document
Dim oLog As Document
Dim oRng As Range
Dim oHeader As HeaderFooter
Dim oSection As Section
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , _
"List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" _
Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close savechanges:=wdPromptToSaveChanges
End If
Set oLog = Documents.Add
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.doc?")
While Len(strFileName) <> 0
WordBasic.DisableAutoMacros 1
Set oDoc = Documents.Open(strPath & strFileName)
'Do what you want with oDoc here
For Each oSection In oDoc.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
Set oRng = oHeader.Range
oRng.Collapse wdCollapseStart
InsertMyBuildingBlock "ASAP 1", oRng
End If
Next oHeader
Next oSection
'record the name of the document processed
oLog.Range.InsertAfter oDoc.FullName & vbCr
oDoc.Close savechanges:=wdSaveChanges
WordBasic.DisableAutoMacros 0
strFileName = Dir$()
Wend
End Sub
Function InsertMyBuildingBlock(BuildingBlockName As String, HeaderRange As Range)
Dim oTemplate As Template
Dim oAddin As AddIn
Dim bFound As Boolean
Dim i As Long
bFound = False
Templates.LoadBuildingBlocks
For Each oTemplate In Templates
If InStr(1, oTemplate.Name, "Building Blocks") > 0 Then Exit For
Next
For i = 1 To Templates(oTemplate.FullName).BuildingBlockEntries.Count
If Templates(oTemplate.FullName).BuildingBlockEntries(i).Name = BuildingBlockName Then
Templates(oTemplate.FullName).BuildingBlockEntries(BuildingBlockName).Insert _
Where:=HeaderRange, RichText:=True
'set the found flag to true
bFound = True
'Clean up and stop looking
Set oTemplate = Nothing
Exit Function
End If
Next i
If bFound = False Then 'so tell the user.
MsgBox "Entry not found", vbInformation, "Building Block " _
& Chr(145) & BuildingBlockName & Chr(146)
End If
End Function
This works, using the ASAP 1 watermark that is in bold. ASAP 1 is a built-in building block, if i just rename this to ASAP, but save it in the same place with buildingblocks.dotx it wont work. What do i need to do to be able to use this with my custom building
blocks?Hi,
This is the forum to discuss questions and feedback for Microsoft Excel, this issue is related to Office DEV, please post the question to the MSDN forum for Excel
http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
Why wont itunes open on my iphone 4S after updating to ios7. Anyone else got this problem. suggestions to fix would be appreciated
Now fixed by going to settings-Safari and unblocking cookies to never.
-
I've been practicing some IPSec VPN scenarios, starting with the typical site-to-site VPN:
Router A
crypto map mymap 10 ipsec-isakmp
set peer 1.1.1.2
set transform-set myset
match address 101
access-list 101 permit ip 10.1.1.0 0.0.0.255 10.1.2.0 0.0.0.255
Router B
crypto map mymap 10 ipsec-isakmp
set peer 1.1.1.1
set transform-set myset
match address 101
access-list 101 permit ip 10.1.2.0 0.0.0.255 10.1.1.0 0.0.0.255
This works as expected. Traffic from 10.1.1.x on Router A gets picked up by the crypto map and sent to RouterB and vice versa. What is confusing me is a more advanced scenario where I'm tunnelling GRE over IPSec with OSPF (why? Because I can).
http://www.cisco.com/en/US/tech/tk583/tk372/technologies_configuration_example09186a008009438e.shtml
Everything works just fine, but I'm bothered by the ACLs being used in the example. I don't see how everthing should be working- OSPF is fat and happy, and if I ping one spoke from another spoke from a loopback interface, it works as well. In this case, is the network traffic being picked up by the Tunnel interface first, and all the crypto map sees is GRE traffic by the time the packets make it that far?Ian
You ask a question about the access lists and I believe that it will be easier to answer the question if we have the access lists to refer to. So here they are:
7206:access-list 130 permit gre host 14.36.88.6 host 14.38.88.40access-list 140 permit gre host 14.36.88.6 host 14.38.88.20access-list 150 permit gre host 14.36.88.6 host 14.38.88.102610:access-list 120 permit gre host 14.38.88.10 host 14.36.88.63620:access-list 110 permit gre host 14.38.88.20 host 14.36.88.6
3640:
access-list 100 permit gre host 14.38.88.40 host 14.36.88.6
one of the first things to understand here (and you briefly mention it in your post) is that they are running OSPF dynamic routing protocol over the tunnels. So each router sees the path to get to the other router as being through the tunnel. So when the 2610 wants to get to the 7206 it will send that traffic to the tunnel interface. The tunnel interface will encapsulate the original packet in a GRE header. So yes the only thing that the access list will see is GRE traffic.
Anything that goes through the tunnel (whether it be a data packet or an OSPF routing update) is encapsulated in a GRE header and the access list does not see the original data but sees only GRE.
HTH
Rick -
Why Wont GPS Work with the Nokie 5530 + Nokia LD-4...
Ok, ive played around with all the settings, etc. The only lights being displayed on the ld-4w gps module are the green light and the blue light. the gps light is not turning on. it is all paired with the nokie 5530 phone.
Ovi maps is installed, all the firmwire is updated.
When i start the application 'Location' (the one thats included with the phone), it says searching for GPS devices. Then it says 'Waiting for gps', then (nearly instantly) it shows 'GPS Not Availible' and exits. After that it displays 'No Connection'.
I have tried by going into my back garden and doing this but it still does not work.
However, when I use ovi maps and type in a route, it displays 'Waiting for GPS' for a long time, then it does not connect either, but then it also asks for an internet connection, which i dont have as i dont have any credit on my phone, and i also dont have wireless internet.
If this is the problem, then why doesent the gps light on my ld-4w even blink?
Please help, i need this GPS module up and running before my sisters birthday party lol (17th april)....so please help..its urgent!
Solved!
Go to Solution.Woohoo!! I finally got this working...what I did was I held the power button down for about 10 seconds until the lights alternated between green and red, and then i turned it back on again. Then while holding the power button down, i plugged it in the charger.
Then i turned it back on again, and paired it with the 5530xm again, and it showed waiting for gps for about 5 mins, then it displayed some co-ordinates! Then i started ovi maps then it showed my location!
Yeeeaaaahh!! it finally works!! Looks like it wasent nokias fault after all!! -
Why wont this jar execute (one way fine, the other is not)
Without using a executable jar this works fine:
java.exe -classpath myproject\classes;lib1.jar;lib2.jar;lib3.jar MyMainClass
MyMainClass is my target class stored in myproject\classes
I make an executable jar called Project.jar (basically all content in myproject\classes with usual manifest file containing target class) and then try
java.exe -classpath lib1.jar;lib2.jar;lib3.jar -jar Project.jar
This does not work and gives error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/beans/factory/InitializingBean
The class org/springframework/beans/factory/InitializingBean is contained in lib1.jar
I must be missing something fundamental about creating executable jars?? Any ideas or pointers?I've simplified my problem so someone could help me please!!!!
The following runs fine:
java -cp .;Model.jar TestThe following fails:
java -cp .;Model.jar -jar Test.jarException in thread "main" java.lang.NoClassDefFoundError: Model at Test.main(Test.java:8)
Model.jar contains one class model.Model.class
Test.jar contains one class Test.class plus manifest file. The Test class simple does the following:
import model.Model;
public class Test
public static void main(String[] args)
System.out.println("Start");
Model model = new Model();
System.out.println("End");
}Any ideas why? -
Why aint this working???
have pasted object thru a constructor like this:
Write screen = new Write(ring);
//and rezive it here in the constructor
public Write(Object ring)
buffer = ring;
// and use it like this:
System.out.println(buffer.remove()); // This line gets an errorSo why is this error comming?
cannot resolve symbol method remove()public class RingBuffer
public static void main(String[] args)
Ringen ring = new Ringen();
Write screen = new Write(ring); // Henter tekst fra ringbuffer og skriver den ut p? skjermen.
Generate genr = new Generate(); // Lager tekst "automatisk" og legger den inn i ringbufferen.
Input_txt intxt= new Input_txt(ring); // Lar brukeren taste inn noen ord som lagres i ringbufferen.
screen.start(); //
genr.start(); // Starter tr?dene.
intxt.start(); //
public class Write extends Thread
private Object buffer;
public Write(Object ring)
buffer = ring;
synchronized public void run()
//Ringen buffer = new Ringen();
while(true){
try{
System.out.println(buffer.remove()); // Pr?ver ? skrive ut hvert sekund
Thread.sleep(1000);
}//end try
catch(InterruptedException e){
System.out.println(e);
}//end while
import java.io.*;
public class Input_txt extends Thread
Object buffer;
public Input_txt(Object ring)
buffer = ring;
synchronized public void run()
try{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Skriv inn noe tull");
String inTxT = in.readLine();
buffer.insert(inTxT);
catch(Exception e) { System.out.println(e);}
public class Ringen implements Buffer
private static final int BUFFER_SIZE = 10;
int in, out; // peker p? f?rste ledige og siste okuperte.
int count; // Teller hvor mange objekter som er i bufferen.
private Object[] buffer;
public Ringen()
count = 0;
in = 0;
out = 0;
buffer = new Object[BUFFER_SIZE];
public void insert(Object item)
while (count == BUFFER_SIZE)
;// do nothing..
// Legger til et object i bufferen
++count;
buffer[in] = item;
in = (in + 1)% BUFFER_SIZE;
public Object remove()
Object item;
while (count == 0){
try{
System.out.println(buffer[0]);
Thread.sleep(4000);
}//end try
catch(InterruptedException e){
System.out.println(e);
}//end while
--count;
item = buffer[out];
out = (out + 1) % BUFFER_SIZE;
return item;
public interface Buffer
// producers call this method
public abstract void insert(Object item);
// consumers call this method
public abstract Object remove();
}
Maybe you are looking for
-
I created a slideshow in aperture. How I can share it?
Is there a way I can share a slideshow from Aperture? I know there are are sharing options like email (file too big), text message (file too big), photostream (can share only as still photos), facebook (not interested), Flikr (not interested).
-
How to disable "Open in Immersive Browser" in IE 11
Hello,<o:p></o:p> I am trying to stop our users from using the Immersive Browser in Windows 8.1 and IE11, as our filtering is done by a local application using a plugin. This BHO does not work in immersive view, and therefore bypasses all of our blac
-
The bookmarks that were added from my IE7 favorites aren't up-to-date. How do I update my bookmarks in Safari? Also, if I want to delete the IE7 folder that is not current in Safari and start over, how do I find the right folder to import all of my I
-
I have imported a video from a Nikon camera into iphoto and it plays fine. I made a duplicate of the video and edited / trimmed it in iphoto as per Apple doc. I can view the edited video in iphoto but when I email it to someone else they cannot vie
-
I'm trying to use XMLBeans to load my xml file and access different elements of it. Here is my schema: <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://testing.jsm.jtsd.com/testData" xmlns:xs="http://www.w3.org/2001/XMLSchema