Different footer for every package or for every classes
Hi!
1.How can I specify in javadoc that I want a different footer for every package or for every classes?
2.how can I told to javadoc that I have external library used in my project (for providing javadoc comments for for these libraries )?
I used an ant build file for generating javadoc API documentation for my packages.
Thanks,
Florin.
1. Specifying a different footer for every package or class is not available
(unless you modify the standard doclet).
2. To generate documentation for external libraries, you must first have the
source code to the external libraries. Then simply pass in the package names,
using -classpath to point to them.
You can also use -link to link to previously-generated javadoc documentation.
-Doug Kramer
Javadoc team
Similar Messages
-
TestStand create different object for singleton class
Hi all,
we have a singleton class which has some functions used to do testing a harware.
Our main Exe will create an object for that singleton class(which opens Com1 port and communicate with hardware). so the Exe will do basic communication test with hardware it is working well. We are using Teststand operator interface to do various testing by using sequence files. Main exe will use teststand usercontrols to execute tests when the user clicks Testbutton. after that, teststand try to create an object for that singleton but it returns new object not the existing one which is created by EXE. So it throwing me exeception "Com1 port access denied." (since we created object for signleton class @ very first in EXE)
My question is Since that teststand runs in a separate Appdoamin will the singltonclass create separate object for different appdomain? if so is there any solution to reslove this?
Hope i clearly explained my probs.
Thanks in advance
SriniHi Srini,
How are you calling the executable? From a Call Executable step? Or are you using another means of calling it? Also, why is TestStand trying to recreate the object? As long as you have the correct handle to the object I don't think it matters what app domain you are in.
Regards,
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~ -
Problems using different tables for base class and derived class
I have a class named SuperProject and another class Project derived from
it. If I let SchemaTool generate the tables without specifying a "table"
extension, I get a single TABLE with all the columns from both classes and
everything works fine. But if I specify a "table" for the derived class,
SchemaTool generates the derived class with just one column (corresponds
to the attribute in derived class). Also it causes problems in using the
Project class in collection attributes.
JDO file:
<jdo>
<package name="jdo">
<class name="Project" identity-type="application"
persistence-capable-superclass="SuperProject">
<extension vendor-name="kodo" key="table" value="PROJECT"/>
</class>
<class name="SuperProject" identity-type="application"
objectid-class="ProjectId">
<field name="id" primary-key="true"/>
</class>
</package>
</jdo>
java classes:
public class Project extends SuperProject
String projectSpecific
public class SuperProject
BigDecimal id;
String name;
tables generated by SchemaTool:
TABLE SUPERPROJECTSX (IDX, JDOCLASSX, JDOLOCKX, NAMEX);
TABLE PROJECT(PROJECTSPECIFICX)
Thanks,
Justine ThomasJustine,
This will be resolved in 2.3.4, to be released later this evening.
-Patrick
In article <aofo2q$mih$[email protected]>, Justine Thomas wrote:
I have a class named SuperProject and another class Project derived from
it. If I let SchemaTool generate the tables without specifying a "table"
extension, I get a single TABLE with all the columns from both classes and
everything works fine. But if I specify a "table" for the derived class,
SchemaTool generates the derived class with just one column (corresponds
to the attribute in derived class). Also it causes problems in using the
Project class in collection attributes.
JDO file:
<jdo>
<package name="jdo">
<class name="Project" identity-type="application"
persistence-capable-superclass="SuperProject">
<extension vendor-name="kodo" key="table" value="PROJECT"/>
</class>
<class name="SuperProject" identity-type="application"
objectid-class="ProjectId">
<field name="id" primary-key="true"/>
</class>
</package>
</jdo>
java classes:
public class Project extends SuperProject
String projectSpecific
public class SuperProject
BigDecimal id;
String name;
tables generated by SchemaTool:
TABLE SUPERPROJECTSX (IDX, JDOCLASSX, JDOLOCKX, NAMEX);
TABLE PROJECT(PROJECTSPECIFICX)
Thanks,
Justine Thomas
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Hi
I have an issue in setting a different footer for different pages. I have total 6 pages and 2 master pages.
I need to set a footer for 1st page and that footer should not be appear in 2nd page onwadrs.
2nd page onwards a new footer has to be displayed which is set in master page2.
I tried with pagination options. In page1, I have set "If Dataset Must be paginated" to "Go to Content area2". Is this correct?
Can somebody help me?Hi,
One quick way would be to limit the occurance of Master Page Page1" to 1. See Object > Master Page palette and tick Restrict Page Occurence and tick Max = 1.
Niall -
Different content for a row popin in every row
HI,
is it possible to have a different content for a row popin in every different row?
For example: In Row 1 I have a ViewContainerUIElement containing View A, in Row 2 I have a ViewContainerUIElement containing View B...
This is what I need, different views in every row...
Is this somehow possible?
Best regards,
PeterOK than. Have you think about one view which will be in your table popin, but each element in this view will be created dynamically? Than you will get the look as there are different views, different design for each row, but it will be the same view.
-
Purchasing info records with different prices for different packaging
Hi,
hope, someone can help me.
We have different prices for different kind of packaging, but all the material is bought in the same unit, i.e. kg.
Let's say, usually you buy x kg in a drum, but sometimes you buy y (or x) kg in a bottle or in a bag.
We won't allow variable order units. Even if we would, it's not helpful, because we always order kg.
So the price depends on a criterion - I don't know, which to take. And we want to maintain the different prices in the info records.
Is there a solution?Hi.
I went through the history of the problem.It seems that your base unit of measure is KG.Also you have mentined that same material is used in various plants.
You need to activate the variable ordering unit 2 in material master. This is present in the materila master Purchasing tab.Also note that this data is maintained at plant level. This will not have any impact on the materials which are presnt in the other plants.
After activating variable order unit in materal master. You need maintains the conversion factors from Order units to Base UOM.(Eg 1 KG = 1 KG, 1BOX = 10 KG etc)
Create inforecord for the material and maintain price in Base unit of measure.
In PO enter the order unit as BOX system will automatically calculate the price of BOX based on the conversion factors which are maintained in the material master.
I belive this is the simple and best solution for your requirement..
If you have any suggestions please let me know
Cheers
Umakanth -
Example codes for each and every class in API
hi,
Is there any place where i can get example code for eacha and every class in java API.
for eample...if i wanna find sample codes for all the clases in java.lang.*
please let me know ASAP.
thanks in advanceTry this
http://www.javaalmanac.com/egs/
It's almost complete, but you could help mr. Patrick Chan to write more samples for the few classes left in the Java API... -
Example code for each and every class in java API
hi,
Is there any place where i can get example code for eacha and every class in java API.
for eample...if i wanna find sample codes for all the clases in java.lang.*
please let me know ASAP.
thanks in advanceCrossposted here: http://forum.java.sun.com/thread.jsp?thread=570264&forum=54&message=2820774
-
Different links for different forms of the same list.
Greetings,
I have a custom list created with several columns one of which is the Title column. I have created three different views for this list.
Using SharePoint Designer 2013 I have created three separate forms, one is a custom new for, a custom edit form and a custom display form. For specific reasons, I have not setup these forms as default.
I'd like to change the URL of the Title column depending on the view.
For example, if I am on View1 and click on the Title column, then I should see the custom display form I have built. In short, I want a way to manually change the url of the Title column.
I plan on creating several other forms for this same list and hence I need to know how I can change the URL of the Title column to match the need of the workflow.
Thanks in advance.
Daniel Christian (MCTS)May be you can achieve it using different java scipt for different views:
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d7083056-594b-45b4-9fd4-9d615cdf5875/how-to-change-link-of-list-items-title-in-sharepoint-custom-list-by-programmatically-on-sharepoint?forum=appsforsharepoint
However another suggest is that you create multiple title column with different links. every view will have a different title column so it can achieved. -
What are the different steps for costing related to repetitive manufacturi
Hi PP guys
can any one explain the different steps for costing in repetitive scenario as compared to discrete scenario what is the major difference
thanks
shaikDear Michel,
!.In REM scenario Product cost collector is required for all the products for which production booking is
to be done.
2.For each production version created a product cost collector will be created in KKF6N.
3.Without a product cost collector production confirmation can not be done in MFBF.
4.Product cost collector is the cost object in REM scenario.
5.Once after creating material master,BOM,work center,rate routing,aproduction version the next steps
is creating product cost collector.
6.While creating the PCC,the system creates a preliminary cost estimate nothing bu the sum up of the
BOM and dare routing cost.
7.Either a prelimnary cost or a standard cost estimate can be used for doing the production
confirmation in MFBF as per the REM profile assigned.
8.Standard cost estimate can be done in CK40N and this costs gets updated in the material master.
9.For every production confirmation made in MFBF the costs gets accumulated in the respective PCC.
10.the variances can be settled periodically as per the business requirement.
Regards
Mangalraj.S -
Different formats for each line in enums & rings?
I don't know if this one is possible but I can't figure it out.
Can you make an enum or ring control have a different format for each selection?
E.G.:
Selection 1 [default]
Selection 2 [test mode]
Selection 3 [optional]
Selection 4 [optional]
I've tried the formatting options and property nodes, no luck. Maybe there are possibilities with control customizing I'm not thinking of???
Thanks & Regards,
K
Using LabVIEW: 7.1.1, 8.5.1 & 2013Hi K.
I don't think it's possible to have those text properties vary in a text-ring, but you might be able to accomplish your goal using a pict-ring - using images of formatted text. In the example (attached) Paint was used to create the pictures then import them into the pict-ring. Here Unclebump shows how to use "Draw Text at Point.vi" to create formatted text in a picture control, though, I have no idea how to copy such pictures out of the pictures control!
Cheers!
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Attachments:
FormattedTextPicRing.vi 14 KB -
Messagebox that displays a different randum number every 2 secs
well im having trouble with putting a messagebox that displays a different randum number every 2 secs and closes with a close button. it goes in the print menu option of this simple text editor,you shoud also be able to work in the background while this message box is been displayed.
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.undo.*;
import java.util.Timer;
import java.util.TimerTask;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.beans.*;
-------------------| Simple Text Editor example application using Java 1.3 with Swing |--------------
public class SimpleTextEditor extends JFrame
private JTextPane textpane;
private JMenuBar mb;
private JFileChooser chooser,picChooser;
private Hashtable actions;
private JPopupMenu popup;
private JMenuItem exit, newDoc, save, open, saveAs,print;
private About ab;
private StyledEditorKit edkit;
private RTFEditorKit rtfkit;
private DefaultStyledDocument doc;
private MyDocumentListener doclistener;
private MyUndoableEditListener undolistener;
//Useful variables
private String filename="untitled1.txt",filetype=".txt";
private File thisfile;
protected String FileFormats[],FileDescriptions[],PicFileFormats[],PicFileDescriptions[];
protected boolean DocumentIsUnedited=true, DocumentIsSaved=false;
public static int SQUARE=0,TRIANGLE=1,CIRCLE=2;
public String newline="\n";
protected UndoManager undo ;
protected UndoAction undoAction;
protected RedoAction redoAction;
// These are the actions used in the menus and on the toolbar
protected Action bold, italic, underline, alignleft, alignright, aligncentre;
protected Action spellchecker, alignjustify, more, cut, copy, paste, tools[];
public SimpleTextEditor()
super("SimpleTextEditor - untitled1.rtf");
this.setLocation(200,200);
this.setIconImage(getMyIcon("Icon.gif").getImage());
getContentPane().setLayout(new BorderLayout());
undo = new UndoManager();
//Set up the file formats and file choosers etc
FileFormats = new String[]{".rtf",".txt",".java",".bat"};
FileDescriptions = new String[]{"Rich Text Format Files","Text Files","Java Source Files","DOS Batch Files"};
PicFileFormats = new String[]{".gif",".bmp",".jpg"};
PicFileDescriptions = new String[]{"Gif Images","Bitmap Images","JPEG Images"};
chooser = new JFileChooser();
picChooser = new JFileChooser();
picChooser.setAccessory(new ImagePreview(picChooser));
javax.swing.filechooser.FileFilter defaultFilter = new SimpleFilter(FileFormats[0],FileDescriptions[0]);
javax.swing.filechooser.FileFilter defaultPicFilter = new SimpleFilter(PicFileFormats[0],PicFileDescriptions[0]);
for(int i=1;i<FileFormats.length;i++){
chooser.addChoosableFileFilter(new SimpleFilter(FileFormats,FileDescriptions[i]));
for(int i=1;i<PicFileFormats.length;i++){
picChooser.addChoosableFileFilter(new SimpleFilter(PicFileFormats[i],PicFileDescriptions[i]));
chooser.setFileFilter(defaultFilter);
picChooser.setFileFilter(defaultPicFilter);
File working = new File("C:/Documents");
if(!working.exists()){
working= new File("C:/MyDocuments");
if(!working.exists()) working = new File("C:/");
if(working.exists()) {
chooser.setCurrentDirectory(working);
picChooser.setCurrentDirectory(working);
// Set up Document object and Editor kits
doc = new DefaultStyledDocument();
edkit = new StyledEditorKit();
rtfkit = new RTFEditorKit();
// Set up Listener objects
doclistener= new MyDocumentListener();
undolistener= new MyUndoableEditListener();
doc.addDocumentListener(doclistener);
doc.addUndoableEditListener(undolistener);
//Set up main GUI content
textpane=new JTextPane(doc);
textpane.setPreferredSize(new Dimension(400,400));
textpane.setMinimumSize(new Dimension(400,400));
JScrollPane scroller=new JScrollPane(textpane);
scroller.setPreferredSize(new Dimension(400,400));
mb=new JMenuBar(); // Create a menu bar
JMenu File=new JMenu("File");
JMenu Help=new JMenu("Help");
//Sort out Actions etc
createActionTable(textpane);
createToolbarActions();
JMenu Style=createStyleMenu();
undoAction = new UndoAction();
redoAction = new RedoAction();
//Create Style, Edit and Format menus + Toolbar
JMenu Edit=createEditMenu();
JMenu Format=createFormatMenu();
JMenu Insert = createInsertMenu();
JToolBar toolbar = createToolbar();
getContentPane().add("North",toolbar);
// set up main menu items with ActionListeners
newDoc=new JMenuItem("New");
newDoc.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
newDoc();
exit=new JMenuItem("Exit");
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
exit();
print=new JMenuItem("Print");
print.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
print();
save=new JMenuItem("Save");
save.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
save();
saveAs=new JMenuItem("Save As...");
saveAs.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
saveas();
open=new JMenuItem("Open...");
open.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
open();
JMenuItem about=new JMenuItem("About");
about.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
ab=new About(SimpleTextEditor.this);
ab.show();
ab.setLocation(400,300);
// Create the popup menu
popup = createEditMenu().getPopupMenu();
popup.addSeparator();
popup.add(createStyleMenu());
popup.add(createFormatMenu());
textpane.add(popup);
// set up Help and File menus
Help.add(about);
File.add(newDoc);
File.add(open);
File.add(print);
File.add(save);
File.add(saveAs);
File.addSeparator();
File.add(exit);
// add the menus to the menubar
mb.add(File);
mb.add(Edit);
mb.add(Format);
mb.add(Style);
mb.add(Insert);
mb.add(Help);
this.setJMenuBar(mb);
getContentPane().add("Center",scroller);
// Add mouse Listener to the textpane for popup events
textpane.addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent e)
if(e.isPopupTrigger())
popup.show(textpane, e.getX(), e.getY());
e.consume();
public void mouseReleased(MouseEvent e)
if(e.isPopupTrigger())
popup.show(textpane, e.getX(), e.getY());
e.consume();
//-----------------| Main active methods |------------------
public void exit()// Main Exit method
if(DocumentIsUnedited){//Check that document is saved/unedited etc
dispose();
setVisible(false);
System.exit(0);
else{
switch(showNotSavedDialog("Exit")){
case JOptionPane.YES_OPTION: save(); exit(); break;
case JOptionPane.NO_OPTION: DocumentIsUnedited=true;exit();break;
case JOptionPane.CANCEL_OPTION: break;
public void newDoc()//Method to create new documents
if(DocumentIsUnedited){
initDoc();
filename="untitled.txt";
filetype=".txt";
resetTitle();
else
switch(showNotSavedDialog("New Document")){
case JOptionPane.YES_OPTION: save(); newDoc(); break;
case JOptionPane.NO_OPTION: DocumentIsUnedited=true;newDoc();break;
case JOptionPane.CANCEL_OPTION: break;
private void initDoc()// Helper method to initialize a new document
doc = null;
doc = (DefaultStyledDocument)edkit.createDefaultDocument();
doc.addDocumentListener(doclistener);
textpane.setStyledDocument(doc);
public void print()
new TimerTestFrame();
class TimerTestFrame extends JFrame
Timer timer;
TimerTestFrame()
super();
timer = new Timer(true);
TimerTask task = new MessageTimer(TimerTestFrame.this);
timer.schedule(task,2000,2000);
class MessageTimer extends TimerTask
Component parent;
public MessageTimer(Component parent)
this.parent = parent;
public void run()
int randnum = (1 +(int)(Math.random()*10));
JOptionPane.showMessageDialog(parent,""+randnum,"Timer Message",JOptionPane.INFORMATION_MESSAGE);
public void saveas()
int n = chooser.showSaveDialog(this);
if(n==0){
filename=chooser.getSelectedFile().getName();
boolean ext = false;
setFiletype();
thisfile = new File(chooser.getCurrentDirectory(),filename);
DocumentIsSaved=true;
save();
resetTitle();
repaint();
public void save()// Save method. Used by "Save As..." as well
if( DocumentIsSaved)
try
FileOutputStream out = new FileOutputStream(thisfile);
if((filetype.equals(".rtf"))||(filetype.equals(".doc"))){
rtfkit.write(out,doc,0,doc.getLength());
else edkit.write(out,doc,0,doc.getLength());
catch(Exception e)
System.out.println(""+e.getMessage()+"");
DocumentIsUnedited=true;
else saveas();
public void open()// Find a file and read it into the document
if(DocumentIsUnedited){
int n = chooser.showOpenDialog(this); // get the outcome of the dialog
if(n==0){
File file = chooser.getSelectedFile();
filename=chooser.getName(file);
setFiletype();
resetTitle();
initDoc();
try
FileInputStream in= new FileInputStream(file);
if(filetype.equals(".rtf")){
rtfkit.read(in,doc,0);
edkit.read(in,doc,0);
catch(Exception e)
System.out.println(""+e.getMessage()+"");
thisfile= new File(chooser.getCurrentDirectory(),chooser.getSelectedFile().getName());
DocumentIsUnedited=true;
DocumentIsSaved=true;
resetTitle();
repaint();
else
switch(showNotSavedDialog("Open")){
case JOptionPane.YES_OPTION: save(); open(); break;
case JOptionPane.NO_OPTION: DocumentIsUnedited=true; open(); break;
case JOptionPane.CANCEL_OPTION: break;
private void setFiletype()// Helper method to get the filetype of saved/opened documents
filetype=null;
for(int i=0;i<FileFormats.length;i++){
if(filename.toLowerCase().endsWith(FileFormats[i])) filetype = FileFormats[i];
else{
for(i=0;i<filename.length();i++){
if(filename.toLowerCase().charAt(i)=='.')
filetype=filename.substring(i);
if(filetype==null) filetype=".txt";
private void resetTitle()
this.setTitle("SimpleTextEditor - "+filename);
private ImageIcon getMyIcon(String filename){
ImageIcon pic = new ImageIcon("Images/"+filename);
return pic;
private int showNotSavedDialog(String title)// Helper method to create "Save? Yes/No/Cancel" dialogs
int n = JOptionPane.showConfirmDialog(this,"The last document has not been saved. \nDo you want to save it first?",
title,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
return n;
//-----------------| Listeners and Helper classes |----------------
protected class MyDocumentListener implements DocumentListener
public void insertUpdate(DocumentEvent e) {
SimpleTextEditor.this.DocumentIsUnedited=false;
public void removeUpdate(DocumentEvent e) {
SimpleTextEditor.this.DocumentIsUnedited=false;
public void changedUpdate(DocumentEvent e) {
SimpleTextEditor.this.DocumentIsUnedited=false;
protected class MyUndoableEditListener implements UndoableEditListener {
public void undoableEditHappened(UndoableEditEvent e) {
//Remember the edit and update the menus.
undo.addEdit(e.getEdit());
undoAction.updateUndoState();
redoAction.updateRedoState();
//Helper class for FileFilter, allows a description to be assigned to a filetype
protected class SimpleFilter extends javax.swing.filechooser.FileFilter
String type,des;
public SimpleFilter(String type, String des)
this.des=des;
this.type=type;
public boolean accept(File f){
if(f.isDirectory())return true;
else{
if(f.getName().toLowerCase().endsWith(type)) return true;
else return false;
public String getDescription(){
return des;
//------------| Methods to help create menus and toolbar |--------------
protected JMenu createStyleMenu()
JMenu menu = new JMenu("Style");
menu.add(bold);
menu.add(italic);
menu.add(underline);
menu.addSeparator();
menu.add(new StyledEditorKit.FontSizeAction("12", 12));
menu.add(new StyledEditorKit.FontSizeAction("14", 14));
menu.add(new StyledEditorKit.FontSizeAction("18", 18));
menu.addSeparator();
menu.add(new StyledEditorKit.FontFamilyAction("Serif","Serif"));
menu.add(new StyledEditorKit.FontFamilyAction("SansSerif","SansSerif"));
menu.addSeparator();
Action red = new StyledEditorKit.ForegroundAction("Red", new Color(255,0,0));
red.putValue(Action.SMALL_ICON,getMyIcon("red.gif"));
menu.add(red);
Action green = new StyledEditorKit.ForegroundAction("Green", new Color(0,150,0));
green.putValue(Action.SMALL_ICON,getMyIcon("green.gif"));
menu.add(green);
Action blue = new StyledEditorKit.ForegroundAction("Blue", new Color(0,50,150));
blue.putValue(Action.SMALL_ICON,getMyIcon("blue.gif"));
menu.add(blue);
Action black = new StyledEditorKit.ForegroundAction("Black", new Color(0,0,0));
black.putValue(Action.SMALL_ICON,getMyIcon("black.gif"));
menu.add(black);
menu.add(more);
return menu;
protected JMenu createEditMenu() {
JMenu menu = new JMenu("Edit");
menu.add(undoAction);
menu.add(redoAction);
menu.addSeparator();
menu.add(cut);
menu.add(copy);
menu.add(paste);
menu.addSeparator();
Action selectall=getActionByName(DefaultEditorKit.selectAllAction);
selectall.putValue(Action.NAME, "Select All");
menu.add(selectall);
return menu;
protected JMenu createFormatMenu(){
JMenu menu = new JMenu("Format");
menu.add(spellchecker);
menu.add(alignleft);
menu.add(alignright);
menu.add(aligncentre);
menu.add(alignjustify);
return menu;
protected JMenu createInsertMenu(){
JMenu menu = new JMenu("Insert");
Action insertimage = new InsertImageAction(this);
menu.add(insertimage);
Action insertdate = new InsertDateAction();
menu.add(insertdate);
Action insertline = new InsertLineAction();
menu.add(insertline);
JMenu bullets =new JMenu("Bullet Points");
bullets.add(new InsertBulletAction(CIRCLE,"Circle"));
bullets.add(new InsertBulletAction(TRIANGLE,"Triangle"));
bullets.add(new InsertBulletAction(SQUARE,"Square"));
menu.add(bullets);
return menu;
public JToolBar createToolbar(){
JToolBar bar= new JToolBar();
JButton newbutton=new JButton(getMyIcon("new.gif"));
newbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
newDoc();
bar.add(newbutton);
JButton savebutton=new JButton(getMyIcon("save.gif"));
savebutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
save();
bar.add(savebutton);
JButton openbutton=new JButton(getMyIcon("open.gif"));
openbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
open();
bar.add(openbutton);
bar.addSeparator();
for(int i=0;i<tools.length;i++){
JButton button=new JButton();
button.setAction(tools[i]);
button.setIcon(getMyIcon(tools[i].getValue(Action.NAME)+".gif"));
button.setText("");
bar.add(button);
if((i==2)||(i==6))bar.addSeparator();
return bar;
public void createToolbarActions(){
bold = new StyledEditorKit.BoldAction();
bold.putValue(Action.NAME, "Bold");
italic = new StyledEditorKit.ItalicAction();
italic.putValue(Action.NAME, "Italic");
underline = new StyledEditorKit.UnderlineAction();
underline.putValue(Action.NAME, "Underline");
more = new MoreColorsAction();
cut = getActionByName(DefaultEditorKit.cutAction);
cut.putValue(Action.NAME, "Cut");
copy = getActionByName(DefaultEditorKit.copyAction);
copy.putValue(Action.NAME, "Copy");
paste = getActionByName(DefaultEditorKit.pasteAction);
paste.putValue(Action.NAME, "Paste");
alignleft = new StyledEditorKit.AlignmentAction("Left Justify",StyleConstants.ALIGN_LEFT);
alignright = new StyledEditorKit.AlignmentAction("Right Justify",StyleConstants.ALIGN_RIGHT);
aligncentre = new StyledEditorKit.AlignmentAction("Align Centre",StyleConstants.ALIGN_CENTER);
alignjustify = new StyledEditorKit.AlignmentAction("Fully Justify",StyleConstants.ALIGN_JUSTIFIED);
spellchecker = new StyledEditorKit.AlignmentAction("Spell Checker",StyleConstants.ALIGN_JUSTIFIED);
tools = new Action[]{ cut, copy, paste, bold, italic, underline, more, alignleft, alignright, aligncentre, alignjustify, spellchecker };
// helper methods to enable menu creators to get their actions by name
private void createActionTable(JTextComponent textComponent) {
actions = new Hashtable();
Action[] actionsArray = textComponent.getActions();
for (int i = 0; i < actionsArray.length; i++) {
Action a = actionsArray[i];
actions.put(a.getValue(Action.NAME), a);
private Action getActionByName(String name) {
return (Action)(actions.get(name));
//----------------| Custom Actions |--------------------
class InsertImageAction extends AbstractAction {
protected SimpleTextEditor parent;
public InsertImageAction(SimpleTextEditor parent){
super("Image...");
this.parent=parent;
public void actionPerformed(ActionEvent e) {
int n = parent.picChooser.showOpenDialog(parent);
if(n==0){
String filename=picChooser.getSelectedFile().getName();
File file = new File(picChooser.getCurrentDirectory(),filename);
Icon pic = new ImageIcon(file.getAbsolutePath());
textpane.insertIcon(pic);
SimpleTextEditor.this.repaint();
class InsertDateAction extends AbstractAction {
public InsertDateAction(){
super("Date");
public void actionPerformed(ActionEvent ble) {
Calendar c= Calendar.getInstance();
String[] months= new String[]{"01","02","03","04","05","06","07","08","09","10","11","12"};
textpane.replaceSelection(c.get(c.DAY_OF_MONTH)+"/"+months[c.get(c.MONTH)]+"/"+c.get(c.YEAR));
class InsertLineAction extends AbstractAction {
public InsertLineAction(){
super("Horizontal line");
public void actionPerformed(ActionEvent e) {
Icon pic = new ImageIcon("Images/line.gif");
textpane.insertIcon(pic);
class InsertBulletAction extends AbstractAction {
protected int type;
protected String filenames[] = new String[]{"square.gif","triangle.gif","circle.gif"};
public InsertBulletAction(int type,String name){
super(name);
this.type=type;
this.putValue(SMALL_ICON,new ImageIcon("Images/"+filenames[type]));
public void actionPerformed(ActionEvent e) {
Icon pic = new ImageIcon("Images/"+filenames[type]);
textpane.insertIcon(pic);
textpane.replaceSelection(" ");
class MoreColorsAction extends AbstractAction {
public MoreColorsAction(){
super("More Colors");
public void actionPerformed(ActionEvent e){
AttributeSet as = textpane.getCharacterAttributes();
SimpleAttributeSet sas = new SimpleAttributeSet(as);
Color newColor = JColorChooser.showDialog(
SimpleTextEditor.this,
"CHere you go guys:
Peace!
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.border.BevelBorder;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.undo.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.beans.*;
-------------------| Simple Text Editor example application using Java 1.3 with Swing |--------------
public class SimpleTextEditor extends JFrame
private JTextPane textpane;
private JMenuBar mb;
private JFileChooser chooser,picChooser;
private Hashtable actions;
private JPopupMenu popup;
private JMenuItem exit, newDoc, save, open, saveAs,print;
private About ab;
private StyledEditorKit edkit;
private RTFEditorKit rtfkit;
private DefaultStyledDocument doc;
private MyDocumentListener doclistener;
private MyUndoableEditListener undolistener;
//Useful variables
private String filename = "untitled1.txt",filetype = ".txt";
private File thisfile;
protected String FileFormats[],FileDescriptions[],PicFileFormats[],PicFileDescriptions[];
protected boolean DocumentIsUnedited = true, DocumentIsSaved = false;
public static int SQUARE = 0,TRIANGLE = 1,CIRCLE = 2;
public String newline = "\n";
protected UndoManager undo;
protected UndoAction undoAction;
protected RedoAction redoAction;
// These are the actions used in the menus and on the toolbar
protected Action bold, italic, underline, alignleft, alignright, aligncentre;
protected Action spellchecker, alignjustify, more, cut, copy, paste, tools[];
public SimpleTextEditor()
super("SimpleTextEditor - untitled1.rtf");
this.setLocation(200, 200);
this.setIconImage(getMyIcon("Icon.gif").getImage());
getContentPane().setLayout(new BorderLayout());
undo = new UndoManager();
//Set up the file formats and file choosers etc
FileFormats = new String[]{".rtf", ".txt", ".java", ".bat"};
FileDescriptions = new String[]{"Rich Text Format Files", "Text Files", "Java Source Files", "DOS Batch Files"};
PicFileFormats = new String[]{".gif", ".bmp", ".jpg"};
PicFileDescriptions = new String[]{"Gif Images", "Bitmap Images", "JPEG Images"};
chooser = new JFileChooser();
picChooser = new JFileChooser();
picChooser.setAccessory(new ImagePreview(picChooser));
javax.swing.filechooser.FileFilter defaultFilter = new SimpleFilter(FileFormats[0], FileDescriptions[0]);
javax.swing.filechooser.FileFilter defaultPicFilter = new SimpleFilter(PicFileFormats[0], PicFileDescriptions[0]);
for (int i = 1; i < FileFormats.length; i++)
chooser.addChoosableFileFilter(new SimpleFilter(FileFormats, FileDescriptions[i]));
for (int i = 1; i < PicFileFormats.length; i++)
picChooser.addChoosableFileFilter(new SimpleFilter(PicFileFormats[i], PicFileDescriptions[i]));
chooser.setFileFilter(defaultFilter);
picChooser.setFileFilter(defaultPicFilter);
File working = new File("C:/Documents");
if (!working.exists())
working = new File("C:/MyDocuments");
if (!working.exists()) working = new File("C:/");
if (working.exists())
chooser.setCurrentDirectory(working);
picChooser.setCurrentDirectory(working);
// Set up Document object and Editor kits
doc = new DefaultStyledDocument();
edkit = new StyledEditorKit();
rtfkit = new RTFEditorKit();
// Set up Listener objects
doclistener = new MyDocumentListener();
undolistener = new MyUndoableEditListener();
doc.addDocumentListener(doclistener);
doc.addUndoableEditListener(undolistener);
//Set up main GUI content
textpane = new JTextPane(doc);
textpane.setPreferredSize(new Dimension(400, 400));
textpane.setMinimumSize(new Dimension(400, 400));
JScrollPane scroller = new JScrollPane(textpane);
scroller.setPreferredSize(new Dimension(400, 400));
mb = new JMenuBar(); // Create a menu bar
JMenu File = new JMenu("File");
JMenu Help = new JMenu("Help");
//Sort out Actions etc
createActionTable(textpane);
createToolbarActions();
JMenu Style = createStyleMenu();
undoAction = new UndoAction();
redoAction = new RedoAction();
//Create Style, Edit and Format menus + Toolbar
JMenu Edit = createEditMenu();
JMenu Format = createFormatMenu();
JMenu Insert = createInsertMenu();
JToolBar toolbar = createToolbar();
getContentPane().add("North", toolbar);
// set up main menu items with ActionListeners
newDoc = new JMenuItem("New");
newDoc.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
newDoc();
exit = new JMenuItem("Exit");
exit.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
exit();
print = new JMenuItem("Print");
print.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
print();
save = new JMenuItem("Save");
save.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
save();
saveAs = new JMenuItem("Save As...");
saveAs.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
saveas();
open = new JMenuItem("Open...");
open.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
open();
JMenuItem about = new JMenuItem("About");
about.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
ab = new About(SimpleTextEditor.this);
ab.show();
ab.setLocation(400, 300);
// Create the popup menu
popup = createEditMenu().getPopupMenu();
popup.addSeparator();
popup.add(createStyleMenu());
popup.add(createFormatMenu());
textpane.add(popup);
// set up Help and File menus
Help.add(about);
File.add(newDoc);
File.add(open);
File.add(print);
File.add(save);
File.add(saveAs);
File.addSeparator();
File.add(exit);
// add the menus to the menubar
mb.add(File);
mb.add(Edit);
mb.add(Format);
mb.add(Style);
mb.add(Insert);
mb.add(Help);
this.setJMenuBar(mb);
getContentPane().add("Center", scroller);
// Add mouse Listener to the textpane for popup events
textpane.addMouseListener(new MouseAdapter()
public void mousePressed(MouseEvent e)
if (e.isPopupTrigger())
popup.show(textpane, e.getX(), e.getY());
e.consume();
public void mouseReleased(MouseEvent e)
if (e.isPopupTrigger())
popup.show(textpane, e.getX(), e.getY());
e.consume();
//-----------------| Main active methods |------------------
public void exit()// Main Exit method
if (DocumentIsUnedited)
{//Check that document is saved/unedited etc
dispose();
setVisible(false);
System.exit(0);
else
switch (showNotSavedDialog("Exit"))
case JOptionPane.YES_OPTION:
save();
exit();
break;
case JOptionPane.NO_OPTION:
DocumentIsUnedited = true;
exit();
break;
case JOptionPane.CANCEL_OPTION:
break;
public void newDoc()//Method to create new documents
if (DocumentIsUnedited)
initDoc();
filename = "untitled.txt";
filetype = ".txt";
resetTitle();
else
switch (showNotSavedDialog("New Document"))
case JOptionPane.YES_OPTION:
save();
newDoc();
break;
case JOptionPane.NO_OPTION:
DocumentIsUnedited = true;
newDoc();
break;
case JOptionPane.CANCEL_OPTION:
break;
private void initDoc()// Helper method to initialize a new document
doc = null;
doc = (DefaultStyledDocument) edkit.createDefaultDocument();
doc.addDocumentListener(doclistener);
textpane.setStyledDocument(doc);
public void print()
new TimerTestDialog(this);
class TimerTestDialog extends JDialog
TimerTestDialog(Frame parent)
super(parent);
setLocationRelativeTo(parent);
setupDialog();
setModal(false); // this will allow you to do still stuff with the main frame
* sorry, using a Timer instead of your original TimerTask - it's simpler
Timer t = new Timer(2000, ticker);
t.start();
private void setupDialog()
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add(getDisplayPanel(), BorderLayout.CENTER);
c.add(getButtonPanel(), BorderLayout.SOUTH);
setSize(300, 150);
setVisible(true);
private Component getDisplayPanel()
label = new JLabel("---", JLabel.CENTER);
label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel backing = new JPanel(new BorderLayout());
backing.add(label, BorderLayout.NORTH); // this will ensure the label doesn't go all tall
panel.add(backing, BorderLayout.CENTER);
return panel;
private Component getButtonPanel()
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel backing = new JPanel(new BorderLayout());
JButton closeButton = new JButton("close");
closeButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
dispose();
backing.add(closeButton, BorderLayout.NORTH);
panel.add(backing, BorderLayout.EAST);
return panel;
private ActionListener ticker = new ActionListener()
public void actionPerformed(ActionEvent e)
label.setText(String.valueOf(getRandomNumber()));
private int getRandomNumber()
return r.nextInt(10) + 1; // shift from 0-9 to 1-10
private JLabel label;
* NOTE - this is the best way to use random stuff in java. if you use instance members
* you can sometimes get the same result each time. not really sure how that works but
* i've seen it happen
private static Random r = new Random();
public void saveas()
int n = chooser.showSaveDialog(this);
if (n == 0)
filename = chooser.getSelectedFile().getName();
boolean ext = false;
setFiletype();
thisfile = new File(chooser.getCurrentDirectory(), filename);
DocumentIsSaved = true;
save();
resetTitle();
repaint();
public void save()// Save method. Used by "Save As..." as well
if (DocumentIsSaved)
try
FileOutputStream out = new FileOutputStream(thisfile);
if ((filetype.equals(".rtf")) || (filetype.equals(".doc")))
rtfkit.write(out, doc, 0, doc.getLength());
else
edkit.write(out, doc, 0, doc.getLength());
catch (Exception e)
System.out.println("" + e.getMessage() + "");
DocumentIsUnedited = true;
else
saveas();
public void open()// Find a file and read it into the document
if (DocumentIsUnedited)
int n = chooser.showOpenDialog(this); // get the outcome of the dialog
if (n == 0)
File file = chooser.getSelectedFile();
filename = chooser.getName(file);
setFiletype();
resetTitle();
initDoc();
try
FileInputStream in = new FileInputStream(file);
if (filetype.equals(".rtf"))
rtfkit.read(in, doc, 0);
edkit.read(in, doc, 0);
catch (Exception e)
System.out.println("" + e.getMessage() + "");
thisfile = new File(chooser.getCurrentDirectory(), chooser.getSelectedFile().getName());
DocumentIsUnedited = true;
DocumentIsSaved = true;
resetTitle();
repaint();
else
switch (showNotSavedDialog("Open"))
case JOptionPane.YES_OPTION:
save();
open();
break;
case JOptionPane.NO_OPTION:
DocumentIsUnedited = true;
open();
break;
case JOptionPane.CANCEL_OPTION:
break;
private void setFiletype()// Helper method to get the filetype of saved/opened documents
filetype = null;
for (int i = 0; i < FileFormats.length; i++)
if (filename.toLowerCase().endsWith(FileFormats[i]))
filetype = FileFormats[i];
else
for (i = 0; i < filename.length(); i++)
if (filename.toLowerCase().charAt(i) == '.')
filetype = filename.substring(i);
if (filetype == null) filetype = ".txt";
private void resetTitle()
this.setTitle("SimpleTextEditor - " + filename);
private ImageIcon getMyIcon(String filename)
ImageIcon pic = new ImageIcon("Images/" + filename);
return pic;
private int showNotSavedDialog(String title)// Helper method to create "Save? Yes/No/Cancel" dialogs
int n = JOptionPane.showConfirmDialog(this, "The last document has not been saved. \nDo you want to save it first?",
title,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
return n;
//-----------------| Listeners and Helper classes |----------------
protected class MyDocumentListener implements DocumentListener
public void insertUpdate(DocumentEvent e)
SimpleTextEditor.this.DocumentIsUnedited = false;
public void removeUpdate(DocumentEvent e)
SimpleTextEditor.this.DocumentIsUnedited = false;
public void changedUpdate(DocumentEvent e)
SimpleTextEditor.this.DocumentIsUnedited = false;
protected class MyUndoableEditListener implements UndoableEditListener
public void undoableEditHappened(UndoableEditEvent e)
//Remember the edit and update the menus.
undo.addEdit(e.getEdit());
undoAction.updateUndoState();
redoAction.updateRedoState();
//Helper class for FileFilter, allows a description to be assigned to a filetype
protected class SimpleFilter extends javax.swing.filechooser.FileFilter
String type,des;
public SimpleFilter(String type, String des)
this.des = des;
this.type = type;
public boolean accept(File f)
if (f.isDirectory())
return true;
else
if (f.getName().toLowerCase().endsWith(type))
return true;
else
return false;
public String getDescription()
return des;
//------------| Methods to help create menus and toolbar |--------------
protected JMenu createStyleMenu()
JMenu menu = new JMenu("Style");
menu.add(bold);
menu.add(italic);
menu.add(underline);
menu.addSeparator();
menu.add(new StyledEditorKit.FontSizeAction("12", 12));
menu.add(new StyledEditorKit.FontSizeAction("14", 14));
menu.add(new StyledEditorKit.FontSizeAction("18", 18));
menu.addSeparator();
menu.add(new StyledEditorKit.FontFamilyAction("Serif", "Serif"));
menu.add(new StyledEditorKit.FontFamilyAction("SansSerif", "SansSerif"));
menu.addSeparator();
Action red = new StyledEditorKit.ForegroundAction("Red", new Color(255, 0, 0));
red.putValue(Action.SMALL_ICON, getMyIcon("red.gif"));
menu.add(red);
Action green = new StyledEditorKit.ForegroundAction("Green", new Color(0, 150, 0));
green.putValue(Action.SMALL_ICON, getMyIcon("green.gif"));
menu.add(green);
Action blue = new StyledEditorKit.ForegroundAction("Blue", new Color(0, 50, 150));
blue.putValue(Action.SMALL_ICON, getMyIcon("blue.gif"));
menu.add(blue);
Action black = new StyledEditorKit.ForegroundAction("Black", new Color(0, 0, 0));
black.putValue(Action.SMALL_ICON, getMyIcon("black.gif"));
menu.add(black);
menu.add(more);
return menu;
protected JMenu createEditMenu()
JMenu menu = new JMenu("Edit");
menu.add(undoAction);
menu.add(redoAction);
menu.addSeparator();
menu.add(cut);
menu.add(copy);
menu.add(paste);
menu.addSeparator();
Action selectall = getActionByName(DefaultEditorKit.selectAllAction);
selectall.putValue(Action.NAME, "Select All");
menu.add(selectall);
return menu;
protected JMenu createFormatMenu()
JMenu menu = new JMenu("Format");
menu.add(spellchecker);
menu.add(alignleft);
menu.add(alignright);
menu.add(aligncentre);
menu.add(alignjustify);
return menu;
protected JMenu createInsertMenu()
JMenu menu = new JMenu("Insert");
Action insertimage = new InsertImageAction(this);
menu.add(insertimage);
Action insertdate = new InsertDateAction();
menu.add(insertdate);
Action insertline = new InsertLineAction();
menu.add(insertline);
JMenu bullets = new JMenu("Bullet Points");
bullets.add(new InsertBulletAction(CIRCLE, "Circle"));
bullets.add(new InsertBulletAction(TRIANGLE, "Triangle"));
bullets.add(new InsertBulletAction(SQUARE, "Square"));
menu.add(bullets);
return menu;
public JToolBar createToolbar()
JToolBar bar = new JToolBar();
JButton newbutton = new JButton(getMyIcon("new.gif"));
newbutton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
newDoc();
bar.add(newbutton);
JButton savebutton = new JButton(getMyIcon("save.gif"));
savebutton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
save();
bar.add(savebutton);
JButton openbutton = new JButton(getMyIcon("open.gif"));
openbutton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
open();
bar.add(openbutton);
bar.addSeparator();
for (int i = 0; i < tools.length; i++)
JButton button = new JButton();
button.setAction(tools[i]);
button.setIcon(getMyIcon(tools[i].getValue(Action.NAME) + ".gif"));
button.setText("");
bar.add(button);
if ((i == 2) || (i == 6)) bar.addSeparator();
return bar;
public void createToolbarActions()
bold = new StyledEditorKit.BoldAction();
bold.putValue(Action.NAME, "Bold");
italic = new StyledEditorKit.ItalicAction();
italic.putValue(Action.NAME, "Italic");
underline = new StyledEditorKit.UnderlineAction();
underline.putValue(Action.NAME, "Underline");
more = new MoreColorsAction();
cut = getActionByName(DefaultEditorKit.cutAction);
cut.putValue(Action.NAME, "Cut");
copy = getActionByName(DefaultEditorKit.copyAction);
copy.putValue(Action.NAME, "Copy");
paste = getActionByName(DefaultEditorKit.pasteAction);
paste.putValue(Action.NAME, "Paste");
alignleft = new StyledEditorKit.AlignmentAction("Left Justify", StyleConstants.ALIGN_LEFT);
alignright = new StyledEditorKit.AlignmentAction("Right Justify", StyleConstants.ALIGN_RIGHT);
aligncentre = new StyledEditorKit.AlignmentAction("Align Centre", StyleConstants.ALIGN_CENTER);
alignjustify = new StyledEditorKit.AlignmentAction("Fully Justify", StyleConstants.ALIGN_JUSTIFIED);
spellchecker = new StyledEditorKit.AlignmentAction("Spell Checker", StyleConstants.ALIGN_JUSTIFIED);
tools = new Action[]{cut, copy, paste, bold, italic, underline, more, alignleft, alignright, aligncentre, alignjustify, spellchecker};
// helper methods to enable menu creators to get their actions by name
private void createActionTable(JTextComponent textComponent)
actions = new Hashtable();
Action[] actionsArray = textComponent.getActions();
for (int i = 0; i < actionsArray.length; i++)
Action a = actionsArray[i];
actions.put(a.getValue(Action.NAME), a);
private Action getActionByName(String name)
return (Action) (actions.get(name));
//----------------| Custom Actions |--------------------
class InsertImageAction extends AbstractAction
protected SimpleTextEditor parent;
public InsertImageAction(SimpleTextEditor parent)
super("Image...");
this.parent = parent;
public void actionPerformed(ActionEvent e)
int n = parent.picChooser.showOpenDialog(parent);
if (n == 0)
String filename = picChooser.getSelectedFile().getName();
File file = new File(picChooser.getCurrentDirectory(), filename);
Icon pic = new ImageIcon(file.getAbsolutePath());
textpane.insertIcon(pic);
SimpleTextEditor.this.repaint();
class InsertDateAction extends AbstractAction
public InsertDateAction()
super("Date");
public void actionPerformed(ActionEvent ble)
Calendar c = Calendar.getInstance();
String[] months = new String[]{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
textpane.replaceSelection(c.get(c.DAY_OF_MONTH) + "/" + months[c.get(c.MONTH)] + "/" + c.get(c.YEAR));
class InsertLineAction extends AbstractAction
public InsertLineAction()
super("Horizontal line");
public void actionPerformed(ActionEvent e)
Icon pic = new ImageIcon("Images/line.gif");
textpane.insertIcon(pic);
class InsertBulletAction extends AbstractAction
protected int type;
protected String filenames[] = new String[]{"square.gif", "triangle.gif", "circle.gif"};
public InsertBulletAction(int type, String name)
super(name);
this.type = type;
this.putValue(SMALL_ICON, new ImageIcon("Images/" + filenames[type]));
public void actionPerformed(ActionEvent e)
Icon pic = new ImageIcon("Images/" + filenames[type]);
textpane.insertIcon(pic);
textpane.replaceSelection(" ");
class MoreColorsAction extends AbstractAction
public MoreColorsAction()
super("More Colors");
public void actionPerformed(ActionEvent e)
AttributeSet as = textpane.getCharacterAttributes();
SimpleAttributeSet sas = new SimpleAttributeSet(as);
Color newColor = JColorChooser.showDialog(
SimpleTextEditor.this,
"Choose Text Color",
doc.getForeground(as));
if (newColor != null)
StyleConstants.setForeground(sas, newColor);
textpane.setCharacterAttributes(sas, true);
SimpleTextEditor.this.repaint();
class UndoAction extends AbstractAction
public UndoAction()
super("Undo");
setEnabled(false);
public void actionPerformed(ActionEvent e)
try
undo.undo();
catch (CannotUndoException ex)
System.out.println("Unable to undo: " + ex);
ex.printStackTrace();
updateUndoState();
redoAction.updateRedoState();
protected void updateUndoState()
if (undo.canUndo())
setEnabled(true);
putValue(Action.NAME, undo.getUndoPresentationName());
else
setEnabled(false);
putValue(Action.NAME, "Undo");
class RedoAction extends AbstractAction
public RedoAction()
super("Redo");
setEnabled(false);
public void actionPerformed(ActionEvent e)
try
undo.redo();
catch (CannotRedoException ex)
System.out.println("Unable to redo: " + ex);
ex.printStackTrace();
updateRedoState();
undoAction.updateUndoState();
protected void updateRedoState()
if (undo.canRedo())
setEnabled(true);
putValue(Action.NAME, undo.getRedoPresentationName());
else
setEnabled(false);
putValue(Action.NAME, "Redo");
//-------------| Very nice Image Previewer 'borrowed' from Sun's Java Tutorial
class ImagePreview extends JComponent implements PropertyChangeListener
ImageIcon thumbnail = null;
File file = null;
public ImagePreview(JFileChooser fc)
setPreferredSize(new Dimension(100, 50));
fc.addPropertyChangeListener(this);
public void loadImage()
if (file == null)
return;
ImageIcon tmpIcon = new ImageIcon(file.getPath());
if (tmpIcon.getIconWidth() > 90)
thumbnail = new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1,
Image.SCALE_DEFAULT));
else
thumbnail = tmpIcon; -
How to set different sounds for different events?
Hello I had Xiaomi Mi2s before and I could set different sound for every email account I had, for sms, for facebook and so on. How do I do it on my Xperia? Of course that for example SMS is more important then some facebook comment, so I would like to hear what happened because not every time I want to reach my phone.
Open each app > menu > settings > notification sound > change the sound > done > repeat as needed
"I'd rather be hated for who I am, than loved for who I am not." Kurt Cobain (1967-1994) -
Use a different alphabet for a bulleted list
Hi!
I'm working on a bilingual user manual, Italian - Russian.
I need to use a different alphabet for the bullet list in every language.
By default indesing use the english alphabet "A B C D E F G H I J K.." and I need to change in "A B C D E F G H I L M N..."
Can anyone help me?
Thank you!I use the World Tools plugin for InDesign from in-tools.com to change my "numbered" lettered lists in translation from Latin script to Arabic script, Korean numbering (either Chosung or Ganada, thanks Harbs I've used both! ), even circle numbering. Many different kinds of numbering/lettering are available to World Tools users. However, World Tools for CS4 doesn't offer every alphabet or abjad or syallabary for lettered lists, only some complex-script ones. I dunno about World Tools for CS5, but I've found in-tools to be really responsive to feature requests.
That being said, it might make more sense to do this without automatic bulleting & numbering. I'd rather set up my own hanging indents and key in each Cyrillic letter myself - iff I knew that the number of entries in the list was not going to change. -
One thing I miss is being able to have different "vibrates' for different events.
One thing I miss is being able to have different "vibrates' for different events. My BB 9700 allowed me to set short/medium/long lengths and one/two/three vibrates. It would be great to get these back on the BB Z10 again.
All BB needs to do is offer the same notification functionality they had in OS 7.1 (I say 7.1 as they gave you control over the LED colour as well which was great), and it would be perfect. Notifications on every other platform pail in comparison to what my 9900 could do (and unfortunately the Z10 is included in that list).
I know it is a new OS but it isn't likey they don't know what they need to offer.
Hopefully it comes sooner than later as this is one of those 'key' BlackBerry experiences which has been lost as part of the 'upgraded' OS.
BB-past: 9000>9700>9800>9780>9810>9900>Z10>Q5
Maybe you are looking for
-
Problem in XML Publisher Report submission from OAF Pages
Hi, I am trying to submit Concurrent Program from OAF Page which is an XML Publisher Report. The request is Submitting and Completing successfully but when we open to view the out put we are able to view the HTML tags. We checked the same Concurrent
-
Hello All, I'm Gene. I have an older MAC desktop and am running iPhoto 09, version8.1.2 (424). Each time I connect my iphone to my MAC I get a message that there is a newer version of iPhoto, but when I select the link, I am taken to the Apple webpag
-
Is there a way to copy the notification rules?
Hi, I am migrating to a new server and have already setup notofication rules the way I want them on the old server. Instead of resetting everything manually I would like to copy the notification setup. Is there a way to do this? I am working with 10G
-
Passing table names as parameters (aka Trouble building a dynamic SQL command)
I am attempting to develop a template for publishing some data, and would like to pass standard table names as parameters to the various queries. What I have created generates the following error: Msg 137, Level 16, State 1, Procedure spPublishTrans
-
Failover cluster node - You do not have administrative privileges on the server 'servername' ?
Hi Hello & Good morning Technet's, I would like to post a question which i really expecting a solution. I got 2 domain in one single forest. Domain 1: hg.corp Domain 2: iac.corp (iac.corp is a tree domain under hg.corp forest) Trust : Transitive trus