Help coderanch get a
new server
by contributing to the fundraiser

Syed Usman

Greenhorn
+ Follow
since Dec 10, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Syed Usman

Hello,
I am creating an application and using swings to change the font of selected text.... using JTextPane i was able to change the font of normal text but i am not able to change font of selected text. consider the following code
////////////////////////
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
public class Multi {
static JFrame frame;
static JMenuBar mbr;
static JToolBar tb;
static JButton b1;
static JMenu mnu;
static JMenuItem mni;
static Container content;
static JTextPane pane;
static SimpleAttributeSet set;
static Document doc;
static Choice fontlist;
static Toolkit tkit;
public static void main(String args[]) {
frame = new JFrame("Multiattributed text");
mbr=new JMenuBar();
tb=new JToolBar();
tb.setLayout(new GridLayout(1,2));
tkit=Toolkit.getDefaultToolkit();
b1=new JButton("Hello");
fontlist=new Choice();
tb.add(b1);
tb.add(fontlist);
tb.add(b1);
String names[]=tkit.getFontList();
for (int i=0;i<names.length;i++)
{
fontlist.addItem(names[i]);
System.out.println(names[i]);
}
mnu=new JMenu("File");
mni=new JMenuItem("New");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
content = frame.getContentPane();
pane = new JTextPane();
set = new SimpleAttributeSet();
set.addAttribute(StyleConstants.CharacterConstants.Bold,Boolean.TRUE);
// Initialize attributes before adding text
pane.setCharacterAttributes(set, true);
pane.setText("Three");
set = new SimpleAttributeSet();
StyleConstants.setItalic(set, true);
doc = pane.getStyledDocument();
try {
doc.insertString(doc.getLength(),"Blind", set);
} catch (BadLocationException e) {
System.err.println("Bad location");
return;
}
set = new SimpleAttributeSet();
StyleConstants.setFontSize(set, 48);

try {
doc.insertString(doc.getLength(), "Mice", set);
} catch (BadLocationException e) {
System.err.println("Bad location");
return;
}
JScrollPane scrollPane = new JScrollPane(pane);
content.add(scrollPane, BorderLayout.CENTER);
content.add(tb,BorderLayout.NORTH);
mnu.add(mni);
mbr.add(mnu);
frame.setJMenuBar(mbr);
frame.setSize(300, 200);
frame.show();
}
}
///////////////////////////
this code will only change the font of fixed text "Blink" and "Mice" but i am not able to change font of selected text.. as i have not functions of getSelectionStart and getSelectionEnd in JTextPane here ......

Can u guide me about it....
thanks...
21 years ago
Hello I am Usman,
I am working with JDBC and want to create Reports, is it possible to create reports using crystal reports using Java. I want basically custom reports.
If it is possible then how can i do this...
plz Tell me ...
it's urgent...
Thnaks
usman
Hello I am Usman, I am working in JSP,
I want to send SMS using java. can u tell me how to do this using java, which api will solve my problem. because JMF is not solving my problem.
And Also how i will start with....
Thanks....
22 years ago
Hello I am Usman,
I have a problem concerning ORDBMS using Java,
we have concept of nested tables in ORDBMS. through which we can create tables within tables. Can you tell me how we will update, delete, insert records into these type of tables. and also how ResultSet manages these type of tables .
How we can view, query these tables.
Thanks.....
Hello I am Usman,
I Read your problem,
It will be clear to me when I will see your code
can you mail me the code...
So I will be able to run it on my network..
and read it's problems...
Thanks
22 years ago
Hello I am using Swings and developing an editor.
I am getting a problem that I want to change the color of my Selected Text, either I use Swings JEditorKit or TextArea. The problem is only how to do this..
Can you solve this problem..
Thanks...
Syed Usman
------------------
Spacefiller
22 years ago