FileFilter - display in different section

Hi,
I am working with a JFileChooser and a FileFilter. The FileFilter allows you to open xml or dtd files. However, I want the files to be displayed in different areas - xml file in one text area and the dtd file in another.
private void openFile() {
            JFileChooser fc = new JFileChooser(".");
        ExampleFileFilter filter = new ExampleFileFilter("xml");
        filter.setDescription("XML Files");
        fc.addChoosableFileFilter(filter);
        filter = new ExampleFileFilter("dtd");
        filter.setDescription("DTD Files");
        fc.addChoosableFileFilter(filter);
        filter = new ExampleFileFilter("xml");
        filter.addExtension("dtd");
        filter.setDescription("XML and DTD Files");
        fc.addChoosableFileFilter(filter);
            int returnVal = fc.showOpenDialog(this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                 File file = fc.getSelectedFile();
                 try {
                        if(filter.addExtension().equals("xml")){   //???????????
                              tpr.textArea.read(new FileReader(file), null);
                       else if (filter.addExtension().equals("dtd")){ //?????????
                              tpr.browserArea.read(new FileReader(file), null);
                    else {
                              System.out.println("This isn't working");
                 } catch (IOException exp) {}
           } Any help would be great!

anyone got any ideas?

Similar Messages

  • Help finishing up my first flash site - using navigation to display different sections of the site?

    Thanks for looking! i am making my first flash site, and im
    not sure what to do next in regards to navigating through the site.
    I have different sections, home, info, hardware, equipment, etc,
    but im not sure how to make each section appear when you click the
    corresponding navigation link. i have an idea but im not sure how
    to execute it.
    Should i make a movie clip for each section (home, info,
    hardware, contact), then place each movie clip in its own frame on
    the main time line, and on each navigation link button (each one is
    a movie clip) use action script and put a gotoAndPlay() code with
    the frame number of the corresponding section? so when you click
    it, it goes to that frame which has the movie clip that has the
    content for that part of site, say contact, or info?? if so how can
    i do this?
    that sounds really confusing and im sorry but please help out
    a beginner! Thank you and happy halloween!
    -Matt
    here is a link so you can see the.swf
    [url]http://www.filedorm.com/show.php/7839_INTOUCH.swf.html[/url]
    and also here is a link for the .fla
    [url]http://public.me.com/mattsh*t[/url]
    your going to have to copy and paste that in your browser
    since the world filter on here. just repleace the " * " with an " i
    "

    Targeting specific timelines in a flash movie can be daunting
    in the beginning. But if you start from the main timeline (_root)
    and build brom there, it becomes easier to understand.
    For eg:
    If you have 2 movieclips on your main timeline (_root).
    Navigation and Pages.
    Inside Navigation you have the buttons, and each button is a
    separate movieclip.
    Inside Pages you have each page, each a separate movieclip.
    to target a specific page number, from a button, there are 2
    ways you can go about it. The method that Ned suggested is called
    RELATIVE.
    -meaning that you target FROM WHERE YOU ARE.
    the second method is ABSOLUTE.
    -meaning you target FROM MAIN TIMELINE.
    Relative is good, but can be confusing when using dot syntax.
    Absolute is straight forward and easy to understand, and can
    be used from anywhere in the whole movie. The downside, is that it
    generally requires a bit more typing.
    In the example I stated above, it does not require more
    typing. simply say:
    _root.page.gotoAndStop(number);
    This line can be used from anywhere in your movie, at any
    timeline depth, and will work with no worries.
    You can also have ALL navigation code on the main timeline on
    the first frame. Simply designate the path to the specific button
    like so:
    navigation.home_btn.onPress = function(){
    doSomething;
    this tells Flash that the button named "home_btn" located
    inside the movieclip called "navigation" will have to doSomething
    when Pressed.
    I hope this helps you understand targeting a bit more.
    Good Luck.

  • 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,
    "C

    Here 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;

  • Flex 3  : Dividing  DataGridColumn  into different Sections

    Hi
    Toughest task was given to me  ,  please help me  to complete .
    I am displaying  data from an XML File on to DataGrid Component .
    Now my requirement is that , On to same row of DataGrid , i need to display different
    different Fields .
    Say for example , a single row of DatagridColumn shoukd consist of Name , Age  and Sex
    as different sections .
    Please help me to complete this . Thanks

    kiran
    Are you saying you want to put all name, age and sex in one cell of the datagrid?
    or are you trying to do
    so this?
    name   sex     age
    xxxx    male    18
    or this
    column 1
    name: xxx
    sex: male
    age :18
    im not sure i follow what you are trying to acomplish.
    Miguel

  • Conditionally Display Paper Layout Section

    I have a report, that uses the Main Section, and the Trailer Section. The Main Section displays summary data, and the trailer section displays detail data.
    I need to use both sections because the paper size for each section is different - the summary data only needs to print out landscape letter, but the detail data needs to print out landscape legal.
    I also have a format trigger so that the user can choose to display or not display either section of the report. The problem I have, however, is that when a user chooses to not display a section, that page still prints out, it just prints out as a blank sheet.
    Is there a way to conditionally display an entire section of the paper layout? (Header, Main or Trailer)

    You are correct using the trigger to suppress the section content. To get rid of blank pages, add BLANKPAGES=NO to the report call string.

  • Is there a way to create a custom screensaver with pics/slides that display for different amounts of time?

    Is there a way to create a custom screensaver with pics/slides that display for different amounts of time? Or even add a "video slide" into the screensaver?
    My business has 3 TVs displayed in our lobby, each with its own apple TV and they are all linked to the same photo stream. Currently the Atv screensaver displays the photostream pictures of our products for the default 3 seconds. We just added pics/slides that now display messages and useful info for our customers but I want that info to be displayed for a longer period of time than the pictures to give people a chance to read it.
    I tried using flickr and powerpoint as a work around but no luck.  I created a slide in powerpoint with play length of 15 secs and saved it as a wmv file.  I added that file to a "screensaver" set in flickr and pointed the Atv screensaver to that flickr set.  It still displays everything, pics and the wmv file at the default 3 sec.
    I know I can increase the duration of all pics in the screensaver to display for longer but the goal is to have the pics display at 3 secs and the info slides to display at 15 secs.

    Welcome to the Apple Community.
    No that's not possible.
    If you have any suggestions that you think might enhance the Apple TV you can send Apple your feedback here 

  • Setting different pages widths in different sections - Pages 5.2

    In Pages 5.2, how does one set different page widths (margins) in different sections?

    You can't. Margins apply to the entire document.
    What you can do is set the margins to their max width and then use left and right indents for the sections you want narrower.
    Peter

  • Two External Displays and Internal Display Over Different Connections

    Hi there.
    I'm going to be purchasing a rMBP in the very, very near future. However, I am unclear about how external displays work with this. My current display setup at work is two basic 1080p monitors that can be run over DVI, VGA or HDMI. I'd like to keep using these when I start using the rMBP but also gain the advantage of a third screen by using the internal display at the same time (so much space for activities!).
    One of the thunderbolt ports will need to be used for an Ethernet connection (there is no wireless here), so this leaves the setup needing to be one monitor run via Thunderbolt -> DVI and the other monitor run via HDMI.
    The internet in general isn't being entirely helpful with this. I'm looking for a clear answer of whether the rMBP will run the internal display and the two external displays using this setup under OS X. Some seem to believe that it won't work using different connection types, for example.
    Thanks for any help.

    Hello dljfield,
    Thanks for using Apple Support Communities.
    If you'd like to use multiple external displays with a MacBook Pro with Retina display, then please take a look at the information outlined below. A 15" MacBook Pro mid-2014 can support up to two external displays using different outputs.
    MacBook Pro (Retina, 15-inch, Mid 2014) - Technical Specifications
    OS X Yosemite: Connect multiple displays to your Mac
    Take care,
    Alex H.

  • Menu Options in responsibilities getting displayed in different language.

    Hi,
    When we are logging in with the English language in R12, the menu options for some responsibilities are displayed in different languages, which is looking very strange. This is happening to different responsibilities. can any one help me on this.

    Hi;
    What is exact EBS version
    It was working before? If yes what have been changed?
    Did you try to compile forms via adadmin?
    Please review:
         R12 System Administrator Menu is showing English values in any NLS language [ID 563008.1]
    Regard
    Helios

  • In my itunes library I have apps for the ipod.  All of the apps were together, and now I have two different sections to my apps. The first one says 44 apps and the second section says 143 apps.  When I connect my ipod only the first section goes on

    can anyone help me with my apps on my itunes.  They have separated for some reason.  I have one section of 44 apps and the other has 121 apps. Only the top section will sinc with my ipod because at the side where it says apps, it is only showing the 44 apps and not the section at the bottom

    Can you take a screen shot of the iTunes screen and post it? I do not really understand what you  mean by different sections.
    What model iPod and iOS do you have? Maybe the section that does not sync are not compatible with the iPod.
    Were all the apps purchased with one account?
    Do you have any Restrictions one that would prevent syncing? Settings>General>Restrictions.

  • How to filter the data in different sections (e.g. Report Footers)?

    Hi,
    I am using Crystal Reports 11 to generate cross-tables.
    I plan to generate 3 cross-tabs, and each cross-table will be put in a section. For example, cross-tab1 in Report Footer a; cross-tab2 in Report Footer b; cross-tab3 in Report Footer c.
    I know use "Select Expert" to filter data. But, it seems that "Select Expert" filters data for the whole report.
    I want to filter the data for each cross-table separately. For example, filter cross-tab1 based on condition1; filter cross-tab2 based on condition2; filter cross-tab3 based on condition3.
    How to filter the data in different sections (e.g. Report Footers)?
    Thank you in advance.

    Hi,
    Now that you've inserted the subreport just right-click the sub-report and click Edit. The Design page for sub-report should open up.
    You can now insert the cross-tab on the Report Header and insert a record selection formula of your choice.
    Also, suppress all the other sections of the subreport so the Main report only shows the crosstab without any spaces.
    Do the same for all the subreports.
    -Abhilash

  • When I click "about this mac" to check on my storage, I get a number of different sections music, movies, etc. but also I get a section called backups, where can I find the files in this section?

    When I click "about this mac" to check on my storage, I get a number of different sections music, movies, etc. but also I get a section called backups, where can I find the files in this section?

    Welcome to Apple Support Communities
    All the storage in "Backups" is taken up by local snapshots, which are made automatically in all MacBooks, MacBooks Pro and MacBooks Air with OS X Lion or newer and Time Machine turned on.
    See > http://pondini.org/TM/30.html I recommend you to leave them there, because they will be removed automatically. However, if you want, you can disable or remove them manually if you want, even if there's no reason to do this. Have a look at the link above for more information

  • How do I make a 20 X 30 print with layers of 16 X 20, 12 X 18, 11 X 14, 8 X 12, 8 X 10, 5 X 7 and 4 X 6 of the same image to display the different sizes available to someone?  Using Elements 13 with Windows 8.1

    How do I make a 20 X 30 print with layers of 16 X 20, 12 X 18, 11 X 14, 8 X 12, 8 X 10, 5 X 7 and 4 X 6 of the same image to display the different sizes available to someone?  Using Elements 13 with Windows 8.1
    A senior citizen needs some help.
    Thanks

    Saving each image as different size - is it an option for you?  I would save images with their name as: 20x30.png, 16x20.png etc etc.
    Or explain whether you want these in a webpage  in which case only one image is necessary and different sizes are displayed with good CSS code.  this is question for Dreamweaver forum if this is what you want.

  • Am creating document with Pages. pages are in "portrait" orientation, but two charts at end need to be "landscape". changing the orientation for one section changes it for entire doc. can i have different orientations in Pages for different sections?

    am creating a document with Pages.  all pages using "portrait" orientation, except 2 appendices need to be in "landscape".  in Word for Windows it is possible to have different page orientations for different sections of a document.  is that possible with Pages.  Even when i put the appendices in a different section, changing the page orientation changes it for the entire doc.

    Make a separate document the size and orientation you want.
    Turn that into a pdf and add it back into the original Pages document or into the pdf from from that document.
    Peter

  • Mac OS X 10.7.4 ARD Issues When Observing/Controlling Computers with Display Mirroring/Different Resolutions

    As if Macs in an enterprise environment could be more difficult to manage, now since our upgrade to OS X 10.7.(4) I have lost the ability to remotely control numerous Macs in our organization. The issue occurs when attempting to control a Mac running OS X 10.7.(4) that has their Display mirrored and the resolution does not match on both displays. What happens is that I can see the remote screen however it does not fill the entire Observe/Control window. Instead, the remote screen takes up about 50% of the window, the rest is black but sometimes will display a mirror image of the remote screen in the black area. What?! Yeah, I've attached a screenshot because this is ridiculous. The real problem is that I cannot control the computer when it has reached this state, the mouse no longer functions properly, it is not clicking where I place the mouse, etc. I have made sure that I have all updates including ARD Client/Server updates. I even tried VNC but as I have come to find out that is a whole other issue (doesn't work, sends me to the login screen, etc).
    So here's what I need:
    - A patch that is going to fix this issue
    - A script to run that is going to change the remote screen resolution (I still have the ability to run remote scripts, etc. simply not Observe/Control)
    Ideas?
    <Image Edited by Host>

    I found a way to work around this issue.  Not a fix but a work around.
    This is little application some one wrote to toggle mirroring on and off.
    Mirror Displays
    If you put this application in the client computer's /Aplications folder
    you can use ARD or SSH to run the app and switch modes.
    The problem only occurs for me when a client is set to mirror dissimilar displays with different aspect ratios.
    I am only seeing this in Lion 10.7.4 and 10.7.5
    Hope it helps someone....

Maybe you are looking for