| Trouble with reading and appending to lines in a file... |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- JFrame to FrontHi,
First of all sorry for my german posting before!
Here is my question in english:
By starting my application I construct a JFrame. By clicking onto a
JButton on this JFrame, it construct a NON-MODAL JDialog, which gets as
parentComponent the JFrame.
Now, if I switch between the Frame and the Dialog, they are correctly
activated, but the Frame does never come to foreground, i.e. it is ever
ovelapped by the Dialog.
I tryed with "Frame.setVisible(true)", "Frame.toFront()" and
"Frame.show()", but unfortunately, it does not work.
Is my desired behavior in this case even possible, or is there only the
way of setting the parentComponent of the Dialog to null?
Thanks!
--
Oliver Hirschi
http://www.FamilyHirschi.ch
- 4
- gray boxes instead of the appletHi all,
I'm a newbie, so if I should be posting this to a different group, please
(gently) tell me which one.
I have copied a very small Java applet source off the web and successfully
compiled it. I have taken the resulting Java classes and put them on my
website, using the <applet> html tag. The applet works great for me.
However, most of the people I work with just get a gray box where the applet
should be. (Others can see and use the applet just fine.) The gray box
*does not* have a red X in it. I can detect no pattern whatsoever in the
clients for whom the applet does/doesn't work.
The most mysterious part to me is that even people who do not see the applet
correctly on my website seem to be able to see and use the same applet just
fine on the site I acquired it from. As far as I know, it's identically the
same applet. (I just stole the source and compiled it.) This would tend to
rule out a problem on the client side, but I can't be sure.
I think I've been able to deduce that the problem is not with the location
of the Java classes on my web page; otherwise, there would be a red X in the
upper-left corner of the gray box, right? (And in that case it probably
wouldn't work for anyone, including me.)
Anyone have a clue what's going on? What other information can I provide?
TIA,
Gnome
- 5
- calling java from DOTNET 2? how stable or painfull?hi.. (sorry but i posted this in a dotnet newsgroup as well becoue i
don't know which would be better handling this question).
i have a java application server whish uses RMI as a delivery transport
for it's apis (it's gets the command in XML but the underlying protocol
needs to be RMI)..
so i need to write an RMI CLIENT to this thing, and expose it microsoft
land.
at first we thought to have it exposed as web service and consume this
service via dotnet dll. the dll would be given to desktop application
developers which canno parse XML.
then i was told i could expose it as JNI and have the dll access it
directly. then the dll in dot net 2.0 would either be given to desktop
developers or exposed as a web service in biztalk if web services are
needed.
btw can i do all of this with express edition versions?
- 5
- eclipse and CDT errorHi,
Somebody got CDT working in eclipse ? What do you have to download ?
I use mingw g++. When I install CDT I get a Java null pointer exception
error
any idea ?
Johan
- 7
- Alioth CVS Read-Only (was: Re: svn repository)-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Maybe we should ask to lock the Alioth's CVS repository of pkg-java
project, so we'll be sure everybody use the svn!
I Cc'd debian-admin but I'm not sure this is the right place. I already
send a mail about the wiki there but never got a response. And I'm not
sure they manage Alioth... If someone can Cc to a better location...
Thanks
Charles Fry wrote:
>>+1, keep only the RELEASE_<VERSION> tags.
>>
>>The directory layout seems ok to me. If there is a problem, we can svn mv.
>>
>>Many thanks for your work Charles,
>
> In that case I'll plan to make the migration on Monday. I'lll send out
> email 15 minutes prior to starting the move, then upon starting and
> finally upon completing the migration.
>
> cheers,
> Charles
- --
.''`.
: :' :rnaud
`. `'
`-
Java Trap: http://www.gnu.org/philosophy/java-trap.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDwlOu4vzFZu62tMIRAtS0AJ9R973xSgRKSS0ZCv6CgCvaTv0MuwCdG29Z
jK7dIKhblWvu5zX3QrgQ7ZE=
=wRbl
-----END PGP SIGNATURE-----
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 7
- How do you like Richfaces?How do you like Richfaces?
http://labs.jboss.com/jbossrichfaces/
Do you think it is the best way to integrate AJAX capabilities into
JSF?
- 7
- 7
- Design question about data conversion class.I'm looking for a name for my class that reflects what it does. Its a
class with functions that converts data.
For example, my current class is called ArticleValueObjectCreator. It
has a method that converts resultsets to an article value object bean.
I now need to create a method which converts an article related
resultset to xml. In the future I may need one that converts a value
object "bean" to xml.
I'm thinking of refactoring the class now that I need to grow it.
What is the best way of acomplishing good design here?
Would renaming the class to something like ArticleDataCovertor, or
ArticleAdaptor tie in with good programming practice, or would it be
better to split these methods up into different classes ( thus making
each class dependent on a fine range particular technologies ) eg, one
which is xml and jdbc only, another that is xml only.
Are there any design patterns like this that emphasise clean
seperation between technologies. Or am I over-engineering?
Thanks
Ben
- 8
- Target Frame?After installing the latest Java version an applet on my homepage doesn't
work as it did before!
Instead of showing a new window in the selected target frame, a new popup
window is openend!
Who can help?
- 9
- clearing outputHello,
I've looked far and wide for the answer to this question without any
success. Is there a method in Java that clears output to
System.out.println? My goal is to pass output to the line then erase it
so that I don't have repeating lines in my loop. Any help is much
appreciated.
Thanks,
Ben
- 10
- pattern matching help on logical ORI'm using Java 1.4.2_05 and need some help getting a logical OR to work
within my pattern matcher.
I'm trying to get both string A and B to be recognized by one pattern?
String strA = "04/14:03,blahblahblah\u007F";
String strB = "04/14:03,blahblahblah";
So I'm trying to match:
Two numerals followed by slash followed by 2 numerals followed by a
colon followed by 2 numerals followed by a comma followed by anything
followed by a one or 0 delete character OR the end of the line/string.
Here is the regex:
Pattern.compile("[0-9]{2}[\u002F][0-9]{2}[\u003A][0-9]{2}[\u002C].+[\u007F?]|[$]",
Pattern.DOTALL);
The logical OR doesn't work though. And I've tried the OR a few other
ways as well.
... [\u007F|$]
... [\u007F?|$]
... [\u007f]?|[$]
These don't work either.
I'd appreciate any suggestions.
Thanks,
Shawna
- 10
- URL Class Loader & file deletionHello,
The following code always displays "File cannot be deleted".
Any idea on the way to allow a file to be deleted when it has been used
by a URL class loader to load code ?
public class ClassLoaderTester {
public static void main( String[] args ) {
try {
String s = "c:\\zob.jar";
URLClassLoader oCL = new URLClassLoader(
new URL[] {
new File(s).toURL()
} );
Class c = oCL.loadClass("com.mysql.jdbc.Driver");
Object o = c.newInstance();
o = null;
c = null;
oCL = null;
System.gc();
System.runFinalization();
File oFile = new File(s);
if ( !oFile.delete() ) {
System.err.println("File cannot be deleted");
}
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}
Thank's in advance.
- 10
- Wholesale all laptops,Apple Ipods Nano, Xbox 360, Sony PS3, Sony PSP.wii ,SONY SD.SONY USB.GPS http://www.new-nikeshoes.cnhi
We are the biggest wholesale suppliers..........We have a lot of very
nice quality merchandises with the very special price
Our main markets are the USA, the UK, Germany, France, Italy, Greece,
Jordan, Australia, Canada,Sweden, and many other countries in Europe
and the Middle East regions.
Ipod nano 1G 45$ ,2G 55$, 4G 65$,8G 70$, 30G 100$ ,60G 120$
ps3 60GB 400$ 40GB 350$ 80GB 450$
psp 150$
wii 220$
X360 300$
SONY Scandisk or Kingston MicroSD
16GB 50$ 8GB 30$ 4GB 18$ 2GB 13$ 1GB 10$
SONY Kingston USB & Flash
16GB 50$ 8GB 30$ 4GB 18$ 2GB 13$ 1GB 10$
We wholesale all laptops
Sony VGN-CR13/B 380$
Sony VGN-CR13/L 350$
Sony VGN-CR15/B 320$
Sony VGN-CR13/P 480$
Sony VGN-C21CH 450$
Sony VGN-SZ44CN 580$
Sony VGN-C22CH/W 620$
Sony VGN-N17C 480$
Sony VGN-CR13/W 580$
Sony VGN-FZ15 560$
Apple MacBook 580$
Apple MacBook Pro(MA896CH/A)680$
Apple MacBook Pro(MA896CH/A) 630$
Apple MacBook (MB063CH/A) 580$
Apple MacBook Pro(MA895CH/A) 580$
Apple MacBook(MB062CH/A) 590$
Apple MacBook(MA700CH/A) 580$
Apple MacBook(MA701CH/A) 550$
Apple MacBook Pro (MA610CH/A) 650$
Apple MacBook Pro (MA611CH/A) 680$
Apple MacBook (MA699CH/A) 580$
(1).all products are all original and new
(2).they have 1year international warranty.
(3).free shipping include ems, tnt, dhl, ups. you may choose one kind
(4).deliver time is in 5 days to get your door
We insist the principia: Prestige first,high-quality,competitive
price,
best services,and timely delivery.
Website: http://www.new-nikeshoes.cn
msn: email***@***.com
Hong-da Co., Ltd.
- 13
- Batch image compression problem. Help!I am using Java to develop a web application that lets user to upload images
to the web server, and the server will automatically resize and compress the
images. It lets users to upload maximum 5 images at one time. The system
works fine. But sometimes a very strange problem occurs. When the users
upload the image, the images are able to be uploaded to the system
successfully, but the system is hanged on the image compression stage. The
system message returns that the uploaded images are under compression, but
never ended, even one hour.
I have checked the system log and find there is nothing mentioned in the log
file. This problem doesn't happen regularly, but it does happen sometimes.
Please kindly advise me what mistake I have made.
Thanks,
Chris
Herebelow is the part of source code:
==============================================================
/**
* create small image.
* @param oldImage,give a image to create small image.
* @param newImage,the image you want to create.
* @param maxWidth,the max width.
* @param maxHeight, the max height.
* @return the image's name.
* @throws java.lang.Exception
*/
public String createThumbnail(String srcImg,String objImg, int
maxWidth,int maxHeight) throws Exception{
try {
EuwLog.EuwPrint("Begin Thumbnail"+objImg);
ImageIcon ii = new ImageIcon(srcImg);
Image i = ii.getImage();
ii = null;
Image temp = null;
BufferedImage bufferedImage=null;
int iWidth = i.getWidth(null);
int iHeight = i.getHeight(null);
double ratio = getRatio(iWidth,iHeight,maxWidth,maxHeight);
iWidth = (int)(ratio*iWidth);
iHeight = (int)(ratio*iHeight);
if (ratio<1.0f){
temp =
i.getScaledInstance(iWidth,iHeight,Image.SCALE_AREA_AVERAGING);
i.flush();
i = null;
temp = new ImageIcon(temp).getImage();
// Create the buffered image.
bufferedImage = new BufferedImage(iWidth, iHeight,
BufferedImage.TYPE_INT_RGB);
// Copy image to buffered image.
Graphics g = bufferedImage.createGraphics();
// Clear background and paint the image.
g.setColor(Color.white);
g.fillRect(0, 0, iWidth,iHeight);
g.drawImage(temp, 0, 0, null);
g.dispose();
g = null;
// sharpen
float[] sharpenArray = { -0.125f, -0.125f, -0.125f, -0.125f,2,
-0.125f, -0.125f, -0.125f, -0.125f };
Kernel kernel = new Kernel(3, 3, sharpenArray);
ConvolveOp cOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
null);
bufferedImage = cOp.filter(bufferedImage, null);
cOp = null;
kernel = null;
/* write the jpeg to a file */
//File file = new File(objImg);
FileOutputStream out = new FileOutputStream(objImg);
/* encodes image as a JPEG data stream */
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param =
encoder.getDefaultJPEGEncodeParam(bufferedImage);
// writeParam = new JPEGImageWriteParam(null);
//
writeParam.setCompressionMode(JPEGImageWriteParam.MODE_EXPLICIT);
//writeParam.setProgressiveMode(JPEGImageWriteParam.MODE_DEFAULT);
param.setQuality(0.9f, true);
encoder.setJPEGEncodeParam(param);
encoder.encode(bufferedImage);
param = null;
encoder = null;
temp.flush();
temp = null;
bufferedImage.flush();
bufferedImage = null;
out.close();
out = null;
EuwLog.EuwPrint("End Thumbnail"+objImg);
- 14
- how to combine paintComponent with add(component)?I have a Java application with several classes that extend JPanels and
that, till now, didn't have any internal Swing components. They did
display text that was antialiased and sometimes animated by overriding
paintComponent in each of these custom classes. And this worked fine.
But now on one of the panels I want to add in the northeast corner
another customized JPanel extending object. When I just call
basePanel.add(newPan) the newPan would show up when first displayed
but then dissapear the next time repaint() is called on the basePanel.
I imagine I have to do something in the basePanel's paintComponent
method to make sure the new panel is repainted every time. But I'm not
sure how that is handled. Anyone have some advice? Maybe a quick
example?
|
| Author |
Message |
scopp

|
Posted: 2004-1-22 9:29:00 |
Top |
java-programmer, Trouble with reading and appending to lines in a file...
Hi there,
Please bare with me on this, I'm a newbie :o). Ok, I'm trying to read a
file (a bunch of 1 word lines), find the last line with the word "SKIP" at
the end, and get the next line. After getting the desired line, I want to
append the word "SKIP" to that line as well and save and close the file.
I also want the class to have an input parameter (integer), which will be
the same name of the file (example: input = 1234 --> filname = 1234.txt).
Here is what I've got so far:
import java.io.*;
public class GetLine {
int number; //let's say the lines in the file are all 5 digit
numbers, with no spaces
public boolean evaluate(String str) {
//
//I'm not sure how to evaluate if the end of the line
has the word SKIP and the following doesn't work????
//
if ( StringBuffer.indexOf("SKIP\n") )
return true;
}
public void get(int c) throws IOException, FileNotFoundException {
String line;
boolean b;
FileReader fr=new FileReader(number + ".txt");
BufferedReader br=new BufferedReader(fr);
while((line=br.readLine())!=null )
{
b = evaluate(line);
if (b==false)
{
//
//not sure if I can just do a "return
line" to get the first line found without SKIP???
return line;
//
//not sure if I can do the following
either???
//
line = line + "SKIP";
}
}
}
}
Please, any suggestions are apprciated. Thanks for your help.
scopp
|
| |
|
| |
 |
Michael Dunn

|
Posted: 2004-1-22 11:17:00 |
Top |
java-programmer >> Trouble with reading and appending to lines in a file...
"scopp" <email***@***.com> wrote in message news:email***@***.com...
: Hi there,
:
: Please bare with me on this, I'm a newbie :o). Ok, I'm trying to read a
: file (a bunch of 1 word lines), find the last line with the word "SKIP" at
: the end, and get the next line. After getting the desired line, I want to
: append the word "SKIP" to that line as well and save and close the file.
:
: I also want the class to have an input parameter (integer), which will be
: the same name of the file (example: input = 1234 --> filname = 1234.txt).
:
: Here is what I've got so far:
:
: import java.io.*;
: public class GetLine {
: int number; //let's say the lines in the file are all 5 digit
: numbers, with no spaces
: public boolean evaluate(String str) {
: //
: //I'm not sure how to evaluate if the end of the line
: has the word SKIP and the following doesn't work????
: //
: if ( StringBuffer.indexOf("SKIP\n") )
: return true;
: }
:
: public void get(int c) throws IOException, FileNotFoundException {
: String line;
: boolean b;
: FileReader fr=new FileReader(number + ".txt");
: BufferedReader br=new BufferedReader(fr);
: while((line=br.readLine())!=null )
: {
: b = evaluate(line);
: if (b==false)
: {
: //
: //not sure if I can just do a "return
: line" to get the first line found without SKIP???
: return line;
: //
: //not sure if I can do the following
: either???
: //
: line = line + "SKIP";
:
: }
: }
: }
: }
:
:
: Please, any suggestions are apprciated. Thanks for your help.
:
: scopp
Something to play around with
import java.io.*;
import java.util.ArrayList;
class TestInputOutput
{
public TestInputOutput()
{
try
{
ArrayList lines = new ArrayList();
BufferedReader fr = new BufferedReader(new FileReader("Test.txt"));
String line = "";
while((line = fr.readLine()) != null) lines.add(line);
for(int x = lines.size()-1; x >= 0; x--)
{
line = lines.get(x).toString();
if(line.substring(line.length()-4).equals("SKIP"))
{
if(x < lines.size()-1) lines.set(x+1,lines.get(x+1) + "SKIP");
break;
}
}
fr.close();
FileWriter fw = new FileWriter("Test.txt");
for(int x = 0; x < lines.size(); x++)
{
fw.write(lines.get(x).toString() + "\r\n");
}
fw.close();
}
catch(Exception e){System.out.println("error - terminating");}
System.exit(0);
}
public static void main(String[] args) {new TestInputOutput();}
}
|
| |
|
| |
 |
Andrew Thompson

|
Posted: 2004-1-22 11:38:00 |
Top |
java-programmer >> Trouble with reading and appending to lines in a file...
"scopp" <email***@***.com> wrote in message
news:email***@***.com...
I suspect Michael's answer will fix the
immediate problem, but I would like to
address a more fundamental issue.
Techniques for testing..
....
| Here is what I've got so far:
An example, you are already miles ahead
of the game.
| import java.io.*;
| public class GetLine {
| int number; //let's say the lines in the file
are all 5 digit
| numbers, with no spaces
| public boolean evaluate(String str) {
| //
| //I'm not sure how to evaluate if the end
of the line
| has the word SKIP and the following doesn't work????
| //
But here is where you should insert some
code if things are not working..
System.out.println( "GL.e str: '" + str + "'");
Note that I have put single quotes
either side of the actual string..
Give it a try and see if it reveals
anything significant..
| if ( StringBuffer.indexOf("SKIP\n") )
| return true;
| }
......
One last comment is that GetLine is
a bad name for a class, classes should
be nouns rather than verbs..
HTH
|
| |
|
| |
 |

|
Posted: 2004-1-23 2:06:00 |
Top |
java-programmer >> Trouble with reading and appending to lines in a file...
Both of your suggestions have been duley noted. Thank you both very much!
stephen
"Andrew Thompson" <email***@***.com> wrote in message
news:2AHPb.22880$email***@***.com...
> "scopp" <email***@***.com> wrote in message
> news:email***@***.com...
>
> I suspect Michael's answer will fix the
> immediate problem, but I would like to
> address a more fundamental issue.
>
> Techniques for testing..
> ....
> | Here is what I've got so far:
>
> An example, you are already miles ahead
> of the game.
>
> | import java.io.*;
> | public class GetLine {
> | int number; //let's say the lines in the file
> are all 5 digit
> | numbers, with no spaces
> | public boolean evaluate(String str) {
> | //
> | //I'm not sure how to evaluate if the end
> of the line
> | has the word SKIP and the following doesn't work????
> | //
>
> But here is where you should insert some
> code if things are not working..
>
> System.out.println( "GL.e str: '" + str + "'");
>
> Note that I have put single quotes
> either side of the actual string..
>
> Give it a try and see if it reveals
> anything significant..
>
> | if ( StringBuffer.indexOf("SKIP\n") )
> | return true;
> | }
> ......
>
> One last comment is that GetLine is
> a bad name for a class, classes should
> be nouns rather than verbs..
>
> HTH
>
> --
> Andrew Thompson
> * http://www.PhySci.org/ PhySci software suite
> * http://www.1point1C.org/ 1.1C - Superluminal!
> * http://www.AThompson.info/andrew/ personal site
>
>
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- MouseEvent problem in JPopupMenuI'm having trouble getting a MouseEvent to get fired for mouseReleased
to fire in any component added to a submenu of a JPopupMenu in Java 1.5.
The same code works fine in 1.4.
Here's some simple code to demonstrate the problem. When clicking the
final button, it stays down and "released" is never printed by the
listener. Under 1.4, the button is fully operational, and "released" is
printed. The other two events (clicked and pressed) work fine in either
version.
Any ideas what's going on here? Any suggested work-arounds? The real
application where I observed this has a rather complex custom component
placed in a submenu of a JPopupMenu, and mouseReleased is needed for it
to work properly.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JPopupMenu;
public class BugTest extends JFrame
{
private MouseListener ml = new MouseListener() {
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mouseClicked(MouseEvent e)
{
System.out.println("clicked");
}
public void mousePressed(MouseEvent e)
{
System.out.println("pressed");
}
public void mouseReleased(MouseEvent e)
{
System.out.println("released");
}
};
public BugTest()
{
super("Test Popup mouseReleased");
JButton startButton = new JButton("Start");
startButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
JPopupMenu popup = new JPopupMenu();
JMenu middleMenu = new JMenu("Middle");
JButton endButton = new JButton("End");
endButton.addMouseListener(ml);
middleMenu.add(endButton);
popup.add(middleMenu);
popup.show(BugTest.this, 20, 20);
}
});
getContentPane().add(startButton);
pack();
setVisible(true);
}
public static void main(String[] args)
{
new BugTest();
}
}
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
- 2
- How to release a free source code?Hi All,
I want to release some free source code, but not all code is done by
me. (ex: I use some code from others into my project... )
I think it is too complicate to check every function/routine belongs to
whom, what should I do to avoid the copyright problem?
Thank you very much.
Best regards,
Boki.
- 3
- Lists: XQuery engines, JDBC and ODBC drivers, OLE DB and .NET providers, DB2 extendersUpdated driver, provider and extender lists are now available at SQLSummit.com.
The newest list is XQuery processors.
JDBC drivers (112)
www.SQLSummit.com/jdbcvend.htm
XQuery engines (29)
www.SQLSummit.com/XQueryProc.htm
ODBC drivers (212)
www.SQLSummit.com/odbcvend.htm
.NET providers (20)
www.SQLSummit.com/dataprov.htm
OLE DB providers (53)
www.SQLSummit.com/oledbven.htm
DB2 Extenders (18)
www.SQLSummit.com/extendven.htm
-----------------------------------
Ken North
www.WebServicesSummit.com
www.SQLSummit.com
www.GridSummit.com (coming soon)
- 4
- Question about binary release licenseHi,
I hope I'm wrong, but does the license of binary jdk/jre
released by FreeBSD Foundation prohibit redistribution
of the package ? I think that Sun allows one to redistribute
at least jre with application so why is this different ?
Ari S.
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 5
- [UPD] SQLeonardo MMV.III released[http://querybuilder.sourceforge.net]
SQLeonardo is a database query tool written in Java, distributed under
the GNU GENERAL PUBLIC LICENSE.
Include FreeQueryBuilder to create SQL queries without directly writing
SQL. All queries can be saved in a workspace for later use. Works
with any JDBC compliant database(ORACLE,MySQL,HSQLDB,Firebird,DB2)
*** NEW ***
Edit tables directly via the data grid
Regards Nickyb
- 6
- Shame onJeff Relf wrote:
> Hello John Bailo , You wrote ,
> " You bankrrupted your life with unrecoverable debt ,
> and now you come here to blame others
> for your foolish behavior "
>
> My " Foolish behavior " was when I ejaculated in 1982 ,
> after being tricked by a woman . That's hardly a crime .
Fooled me once, shame on you.
Fooled me twice, shame on me.
>
> It's not like your fantasies of time travel
> could rectify that .
- 7
- [SWT] How to enable and disable windows correctly, if using dialogs?Hi,
I am programming a configuration gui for a hardware simulator. There I
wrote some gui elements, which enable the user to set up some
parameters used by the simulator.
For example it is possible to enter values in textfields. I do a check,
if the entered value even is an int, and if not, I create a short error
message. For example like this:
textwidth.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
try {
width = Integer.parseInt(textwidth.getText());
} catch (NumberFormatException nfe){
if (!textwidth.getText().equals("")) {
width = 0;
ErrorHandling error = new ErrorHandling(
"Please enter numbers only!\r\nWidth is
reset to 0.",
selscomposite.getShell());
textwidth.setText("0");
}
}
//modify the scale so it represents the entered value
scalewidth.setSelection(scalewidth.getMaximum() - width
+ scalewidth.getMinimum());
}
});
textwidth is the textfield, representing the value chosen through a
scale and enabling the user to enter a value manually, and the
scale-representation is updated if done so.
ErrorHandling is the class I use throughout the project to display
small error messages. It looks like this:
public class ErrorHandling {
Shell error;
Shell parentshell;
public ErrorHandling(String errormessage, Shell shell) {
//shell displaying the errormessage
error = new Shell(SWT.TITLE | SWT.BORDER);
error.setText("User input error");
//the layout for the error shell
FillLayout filllayout = new FillLayout(SWT.VERTICAL);
filllayout.marginHeight = 5;
filllayout.marginWidth = 5;
filllayout.spacing = 3;
error.setLayout(filllayout);
//disable the parent shell
parentshell = shell;
parentshell.setEnabled(false);
//set the errormessage
CLabel errorlabelmessage = new CLabel(error, SWT.CENTER |
SWT.SHADOW_IN);
errorlabelmessage.setText(errormessage);
//a button to close the errormessage
Button errorreceived = new Button(error, SWT.PUSH |
SWT.CENTER);
errorreceived.setText("Ok, i got it!");
errorreceived.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
parentshell.setEnabled(true);
error.close();
}
});
//create the errorshell
error.setActive();
error.pack();
error.open();
}
}
parentshell is needed, so I can disable the shell, in which the error
occured until the user hast closed the errormessage by using the "Ok, I
got it!"-button. I don't even know if this is good style, but it's all
I know to do so far. I need to have a new shell-variable (e.g.
parentshell), because otherwise I could not use it in the inner class
within the listener-context. This leads to the first question: Is there
no better way to handle this, but the new Object "parentshell"?
The second problem with this implementation is, that if I do not use
the SWT.BORDER and SWT.TITLE constants within the initialization of the
error-Shell-object, the small window displaying the error message looks
real crappy. The title and a window border is needed, but if I have
those, I also have a close-button on the upper right of the window.
Because a disabled the parent shell:
parentshell = shell;
parentshell.setEnabled(false);
I have to enable it, if the error message is closed. I am able to
enable it, if the user choses the button, but if the user closes the
window by the close-button of the window-manager, the parent-shell
never ever gets accessible, because there never came a command to
enable it again.
A last few words: I tried several constants in the creation of the
error-Shell-object, but most of them (like ON_TOP, or several modal
state specifiers) only have the effect, that the error-message has no
border and no title any more. I am using Linux and the X-Server, so I
don't know what the behaviour of these constants would be on other
window-architectures.
Now this was a whole lot of information, but ask me, if you want to
know something more specific. Any comments are welcome, even those,
telling me what I have done is totally crap and I should do it like
this or that.
Thank you in advance!
PS: Sorry for any errors and the bad english.
- 8
- Tabs on the right side in JTabbedPane ?I wanted to add 4 tabs to a JTabbedPane. Two of them should be on the left
side and two on the right side (all on the top). In other words, I want a
pretty big gap between these two sets of tabs.
______ _____ ______ _____
/__1___\/__2__\________________/___3__\/__4__\
|
|
|
|
Something like the above.
Is there a way to do it ?
Thanks.
RC
- 9
- How to get the return value by a Sybase stored procedureSuppose I have the following dummy stored procedure on Sybase or MS
SQL Server:
create procedure foo
as
select 'Hello World'
return 12345
With jdbc driver, how can I get both "Hello World" and 12345 back? Or
can I get the return code back at all? Do I have to use output
parameters?
Thanks in advance.
-tony
- 10
- Java code obfuscationHey all,
I'm looking at using a tool to obfuscate some java code and have a 3
part question:
1. If price were not a factor, what obfuscator would you use?
2. If price were a factor and you wanted a midrange cost product (say
under $500) what obfuscator would you use?
3. If you wanted a free obfuscator which one would you use?
Something of note about my product is that there is a fair amount of
reflection going on as I do a lot of dynamic class loading. I've played
around with RetroGuard, and while it's nice, the script creation looks
like it will be quite painful with the amount of reflection I'm going to
have to work with. Anyway, I'd appreciate any thoughts you might have.
Thanks.
Matthew Zimmer
- 11
- XAResource implementation besides of DB and JMSHi All,
When I read article about JTA, the most commonly used XAResource
implementation is for either DB or JMS. I'm wondering if there's any
other type of XAResource is really meaningful or useful to be cretaed
at all. If you have experience making any XAResource besides of DB and
JMS, would you please share your knowledge. It would be great if you
can tell what kind of XAResource you have created and where it is used(
from both business and coding point of view ). It will be even better
if you can share idea about how the new XAResource is implemented.
Thanks!
- 12
- Transform DOM to TableModelI'm writing an application which will invoke a servlet (via a
UrlConnection) and display the (CML) data returned by the servlet
in a JTable. (The data returned by this servlet is in row/column
format, so in this application a JTable is the appropriate control
for displaying the data.) Can someone give me advice on the best
approach for converting a DOM to a TableModel:
-- Write a Transformer that takes a Document as a source and
uses a TableModel as a sink?
-- Use XSLT?
-- Use SAX instead of DOM (I'm not married to DOM) and build
the TableModel as thx SAX parser parses it?
Any advice would be appreciated.
Larry Coon
University of California
- 13
- strings in javaAs a response to a request to "make a complete and concise statement" and
"to provide some context", I reply here to my own post.
"Boudewijn Dijkstra" <email***@***.com> schreef in bericht
news:40b5afde$0$41748$email***@***.com...
> "Tony Morris" <email***@***.com> schreef in bericht
> news:c91dr1$i3c$email***@***.com...
> > "Ace" <email***@***.com> wrote in message
> > news:s0Usc.167024$email***@***.com...
> > > Now what if you had: String str ="abc"+" "+"def"+"efg";
> >
> > The compiler creates a single String instance with the value "abcdefefg"
>
> It becomes "abc defefg", actually.
> It is
remove "It is"
insert "The exact same string can be"
> created with the following Java statement:
> new StringBuffer().append("abc").append(" ")
> .append("def").append("efg").toString()
Maybe I am just too flexible in my use of language.
- 14
- Why does we need Inner Class?Hello:
Am I correct? And everyone's words is welcome. Thanks.
class A {
int i;
int geti() {
return i;
}
}
class B {
int j;
int getj() {
return j;
}
}
/* It's wrong to write as follows: */
/*
public class C extends A,B {
}
*/
/* But it's right as follow: */
public class C extends A{
class D extends B {
}
}
- 15
- ligatures in Java 2DI've been trying to work out how to get Java to handle ligatures such
as "fi" correctly, but without much success. Various online documents
have suggested that I need to be intervening in the rendering process
and laying out my own GlyphVectors based on information associated
with Fonts, but I can't find out the details I need to actually do
that systematically.
I have discovered (<http://mindprod.com/jgloss/ligature.html>) that
'fi' has its own code point (\ufb01) in Unicode - should I be manually
checking whether my Font has specific glyphs for such ligatured
characters and manually substituting them into my char[] to feed to
layoutGlyphVector? Do Fonts come with lists of ligatures they
support, and if so how do I get at them?
And most of all, what is TFM that I am currently foolishly neglecting
to R?
Des
|
|
|