When I run the following code it triggers an error message. The error message is shown below the code.
What code changes, or changes to the image file, are needed to fix this error?
Help will be appreciated.
import java.awt.*;
import java.awt.datatransfer.*;
public class LoadToClipboard {
public static void main( String [] args ) {
Toolkit tolkit = Toolkit.getDefaultToolkit();
Clipboard clip = tolkit.getSystemClipboard();
clip.setContents( new ImageSelection( tolkit.getImage("StackOverflowLogo.png")) , null );
}
}
class ImageSelection implements Transferable {
private Image image;
public ImageSelection(Image image) {
this.image = image;
}
// Returns supported flavors
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{DataFlavor.imageFlavor};
}
// Returns true if flavor is supported
public boolean isDataFlavorSupported(DataFlavor flavor) {
return DataFlavor.imageFlavor.equals(flavor);
}
// Returns image
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
if (!DataFlavor.imageFlavor.equals(flavor)) {
throw new UnsupportedFlavorException(flavor);
}
return image;
}
}
Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0 at
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999) at
sun.awt.datatransfer.DataTransferer.imageToStandardBytes(DataTransferer.java:1994) at
sun.awt.windows.WDataTransferer.imageToPlatformBytes(WDataTransferer.java:267) at
sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1123) at
sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:163) at
sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:73) at
sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:93) at
automateSignature.LoadToClipboard.main(LoadToClipboard.java:8)
I have tried to find a place in the code where width and height can be specified, but have not succeeded. I also examined the properties of the jpg file and the w and h are specified.enter code here
Hi,
This is my array
Array
(
[0] => Array
(
[sample_id] => 3
[time] => 2010-05-30 21:11:47
)
[1] => Array
(
[sample_id] => 2
[time] => 2010-05-30 21:11:47
)
[2] => Array
(
[sample_id] => 1
[time] => 2010-05-30 21:11:47
)
)
And I want to get all the sample_ids in one array. can someone please help ?
Can this be done without for loops (because arrays are very large).
I have different php output in jQuery-based tabs. This output is formed from database and it consists of several <div>'s. Every time I click any tab it sends AJAX request to the php script which performs "SELECT" request and gives result back as response to AJAX request from the tab.
$(document).ready(function() {
$('ul.tabs li').css('cursor', 'pointer');
$('ul.tabs.tabs1 li').click(function(){
var thisClass = this.className.slice(0,2);
$('div.t1').hide();
$('div.t2').hide();
$('div.t3').hide();
$('div.t4').hide();
$('div.' + thisClass).show('fast');
$('ul.tabs.tabs1 li').removeClass('tab-current');
$(this).addClass('tab-current');
var data = thisClass;
$.ajax({
type:"GET",
url:"handler.php?name="+data,
data:data,
success:function(html) {
$('div.' + thisClass).html(html);
}
});
return false;
});
});
//Server-side PHP script:
<?php
$name = $_GET[name];
switch ($name) {
case "t1":
query_and_output_1();
case "t2":
query_and_output_2();
// etc...
}
?>
The problem is that the first tab contains output that must be in second and third ones as well, the second also contains the third tab output.
Sorry for such a rubbishy question, I used to work with server side and unfortunately I'm not familiar with DOM and jQuery yet.
Thanks.
I'm an experienced programmer, but relatively new to SQL. We're using Oracle 10 and 11. I have a system in place using SQL that combines actual rows with virtual rows (e.g. "SELECT 1 from DUAL") doing unions and intersects as needed, which all seems to work.
My problem is that I need to combine this system which is expecting rows of data, with new data that will have the data in (let's say for simplification) comma delimited strings.
So I think what I need is a way to convert a string like: "5,6,7,8" into 4 rows with one column each, with "5" in the first row, "6" in the second, etc. In other languages, I'd do a "Split" with comma as the delimiter. Of course, the data won't always have 4 entries.
There's a second question, but I'll ask it separately. But I suspect it will simplify things, if possible, if the solution to the above could be used as a table in another SQL statement (i.e., to work with my existing system). Thanks for any help.
I have a directory /tmp/dir with two types of file names
/tmp/dir/abc-something-server.log
/tmp/dir/xyz-something-server.log
..
..
and
/tmp/dir/something-client.log
I need append a few lines (these lines are constant) to files end with "client.log"
line 1
line 2
line 3
line 4
append these four lines to files end with "client.log"
and For files end with "server.log"
I needed to append after a keyword say "After-this".
"server.log " file has multiple entries of "After-this" I need to find the first entry of "After-this" and append above said four lines keep the remaining file as it is.
Any help will be great appreciated :) Thanks in advance.
i have a char* array of data that was in RGBA and then moved to ARGB
Bottom line is the set application image looks totally messed up and i cant put my finger on why?
//create a bitmap representation of the image data.
//The data is expected to be unsigned char**
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes : (unsigned char**) &dest
pixelsWide:width pixelsHigh:height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow: 0
bitsPerPixel:0 ];
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
[image addRepresentation:bitmap];
if( image == NULL) {
printf("image is null\n");
fflush(stdout);
}
[NSApp setApplicationIconImage :image];
What in these values is off? the image looks very multicolored and pixelated, with transparent parts/lines as well.
Hi,
Through the housekeeping stuff my android application has to do is to read and write some files and sometimes to delete others and create new ones. The files in cause have all "sdcard/" as root. Is it safe if I perform all this task using Java style functions ?
To me it is very handy to do it this way but I've read that not always the java functions can be applied when it comes to files in Android.
If I create a button with an image inside, it gets blown up to much larger size than the image.
If i try to constrain the size of image, and container button, the image gets cut off:
<Button Background="Transparent" Width="18" Height="18" Margin="0,0,0,0" Padding="0,0,0,0" BorderBrush="{x:Null}">
<Image Width="16" Height="16" />
</Button>
Native image size is 16x16. Here the button is 18x18 with 0 padding, yet the image still gets cut-off on right/bottom.
how can i make the entire button be exactly the size of the image w/out any cut off?
Hi
I have a list of dates for an event in the following format
13/04/2010 10:30:00
13/04/2010 13:30:00
14/04/2010 10:30:00
14/04/2010 13:30:00
15/04/2010 10:30:00
15/04/2010 13:30:00
16/04/2010 10:30:00
17/04/2010 11:00:00
17/04/2010 13:30:00
17/04/2010 15:30:00
How can i have the list be output, so that the date is only displayed once followed by the times for that date, so the above list would look like something like this:
13/04/2010
10:30:00
13:30:00
14/04/2010
10:30:00
13:30:00
15/04/2010
10:30:00
13:30:00
16/04/2010
10:30:00
17/04/2010
11:00:00
13:30:00
15:30:00
Hi all,
Am I better to move a node I sent down form the server or to insert it?
I'm using jQuery (1.4) but would like to know for both jQuery and JS in general. In this case the node is small with only one child. But what if it were a large list?
Due to CSS limitations I am forced to stack to semi-transparent images on my website. I won't go into detail regarding the CSS since if I can get this question answered the problem is moot.
Anyway, I would like to modify image A in the GIMP such that it will look like it did originally after being stacked on top of image B. Both image A and image B have their opacities set to 50%. Image B is a solid color throughout, whereas image A has some minor details such as a gradient.
Here's what it looks like before image B is applied on top (and what it should look like in the end):
[URL=http://s421.photobucket.com/albums/pp292/SharkD2161/Support/Website/?action=view¤t=website_testing_target_image.png][IMG]http://i421.photobucket.com/albums/pp292/SharkD2161/Support/Website/th_website_testing_target_image.png[/IMG][/URL]
Here's what it looks like after image B has been applied on top:
[URL=http://s421.photobucket.com/albums/pp292/SharkD2161/Support/Website/?action=view¤t=website_testing_undesired_result.png][IMG]http://i421.photobucket.com/albums/pp292/SharkD2161/Support/Website/th_website_testing_undesired_result.png[/IMG][/URL]
Thanks!
Mike
I have three images, two of these images animate as follow and third image should blink:
<Window.Resources>
<Storyboard x:Key="AnimateTarget" RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Duration="0:00:03" Storyboard.TargetName="img1" Storyboard.TargetProperty="Y">
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="0" />
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="200" />
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="0:0:2" Duration="0:00:03" Storyboard.TargetName="img2" Storyboard.TargetProperty="x">
<EasingDoubleKeyFrame KeyTime="0:0:0" Value="0" />
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="200" />
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimation BeginTime="0:0:4" Duration="0:0:0.5" Storyboard.TargetProperty="(Image.Opacity)" Storyboard.TargetName="img3" From="1.0" To="0.0" RepeatBehavior="Forever" AutoReverse="True" />
</Storyboard>
</Window.Resources>
The first two images are animating fine but the third image doesn’t blink, it will do nothing and just stay there as you can see I have used the following code for blinking the third image:
<DoubleAnimation BeginTime="0:0:4" Duration="0:0:0.5" Storyboard.TargetProperty="(Image.Opacity)" Storyboard.TargetName="img3" From="1.0" To="0.0" RepeatBehavior="Forever" AutoReverse="True" />
Also this is a code for the third image:
<Image Height="65" Name="image1" Stretch="Fill" Width="67" Source="/PicTakeWPF;component/Images/422505_110594629067212_100003500265268_37406_1212153553_n.jpg">
<Image.RenderTransform>
<TranslateTransform x:Name="img3"></TranslateTransform>
</Image.RenderTransform>
</Image>
I would appreciate if someone helps me on this
Thanks,
Hey guys,
I have been working on this code but I can't find out what is wrong.
This program does compile and run but it ends up having a fatal error.
I have a file called myFile.txt, with the following content :
James------ 07.50 Anthony--- 17.00
And here is the code :
int main()
{
int n =2, valueTest=0,count=0;
FILE* file = NULL;
float temp= 00.00f, average= 00.00f, flTen = 10.00f;
float *totalNote = (float*)malloc(n*sizeof(float));
int position = 0;
char selectionNote[5+1], nameBuffer[10+1], noteBuffer[5+1];
file = fopen("c:\\myFile.txt","r");
fseek(file,10,SEEK_SET);
while(valueTest<2)
{
fscanf(file,"%5s",&selectionNote);
temp = atof(selectionNote);
totalNote[position]= temp;
position++;
valeurTest++;
}
for(int counter=0;counter<2;counter++)
{
average += totalNote[counter];
}
printf("The total is : %f \n",average);
rewind(file);
printf("here is the one with less than 10.00 :\n");
while(count<2)
{
fscanf(file,"%10s",&nameBuffer);
fseek(file,10,SEEK_SET);
fscanf(file,"%5s",¬eBuffer);
temp = atof(noteBuffer);
if(temp<flTen)
{
printf("%s who has %f\n",nameBuffer,temp);
}
fseek(file,1,SEEK_SET);
count++;
}
fclose(file);
}
I am pretty new to c and find it more difficult than c# or java. And I woud like to get some suggestions to help me to get better. I think this code could be simplier. Do you think the same ?
When I search on the Internet about JQuery and I got the jquery cheat sheet. At there, I am very confused about how to use the following under which condition. Pls help me.
[attribute|=val]
[attribute*=val]
[attribute~=val]
[attribute$=val]
[attribute=val]
[attribute!=val]
[attribute^=val]
[attribute]
[attribute1=val1] [attribute2=val2]
What are the functions of these special character *, ~, $, !, ^? Thanks very much.
Has anyone an idea, how I can make TValue using a reference to the original data? In my serialization project, I use (as suggested in XML-Serialization) a generic serializer which stores TValues in an internal tree-structure (similar to the MemberMap in the example).
This member-tree should also be used to create a dynamic setup form and manipulate the data.
My idea was to define a property for the Data:
TDataModel <T> = class
{...}
private
FData : TValue;
function GetData : T;
procedure SetData (Value : T);
public
property Data : T read GetData write SetData;
end;
The implementation of the GetData, SetData Methods:
procedure TDataModel <T>.SetData (Value : T);
begin
FData := TValue.From <T> (Value);
end;
procedure TDataModel <T>.GetData : T;
begin
Result := FData.AsType <T>;
end;
Unfortunately, the TValue.From method always makes a copy of the original data. So whenever the application makes changes to the data, the DataModel is not updated and vice versa if I change my DataModel in a dynamic form, the original data is not affected.
Sure I could always use the Data property before and after changing anything, but as I use lot of Rtti inside my DataModel, I do not realy want to do this anytime.
Perhaps someone has a better suggestion?
Hi,
I'm a beginner in java. I want the logic of the small program.
I have two arrays
array = {a1,a2,a3,a4,a5,,,,,,,,,an}
and
array2 = {b1,b2,b3,b4,,,,,,,,,,,bn}
I want string as:
a1b1,a2a3b2b3,a4a5a6b4b5b6,..........an
Please tell me what will be the logic.
I've searched through related questions but can't find what I need.
I have a richtextbox control. I need to trigger an event when the vertical scrollbar reaches a certain position (say 90% down to the bottom). I've been playing around with the events for the rich textbox but have yet to find anything.
Any help would be greatly appreciated.
For a project, I have to convert a binary string into (an array of) bytes and write it out to a file in binary.
Say that I have a sentence converted into a code string using a huffman encoding. For example, if the sentence was: "hello" h = 00 e = 01, l = 10, o = 11
Then the string representation would be 0001101011.
How would I convert that into a byte? <-- If that question doesn't make sense it's because I know little about bits/byte bitwise shifting and all that has to do with manipulating 1's and 0's.
I'm new to SQL and the time functions are different than mySQL so I'm having a terrible time finding a good site reference with USEFUL timestamp queries.
I'm not able to locate the correct way of doing this query in SQL:
Id Timestamp
-----------------------------------
1145744 2012-10-10 18:15:11.500
1145743 2012-10-10 18:15:11.313
1145742 2012-10-10 18:15:11.313
1145741 2012-10-10 18:15:11.253
1145740 2012-10-10 18:15:11.190
1145739 2012-10-10 18:15:11.190
1145738 2012-10-10 18:15:11.127
1145737 2012-10-10 18:15:11.067
1145736 2012-10-10 18:15:11.063
1145735 2012-10-10 18:15:10.940
1145734 2012-10-10 18:15:10.817
SELECT * from table WHERE Timestamp ... RANGE
I need the range of 2 timestamps so I can select rows by the following parameters:
second range
minute range
hour range
day range
week range
month range
year range
Is there one function to put in 2 timestamps and get the range? or is this a mix of functions I need?
Any good site references would be greatly appriceated. MSDN site isn't helping me isolate the proper way of doing this. I've been searching for about an hour trying to get the last day from 1:30PM to 1:30PM today.
I was recently faced with the problem of calculating the number of days from two dates in Java (without using joda, I'm afraid). Searching on the 'net shows most answers to this question say to get the milliseconds of the two days and convert that to days, which I found appalling. However, a scant few show a different approach: use a temporary variable to count how many times it takes adding 1 day to the first date to get to the second. This leaves the conversions to the code that does it best: the library.
Why do so many people advocate the first?
In another project, I had previously encountered numerous subtle date calculation problems involving time-zones, daylight-saving and once even leap years using seconds to do date comparisions and calculations. All these went away when all the comparison and calculation code was rewitten to use the language libraries. (This was in PHP, though, where the libraries are structured quite differently to Java.) So I'm understandably reluctant to use this "common wisdom" in the world of Java about comparing dates.
I need to port this following from Oracle syntax to Postgresql. Both FLO_END_DT and FLO_START_DATE are of type DATE in Oracle, and TIMESTAMP WITHOUT TIME ZONE in Postgresql:
SELECT
TRUNC( TO_CHAR(ROUND(( FL.FLO_END_DT- FL.FLO_START_DT)* 24), '9999D99'),2)
FROM
FLOWS FL
I am not familiar enough with Oracle to know what it is trying to accomplish.
Any ideas?
Hello everyone,
Im trying to use the DOM in PHP to do a pretty specific job and Ive got no luck so far, the objective is to take a string of HTML from a Wordpress blog post (from the DB, this is a wordpress plugin). And then out of that HTML replace <div id="do_not_edit">old content</div>" with <div id="do_not_edit">new content</div>" in its place. Saving anything above and below that div in its structure.
Then save the HTML back into the DB, should be simple really, I have read that a regex wouldnt be the right way to go here so Ive turned to the DOM instead.
The problem is I just cant get it to work, cant extract the div or anything.
Help me!!
UPDATE
The HTML coming out of the wordpress table looks like:
Congratulations on finding us here on the world wide web, we are on a mission to create a website that will show off your culinary skills better than any other website does.
<div id="do_not_edit">blah blah</div>
We want this website to be fun and easy to use, we strive for simple elegance and incredible functionality.We aim to provide a 'complete package'. By this we want to create a website where people can meet, share ideas and help each other out.
After several different (incorrect) workings all Ive got below is:
$content = ($wpdb->get_var( "SELECT `post_content` FROM $wpdb->posts WHERE ID = {$article[post_id]}" ));
$doc = new DOMDocument();
$doc->validateOnParse = true;
$doc->loadHTMLFile($content);
$element = $doc->getElementById('do_not_edit');
echo $element;
I have a table that looks like this:
ID / Description / textValue / dateValue / timeValue / Type
1 / FRRSD / NULL / 2010-04-16 00:00:00.000 / NULL / classdates
Now I've got a LINQ command to pull only the rows where the type is classdates from this table:
Dim dbGetRegisterDates As New dcConfigDataContext
Dim getDates = (From p In dbGetRegisterDates.webConfigOptions _
Where p.Type = "classdates" _
Select p)
I now want to display the data in five different labels like so:
lblClass1.Text = "Your class is from " & getDates.Description("FRRSD").dateValue & "to " & getDates.Description("FRRCD").dateValue
Basically, I want to pull a row based on the description column value and then return the datevalue column value from that same row.
Hi,
I am trying to create a css menu. I would like to remove border and padding for every last
li > a element on the child ul tag. (sorry for confusing)
Here is the code for the menu
<ul id="nav">
<li><a id="cat1" href="#">Menu 1</a></li>
<li><a id="cat2" href="#">Menu 2</a></li>
<li><a id="cat3" href="#">Menu 3</a>
<ul>
<li><a href="#">Sub Item 1 - M3</a></li>
</ul>
</li>
<li><a id="cat4" href="#">Menu 4</a>
<ul>
<li><a href="#">Sub Item 2 - M3</a></li>
<li><a href="#">Sub Item 3 - M3</a></li>
<li><a href="#">Sub Item 4 - M3</a></li>
</ul>
</li>
</ul>
The code must remove border and padding for last elements that is
<li><a href="#">Sub Item 1 - M3</a></li>
<li><a href="#">Sub Item 4 - M3</a></li>
Tried this but it takes off border for only sub item 4
$("#nav li ul").each(function(index) {
$("#nav li ul > :last a").css('border','0 none');
$("#nav li ul > :last a").css('padding','0');
});