|
Hello all,
I have 5 textareas one below the another. They are packed using the GridBagLayout (Doing all this in NetBeans 6.5). When only one line text is fetched in the textarea everything is fine, but the moment the text fetched is of 2 or more lines, all the textareas size increases reducing the last panel's (below 5 textares) height.
This also happens with the combo box. when the items fetched are greater than the width of the combo its width increases and comes to normal if the items are of less width.
Anybody faced such problem ??? Plz. help.
|
|
|
|
|
You will probably need to develop a custom layout manager rather than using one of the pre-defined layout modes. Basically, you create a class that implements LayoutManager, providing an implementation for the layoutContainer method, among others. You then instantiate your manager and assign it to be the parent window's manager with setLayout.
Try plowing through the docs for LayoutManager and take a whack at it. I can help if you have trouble.
[edit]
Hint - If you make your custom layout manager an inner class of the parent window, it'll have access to the control variables representing the text areas and be able to manipulate their positions.
[/edit]
modified on Wednesday, December 2, 2009 1:02 PM
|
|
|
|
|
thanks ....
will get back to u, when i start working on that.
currently working on other higher priority issues.
thanks again..
|
|
|
|
|
Is it advanced concept?what is java effects?Where can i use it?Please give any url for java effects tutorial..
vinoli
|
|
|
|
|
Why not try this[^] first!
|
|
|
|
|
|
Hi,
I have created a web application in Struts 1. It has got a reporting tool module, for which i want to embed the features of Pentaho into it. I figured out that it is possible by adding some of the JAR files of Pentaho into my application folder and editing my web.xml file. I tried, but couldnt get it the way i wanted. Can anyone please help me with this? I am not using hibernate in my project.
Regards,
Vivek Vijayan
This code was posted by me...
|
|
|
|
|
This does not appear to be a Java question. Try the Struts or Pentaho forums instead.
|
|
|
|
|
Does anyone know what am i supposed to do to write xml attribute in java?
example
<body id="Content">Text</body>
|
|
|
|
|
i have got a code for Web Crawler in java language....
Following is applet code...
import java.applet.Applet;
import java.text.*;
import java.awt.*;
import java.awt.List;
import java.awt.event.*;
import java.util.*;
import java.util.*;
import java.net.*;
import java.io.*;
public class WebCrawler extends Applet implements ActionListener, Runnable {
public static final String SEARCH = "Search";
public static final String STOP = "Stop";
public static final String DISALLOW = "Disallow:";
public static final int SEARCH_LIMIT = 50;
Panel panelMain;
List listMatches;
Label labelStatus;
Vector vectorToSearch;
Vector vectorSearched;
Vector vectorMatches;
Thread searchThread;
TextField textURL;
Choice choiceType;
public void init() {
panelMain = new Panel();
panelMain.setLayout(new BorderLayout(5, 5));
Panel panelEntry = new Panel();
panelEntry.setLayout(new BorderLayout(5, 5));
Panel panelURL = new Panel();
panelURL.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
Label labelURL = new Label("Starting URL: ", Label.RIGHT);
panelURL.add(labelURL);
textURL = new TextField("", 40);
panelURL.add(textURL);
panelEntry.add("North", panelURL);
Panel panelType = new Panel();
panelType.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
Label labelType = new Label("Content type: ", Label.RIGHT);
panelType.add(labelType);
choiceType = new Choice();
choiceType.addItem("text/html");
choiceType.addItem("audio/basic");
choiceType.addItem("audio/au");
choiceType.addItem("audio/aiff");
choiceType.addItem("audio/wav");
choiceType.addItem("video/mpeg");
choiceType.addItem("video/x-avi");
panelType.add(choiceType);
panelEntry.add("South", panelType);
panelMain.add("North", panelEntry);
Panel panelListButtons = new Panel();
panelListButtons.setLayout(new BorderLayout(5, 5));
Panel panelList = new Panel();
panelList.setLayout(new BorderLayout(5, 5));
Label labelResults = new Label("Search results");
panelList.add("North", labelResults);
Panel panelListCurrent = new Panel();
panelListCurrent.setLayout(new BorderLayout(5, 5));
listMatches = new List(10);
panelListCurrent.add("North", listMatches);
labelStatus = new Label("");
panelListCurrent.add("South", labelStatus);
panelList.add("South", panelListCurrent);
panelListButtons.add("North", panelList);
Panel panelButtons = new Panel();
Button buttonSearch = new Button(SEARCH);
buttonSearch.addActionListener(this);
panelButtons.add(buttonSearch);
Button buttonStop = new Button(STOP);
buttonStop.addActionListener(this);
panelButtons.add(buttonStop);
panelListButtons.add("South", panelButtons);
panelMain.add("South", panelListButtons);
add(panelMain);
setVisible(true);
repaint();
vectorToSearch = new Vector();
vectorSearched = new Vector();
vectorMatches = new Vector();
URLConnection.setDefaultAllowUserInteraction(false);
}
public void start() {
}
public void stop() {
if (searchThread != null) {
setStatus("stopping...");
searchThread = null;
}
}
public void destroy() {
}
boolean robotSafe(URL url) {
String strHost = url.getHost();
String strRobot = "http://" + strHost + "/robots.txt";
URL urlRobot;
try {
urlRobot = new URL(strRobot);
} catch (MalformedURLException e) {
return false;
}
String strCommands;
try {
InputStream urlRobotStream = urlRobot.openStream();
byte b[] = new byte[1000];
int numRead = urlRobotStream.read(b);
strCommands = new String(b, 0, numRead);
while (numRead != -1) {
if (Thread.currentThread() != searchThread)
break;
numRead = urlRobotStream.read(b);
if (numRead != -1) {
String newCommands = new String(b, 0, numRead);
strCommands += newCommands;
}
}
urlRobotStream.close();
} catch (IOException e) {
return true;
}
String strURL = url.getFile();
int index = 0;
while ((index = strCommands.indexOf(DISALLOW, index)) != -1) {
index += DISALLOW.length();
String strPath = strCommands.substring(index);
StringTokenizer st = new StringTokenizer(strPath);
if (!st.hasMoreTokens())
break;
String strBadPath = st.nextToken();
if (strURL.indexOf(strBadPath) == 0)
return false;
}
return true;
}
public void paint(Graphics g) {
g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
panelMain.paint(g);
panelMain.paintComponents(g);
}
public void run() {
String strURL = textURL.getText();
String strTargetType = choiceType.getSelectedItem();
int numberSearched = 0;
int numberFound = 0;
if (strURL.length() == 0) {
setStatus("ERROR: must enter a starting URL");
return;
}
vectorToSearch.removeAllElements();
vectorSearched.removeAllElements();
vectorMatches.removeAllElements();
listMatches.removeAll();
vectorToSearch.addElement(strURL);
while ((vectorToSearch.size() > 0)
&& (Thread.currentThread() == searchThread)) {
strURL = (String) vectorToSearch.elementAt(0);
setStatus("searching " + strURL);
URL url;
try {
url = new URL(strURL);
} catch (MalformedURLException e) {
setStatus("ERROR: invalid URL " + strURL);
break;
}
vectorToSearch.removeElementAt(0);
vectorSearched.addElement(strURL);
if (url.getProtocol().compareTo("http") != 0)
break;
if (!robotSafe(url))
break;
try {
URLConnection urlConnection = url.openConnection();
urlConnection.setAllowUserInteraction(false);
InputStream urlStream = url.openStream();
String type
= urlConnection.guessContentTypeFromStream(urlStream);
if (type == null)
break;
if (type.compareTo("text/html") != 0)
break;
byte b[] = new byte[1000];
int numRead = urlStream.read(b);
String content = new String(b, 0, numRead);
while (numRead != -1) {
if (Thread.currentThread() != searchThread)
break;
numRead = urlStream.read(b);
if (numRead != -1) {
String newContent = new String(b, 0, numRead);
content += newContent;
}
}
urlStream.close();
if (Thread.currentThread() != searchThread)
break;
String lowerCaseContent = content.toLowerCase();
int index = 0;
while ((index = lowerCaseContent.indexOf("<a", index)) != -1)
{
if ((index = lowerCaseContent.indexOf("href", index)) == -1)
break;
if ((index = lowerCaseContent.indexOf("=", index)) == -1)
break;
if (Thread.currentThread() != searchThread)
break;
index++;
String remaining = content.substring(index);
StringTokenizer st
= new StringTokenizer(remaining, "\t\n\r\">#");
String strLink = st.nextToken();
URL urlLink;
try {
urlLink = new URL(url, strLink);
strLink = urlLink.toString();
} catch (MalformedURLException e) {
setStatus("ERROR: bad URL " + strLink);
continue;
}
if (urlLink.getProtocol().compareTo("http") != 0)
break;
if (Thread.currentThread() != searchThread)
break;
try {
URLConnection urlLinkConnection
= urlLink.openConnection();
urlLinkConnection.setAllowUserInteraction(false);
InputStream linkStream = urlLink.openStream();
String strType
= urlLinkConnection.guessContentTypeFromStream(linkStream);
linkStream.close();
if (strType == null)
break;
if (strType.compareTo("text/html") == 0) {
if ((!vectorSearched.contains(strLink))
&& (!vectorToSearch.contains(strLink))) {
if (robotSafe(urlLink))
vectorToSearch.addElement(strLink);
}
}
if (strType.compareTo(strTargetType) == 0) {
if (vectorMatches.contains(strLink) == false) {
listMatches.add(strLink);
vectorMatches.addElement(strLink);
numberFound++;
if (numberFound >= SEARCH_LIMIT)
break;
}
}
} catch (IOException e) {
setStatus("ERROR: couldn't open URL " + strLink);
continue;
}
}
} catch (IOException e) {
setStatus("ERROR: couldn't open URL " + strURL);
break;
}
numberSearched++;
if (numberSearched >= SEARCH_LIMIT)
break;
}
if (numberSearched >= SEARCH_LIMIT || numberFound >= SEARCH_LIMIT)
setStatus("reached search limit of " + SEARCH_LIMIT);
else
setStatus("done");
searchThread = null;
}
void setStatus(String status) {
labelStatus.setText(status);
}
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.compareTo(SEARCH) == 0) {
setStatus("searching...");
if (searchThread == null) {
searchThread = new Thread(this);
}
searchThread.start();
}
else if (command.compareTo(STOP) == 0) {
stop();
}
}
public static void main (String argv[])
{
Frame f = new Frame("WebFrame");
WebCrawler applet = new WebCrawler();
f.add("Center", applet);
Properties props= new Properties(System.getProperties());
props.put("http.proxySet", "true");
props.put("http.proxyHost", "webcache-cup");
props.put("http.proxyPort", "8080");
Properties newprops = new Properties(props);
System.setProperties(newprops);
applet.init();
applet.start();
f.pack();
f.show();
}
}
But when i run it, and enter any URL it shows Following error in Cmd
Exception in thread "AWT-EventQueue-1" java.lang.IllegalThreadStateExcepti
at java.lang.Thread.start(Thread.java:571)
at WebCrawler.actionPerformed(WebCrawler.java:388)
at java.awt.Button.processActionEvent(Button.java:388)
at java.awt.Button.processEvent(Button.java:356)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDisp
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispat
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.jav
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.jav
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Please look at it...please tell what i need to do in it....
and what i need to edit in this Code of webcrawler
Properties props= new Properties(System.getProperties());
props.put("http.proxySet", "true");
props.put("http.proxyHost", "webcache-cup");
props.put("http.proxyPort", "8080");
Please help me out....
Please help.....
|
|
|
|
|
This is far too much code for anyone to read through. Please identifiy the line of code where the error occurs and post only the small amount of code near that line. Have you looked at the documentation to see what an IllegalThreadStateException is, and what may be its causes?
|
|
|
|
|
public static void main (String argv[])
{
Frame f = new Frame("WebFrame");
WebCrawler applet = new WebCrawler();
f.add("Center", applet);
Properties props= new Properties(System.getProperties());
props.put("http.proxySet", "true");
props.put("http.proxyHost", "webcache-cup");
props.put("http.proxyPort", "8080");
Properties newprops = new Properties(props);
System.setProperties(newprops);
applet.init();
applet.start();
f.pack();
f.show();
}
}
Ok ..just look at this MAIN
is there something needed to be done at
Properties prop=new Properties(System.getProperties());
Please compile it at your side ....and look at error..
there are some errors which i cannot explain...
please just once run it at your side...and put the inputs
and see what is that i am missing....
Please help me...
|
|
|
|
|
sangeeta2009 wrote: Please compile it at your side ....and look at error..
Well once I had commented out all the irrelevant code I could not see anything wrong; it compiles and runs. However, I don't see what this has to do with your original problem which as I recall, was some sort of ThreadException. My only suggestion is that you use whatever debug tools you have and try to step through your code. Assuming you wrote this code in the first place you should be able to extract small parts of it to test in isolation until you can at least narrow it down to a specific area of code.
|
|
|
|
|
Richard MacCutchan wrote: Assuming you wrote this code in the first place [...]
#wistles#
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Someone must have written it!
|
|
|
|
|
Ok if Possible please help me out...
I have run that code without any compilation error...
But when i input the url int the first Text box..
say: http://java.sun.com
in command prompt it give me errors..and doesn't display me any
of the Url's related to that site..
Hope you get it...Please help and see if that works on your side...
And please all other guys..stop commenting about the code....
I haven't written that code, i have taken it form Sun.com
So if Somebody is interested in helping someone whose is in need...
|
|
|
|
|
sangeeta2009 wrote: I haven't written that code, i have taken it form Sun.com
Well I suggest you go back to Sun and ask them to fix it. I don't have the skills to work on a piece of code this complex, and as you haven't written it yourself I doubt that you have much understanding of it either.
|
|
|
|
|
Ohhh..!!!
That means you cannot help ..except fake posting...
If i will be knowing that...it will be better that
i will not be here..asking for help!!!
well thanks for time wasting...
|
|
|
|
|
sangeeta2009 wrote: That means you cannot help ..except fake posting.
On the contrary, I have tried to help, but you seem incapable of doing anything for yourself, even answering a simple question.
sangeeta2009 wrote: well thanks for time wasting
Yes, I am sorry that I have wasted my time trying to assist you. I thought you were a serious programmer who wanted to learn something. Obviously I was mistaken.
|
|
|
|
|
Please can somebody help me to find the source code for creating a routing table in java.. i googled but couldn't find anything useful there..
|
|
|
|
|
vidzdas wrote: i googled but couldn't find anything useful there..
I googled and found lots of examples; why do think they are not useful?
|
|
|
|
|
They do not describe how these tables are implemented. It only describes the nature of these tables..
|
|
|
|
|
|
Thanks a lot..
I think this should solve my problem.
I'l keep u updated..
|
|
|
|
|
Hi
Can anyone send a sample code to serialize & deserialize excel file?
Thanks in Advance.
|
|
|
|