Ana Mihailescu

Greenhorn
+ Follow
since Apr 26, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ana Mihailescu

Hello all,
I am using a JTable to display some data, and
I need that the first column to be not movable/draggable (to keep its first position). Please note that the other columns have to be movable, so the solution with
JTableHeader - setReorderingAllowed(boolean) is not suitable for my case.
I was thinking to make my own TableColumnModel,
but I don't know at all if it is a good idea.
Any sugestion will be very appreciated :-)
Thank you,
Ana
19 years ago
If I have right understood your problem , the solution is to set the 'Mnemonic' for your JButtons.
for example :
javax.swing.JButton button;
button.setText("abcdefg");
button.setMnemonic('c');
The result is that the 'c'letter on your button is underlined and
the actions that are triggered by a click on the button will be triggered in the same way by ALT - c from the keyboard
20 years ago
Try this, and you will have a default dialog to choose the size of the paper ...
PrinterJob printerJob=PrinterJob.getPrinterJob();

PageFormat format=new PageFormat();
format=printerJob.pageDialog(format);

Book book=new Book();
book.append(new TestPrint(), format);

printerJob.setPageable(book);

boolean doPrint=printerJob.printDialog();
if (doPrint) {
try {
printerJob.print();
} catch(PrinterException printerExc){}
}
20 years ago
This example is part of an applet. If the "conex" button is pressed, it opens a new browser window, for the given url.
public void actionPerformed(ActionEvent e)
{
String comanda=e.getActionCommand();
if (comanda.equals("conex"))
{
String address=t.getText();
// eg. http://www.altavista.com

try {
URL url = new URL(address);
AppletContext context = getAppletContext();
context.showDocument(url);
} catch(MalformedURLException exc)
{ System.out.println("URL wrong !!!\n"); }
}
}
20 years ago
Hi all,
I have a strage problem with a look and feel.
I have my own look and feel class, and when I update de UI for a tabbed pane component, I get very strange exceptions. The most strage thing is that a long time worked, and now doesn't work anymore.
Here is the piece of code where I change the look and feel:
try {
com.ls.treasury.ChatLookAndFeel.ChatLookAndFeel otto= new com.ls.treasury.ChatLookAndFeel.ChatLookAndFeel();
UIManager.setLookAndFeel(otto);
jTabbedPane1.updateUI();

} catch (Exception ex) {
System.err.println ("Could not swap LookAndFeel: ChatLNF");
ex.printStackTrace();
}
And this is the error that I get in the Java Console:
UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JTabbedPane[,10,20,500x320,layout=javax.swing.plaf.metal.MetalTabbedPaneUI$TabbedPaneLayout,alignmentX=null,alignmentY=null,border=,flags=1408,maximumSize=,minimumSize= ,preferredSize=,haveRegistered=false,tabPlacement=TOP]
java.lang.Error
at javax.swing.UIDefaults.getUIError(Unknown Source)
at javax.swing.UIDefaults.getUI(Unknown Source)
at javax.swing.UIManager.getUI(Unknown Source)
at javax.swing.JTabbedPane.updateUI(Unknown Source)
at com.ls.treasury.applets.ChatFrame.<init>(ChatFrame.java:167)
What could it be ? Please help !
20 years ago
Hi,
I have the following problem:
I have more JButtons and I want them to have a different color when are pressed. For this, I do
UIManager.put("Button.select",java.awt.Color.red);
buton1.updateUI();
and it works if I want the same color for all the buttons.
But if I try to change the color and to make updateUI() for a second button, it changes also the color for the first button.
So, what can I do if I want to have different colors for differnt buttons whent they are selected ?
Thank you,
Ana
20 years ago
Yes, Nitin is right...
Now, you add the focus listener to the dialog, and when you press the button and loose the focus on the dialog, it is received back immediately.
But what I don't understand in your code , is why the parent frame of your dialog is a new Frame("frame");
It could be "this", because also "this" is a frame. Why it is the need to create a new frame... ?
Ana
20 years ago
Well, as I know, an HTML file has a well defined structure, with
<html>, <head>, <body> , etc tags...
If you append somenthig at the end, you destroy this structure,
isn't it? Maybe you want to append in the body of the html text,
but anyway , I don't know how...
Ana
20 years ago
I just post a response (including code ) about this in Gary Bryan's question "html text in JTextPane"
:-)
20 years ago
What do you say about some tool tips ?
:-)
20 years ago
Hi,
I can give you an example with JEditorPane.
You will have an html file which will be displayed in the Pane.
Take care that the class has to implement HiperlinkListener interface, and also Runnable
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import java.util.*;
import java.text.*;
import java.applet.*;
import java.net.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.table.*;
import javax.swing.event.*;
import javax.mail.*;
import javax.mail.internet.*;
public class Help extends JFrame implements WindowListener,HyperlinkListener, Runnable
{
JEditorPane htmlArea=null;
JScrollPane scrollPane;
URL url;
Cursor cursor=null;

public Help()
{
super("Help");
this.setIconImage((new ImageIcon("middle.gif")).getImage());
this.getContentPane().setLayout(new BorderLayout());

try{
htmlArea = new JEditorPane();
url=new URL("file:///e:/An4/Posta/help.html");
htmlArea.setEditorKit(htmlArea.getEditorKitForContentType("html"));
htmlArea.setPage(url);
htmlArea.setEditable(false);
htmlArea.addHyperlinkListener(this);
}
catch( Exception e4){System.out.println(e4.getMessage());};

scrollPane = new JScrollPane(htmlArea);
this.getContentPane().add(scrollPane,BorderLayout.CENTER);
this.addWindowListener(this);
this.pack();
this.setSize(500,400);this.setResizable(false);
this.show();
}

public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
linkActivated(e.getURL());
}
}

protected void linkActivated(URL u)
{
Cursor c = htmlArea.getCursor();
Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
htmlArea.setCursor(waitCursor);
this.url = u;
this.cursor = c;
SwingUtilities.invokeLater(this);
}

public void run()
{
if (url == null)
{
htmlArea.setCursor(cursor);
Container parent = htmlArea.getParent();
parent.repaint();
}
else
{
Document doc = htmlArea.getDocument();
try
{
htmlArea.setPage(url);
}
catch (IOException ioe){
htmlArea.setDocument(doc);
getToolkit().beep();
}
finally
{
url = null;
SwingUtilities.invokeLater(this);
}
}
}
} // class Help
20 years ago
Hi ,
I tryed a similar example and it works ! I put Integer instead of
ImageIcon to be more simple. Have a look:
public class TestData {
private Integer theIcon = null;
public Integer getIcon() {
return theIcon;
}
public static void main(String [] a){

TestData tempData = new TestData();
System.out.println("ICON: "+tempData.getIcon());
if (tempData.getIcon()==null){
System.out.println("Am I even getting here?");
}
}
}
20 years ago
Hi Tom,
As I have understood , Java Mail is usefull to program mail clients; It helps you to connect a pop3, imap host and to read/send email using this protocols.
If you want to have a mail server you should have a look to pop3,
imap, smtp protocols, for example at RFC page:
for SMTP http://www.faqs.org/rfcs/rfc821.html
for pop3 http://www.faqs.org/rfcs/std/std53.html
Again, as I understand , your server should implement such protocols...
20 years ago
Only a suggestion:
Why not JavaTM Speech ?
And keep us informed about this project :-)
20 years ago