Program.launch of Mac OSX TextEdit can cause problems


My SWT application has been used in both Windows XP/Vista/7 and Mac OSX for several years.

Recently, in certain org.eclipse.jface.action.Action classes I've added the option to open *.txt files (these are newly created operational reports). The files are opened by calling org.eclipse.swt.program.Program.launch(fileName), where fileName is the full path name for a particular *.txt file.

In Windows, there are no issues with this scenario.

In Mac OSX, if the user first launches the text-related program (e.g., TextEdit) before launching my SWT application, there are no issues with this scenario.

In Mac OSX, if the user first exits the text-related program (e.g., TextEdit) launched by my SWT application before attempting to exit my SWT application (via menu's "Quit", etc.), there are no issues with this scenario.

In Mac OSX, if the users does not exit the text-related program (e.g., TextEdit) launched by my SWT application before attempting to exit my SWT application, my SWT application's window closes... but the icon is left behind in the Dock (a.k.a., system taskbar) and my SWT application has not actually exited. I have to manually terminate my SWT application via Force Quit.

Any suggestions about this problem would be welcome.
Posted On: Sunday 30th of September 2012 10:52:19 PM Total Views:  223
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




create a jtable which can combine and split and the image change also

hi newbie here and would like to know how to create a jtable with default images and with specific column and rows that if you combine the cells the image enlarge and when split the image decreases.
VIEWS ON THIS POST

229

Posted on:

Wednesday 19th September 2012
View Replies!

Dialog focus problem on java 7 and mac osx

, I'm currently validating a swing application that runs on a browser (on an applets). I came across with a problem for the java JRE 7 released by Oracle - this was not happening on Applet JRE 6 (1.6.0_33) Every time I open a dialog within my application, that dialog comes to the front of the browser window but it does not request the focus as expected. THIS HAPPENS ONLY WHEN THE APPLET RUNS ON THE BROWSER. Here is a small program to show the problem: package com.macosx.tests; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingUtilities; public class AppletDialogExample extends JApplet{ private JPanel panel; private JButton openDialogBtn; private void doStart() { panel = new JPanel(); panel.setPreferredSize(new Dimension(500,500)); panel.setBackground(Color.GRAY); openDialogBtn = new JButton("open dialog"); openDialogBtn.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent arg0) { Runnable run = new Runnable() { public void run() { JPanel dialogPanel = new JPanel(new GridLayout(1,1)); JTextField textField = new JTextField(); dialogPanel.add(textField); JOptionPane.showConfirmDialog(null, dialogPanel); } }; SwingUtilities.invokeLater(run); } }); panel.add(openDialogBtn); setContentPane(panel); } @Override public void start() { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { doStart(); } }); } catch (Exception e) { throw new RuntimeException(e); } } }
VIEWS ON THIS POST

260

Posted on:

Thursday 20th September 2012
View Replies!

Why can't i create a new object?

I am having a simple error. I want to create a jframe to say a player already exists and have created a class in its own right. I am new to swing, so am not even sure if this is the right thing to do Anyway there is an error when i try to create a new object and i cant for the life of me figure out what it is public void mouseClicked(MouseEvent e) { String firstname = txtFirstname.getText(); String secondname = txtSurname.getText(); if(!(Players.usercheck(firstname, secondname))) { Players.addplayer(firstname, secondname); PlayerAdded pla = new PlayerAdded(firstname, secondname); pla.setVisible(true); } else { UserExists userexists = new UserExists(); userexists.setvisible(true); } } });
VIEWS ON THIS POST

186

Posted on:

Friday 21st September 2012
View Replies!

i try to get the VK_TAB in jtextfield but i cant,here is the code what i doing wrong? the other keys

this is the code... private void jTextField18KeyReleased(java.awt.event.KeyEvent evt) { // TODO add your handling code here: if(evt.getKeyCode()==KeyEvent.VK_CONTROL){ jTextField3.setFocusable(true); jTextField3.requestFocusInWindow(); } } buy the way i generate the code with netbeans...
VIEWS ON THIS POST

237

Posted on:

Saturday 22nd September 2012
View Replies!

can we display images in sequence which will gives perception of motion in frame's contentPane ?

can we display images in frame which can give perception of motion very similar to videos ....i short can we display sequence of images so that it is played like a video i have tried but ..the images where over lapping other and GUI gets hanged does any one has done that before
VIEWS ON THIS POST

190

Posted on:

Saturday 22nd September 2012
View Replies!

BoxLayout can't be shared exception?

, I'm learning Java from Head First and I'm trying to write a simple GUI program that first asks if the user wants to load a game or start completely over. After that, the user gets to change the values of his character. If the user selected Restore, the TextFields contain the information that he saved last time the game was played. However, in the method gameGui(), the JVM throws an exception at me saying that Boxlayout can't be shared. I do not understand that at all. Maybe somebody can help =) The code(Don't worry, the bulk of it is just Swing ;) import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.event.*; public class SaveGame { JFrame frame; JPanel panel; static SaveGame game; GameCharacter character; JTextField nameField; JTextField powerField; JTextField weaponField; public static void main(String[] args) { game = new SaveGame(); game.setStartupGui(); } public void setStartupGui(){ try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) {} frame = new JFrame("Adventure SaveGame"); panel = new JPanel(); JLabel label = new JLabel("Do you want to start over or restore a savegame"); label.setFont(new Font("serif", Font.BOLD, 18)); JButton startButton = new JButton("Start Over"); startButton.addActionListener(new StartListener()); JButton restoreButton = new JButton("Restore Savegame"); restoreButton.addActionListener(new RestoreListener()); panel.add(startButton); panel.add(restoreButton); frame.getContentPane().add(BorderLayout.CENTER, label); frame.getContentPane().add(BorderLayout.SOUTH, panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400); frame.setVisible(true); } //Method I get the error in below: public void gameGui() { frame.getContentPane().remove(); panel.remove(); panel.setLayout(new FlowLayout()); JLabel nameLabel = new JLabel("Name"); JLabel powerLabel = new JLabel("Power #:"); JLabel weaponLabel = new JLabel("Weapon:"); nameField = new JTextField("Name",10); powerField = new JTextField("Power",5); weaponField = new JTextField("Weapon",10); nameField.setText(character.getName()); powerField.setText(character.getPower()); weaponField.setText(character.getWeapon()); JButton saveButton = new JButton("Save"); saveButton.addActionListener(new SaveListener()); JButton exitButton = new JButton("Exit"); exitButton.addActionListener(new ExitListener()); JPanel labelPanel = new JPanel(); JPanel fieldPanel = new JPanel(); JPanel buttonPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS)); labelPanel.add(nameLabel); labelPanel.add(powerLabel); labelPanel.add(weaponLabel); panel.add(labelPanel); fieldPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS)); fieldPanel.add(nameField); fieldPanel.add(powerField); fieldPanel.add(weaponField); panel.add(fieldPanel); buttonPanel.add(saveButton); buttonPanel.add(exitButton); frame.getContentPane().add(BorderLayout.CENTER, panel); frame.getContentPane().add(BorderLayout.SOUTH, buttonPanel); frame.repaint(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400,400); frame.setVisible(true); } //--------------------------------------------------------------------------------------------------------------------------------- class SaveListener implements ActionListener { public void actionPerformed(ActionEvent ev) { String name = nameField.getText(); String power = powerField.getText(); String weapon = weaponField.getText(); character.setName(name); character.setPower(power); character.setWeapon(weapon); try { FileOutputStream fs = new FileOutputStream("Savegame.ser"); ObjectOutputStream os = new ObjectOutputStream(fs); os.writeObject(character); os.close(); } catch(Exception ex) {ex.printStackTrace();} } } class ExitListener implements ActionListener { public void actionPerformed(ActionEvent ev) { System.exit(0); } } class StartListener implements ActionListener { public void actionPerformed(ActionEvent ev) { character = new GameCharacter(); game.gameGui(); } } class RestoreListener implements ActionListener { public void actionPerformed(ActionEvent ev) { try { FileInputStream fs = new FileInputStream("Savegame.ser"); ObjectInputStream os = new ObjectInputStream(fs); Object one = os.readObject(); character = (GameCharacter) one; os.close(); } catch(FileNotFoundException fex) { character = new GameCharacter();} catch(Exception ex) {ex.printStackTrace();} finally { game.gameGui();} } } }
VIEWS ON THIS POST

133

Posted on:

Saturday 22nd September 2012
View Replies!

java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to java.lang.Comparable

The SWING frame work that i am using is working fine with jre1.6.When i try to run it through jre1.7 getting the below exception . java.lang.ClassCastException: javax.swing.KeyStroke cannot be cast to java.lang.Comparable at java.util.TreeMap.compare(Unknown Source) at java.util.TreeMap.put(Unknown Source) at java.util.TreeSet.add(Unknown Source) Can any one help to reslove this ..
VIEWS ON THIS POST

153

Posted on:

Saturday 22nd September 2012
View Replies!

Change canvas background colour at button click

I am developing Java applet, which have canvas in it. I want to change background color of canvas at one button click. i have changed it using c.offscreen.setColor(back); c.offscreen.fillRect(0, 0, c.getWidth(), c.getHeight()); c.repaint();
VIEWS ON THIS POST

188

Posted on:

Saturday 22nd September 2012
View Replies!

How can I change DefaultCellEditor#setClickCountToStart(int) for DefaultTreeCellEditor

because TreeCellEditor is availble only at 3rd. mouse click my SSCCE demonstrate a.m. issue import java.awt.BorderLayout; import javax.swing.*; import javax.swing.tree.DefaultTreeCellEditor; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeCellEditor; public class TreeEdit { public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object array[] = {Boolean.TRUE, Boolean.FALSE, ""}; JTree tree = new JTree(array); tree.setEditable(true); tree.setRootVisible(true); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); String elements[] = {"A", "B", "C", "D"}; JComboBox comboBox = new JComboBox(elements); comboBox.setEditable(true); TreeCellEditor comboEditor = new DefaultCellEditor(comboBox); TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor); tree.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); } }
VIEWS ON THIS POST

121

Posted on:

Saturday 22nd September 2012
View Replies!

how to create java application that scans picture with handyscan

I am creating a java application such that if the user when run the application and when prompt to scan the user will scan by pressing a button on the handyscan magiscscan miscns(a handheld scanner by skypix handheld) and the scanned image will appear on the screen
VIEWS ON THIS POST

180

Posted on:

Sunday 23rd September 2012
View Replies!

I can't make my JTextArea Scrollable

I am supposed to display data from a file into a JTextArea. To make it scrollable, I put it into a JScrollPane, but as soon as I input the data read from the file into JTextArea, the text goes out of bounds. If i don't put anything in the JTextArea, and enter text from keyboard, it remains scrollable, but if I set text read from a file, it's scroll doesn't work. Please help.
VIEWS ON THIS POST

160

Posted on:

Monday 24th September 2012
View Replies!

fillRect method, can't call it properly

i m writing a java applet that accepts 4 parameters to draw a rectangle - x, y, width, height my problem is, i don't know how to call it in another method - square of asterisks, it needs a variable Graphics g to be supplied, but i don't know where to give this "g" variable! import java.awt.* ; import java.awt.event.* ; import javax.swing.* ; public class ex_6_21 extends JApplet implements ActionListener{ public void squareOfAsterisks(Graphics g, int x,int y, int width, int height){ super.paint(g) ; g.fillRect(x,y,width,height) ; } JTextField x,y,width, height ; JTextArea outputArea ; public void init(){ Container c = getContentPane() ; c.setLayout(new FlowLayout()) ; x = new JTextField(4) ; x.setEditable(true) ; c.add(x) ; y = new JTextField(4) ; y.setEditable(true) ; c.add(y) ; width = new JTextField(4) ; width.setEditable(true) ; c.add(width) ; height = new JTextField(4) ; height.setEditable(true) ; height.addActionListener(this) ; c.add(height) ; outputArea = new JTextArea() ; outputArea.setText("") ; c.add(outputArea) ; } public void actionPerformed(ActionEvent e){ int x_i = Integer.parseInt(x.getText()) ; int y_i = Integer.parseInt(y.getText()) ; int width_i = Integer.parseInt(width.getText()) ; int height_i = Integer.parseInt(height.getText()) ; Graphics g ; squareOfAsterisks( Graphics g, x_i, y_i, width_i, height_i) ; } }
VIEWS ON THIS POST

146

Posted on:

Tuesday 25th September 2012
View Replies!

I cannot for the *life* of me set the focus to my desired window.

I've been at this for hours. I've now distilled it down to a very simple test program. First, I'm running JRE 7 on Linux (I've heard that can make a difference). Here is what I'd like the following program to do: 1. Open 3 windows 2. Set the focus to "TestWindow 1" What it actually does: 1. Opens 3 windows 2. Sets the focus typically to "TestWindow 3" and sometimes to "TestWindow 2" After much reading, I've moved the focus request (and almost everything else gui related for that matter) into the event dispatch thread. Please let me know your ideas! Now I'm dying of curiosity as to the solution. Class TestWindow import javax.swing.*; public class TestWindow { JFrame jFrame; TestWindow(String name, int x, int y) { DefaultListModel defaultListModel = new DefaultListModel(); defaultListModel.addElement("one"); defaultListModel.addElement("two"); defaultListModel.addElement("three"); JList jList = new JList(defaultListModel); JPanel jPanel = new JPanel(); jPanel.add(jList); jFrame = new JFrame(); jFrame.add(jPanel); jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jFrame.setTitle(name); jFrame.setSize(200, 100); jFrame.setLocation(x,y); jFrame.setVisible(true); } public JFrame getJFrame(){ return jFrame; } }
VIEWS ON THIS POST

124

Posted on:

Wednesday 26th September 2012
View Replies!

Anybody can tell me some websites about investigating the Swing or other UI deeply?

Can anybody tell me some websites about investigating the Swing or other UI deeply Thank you,everybody in advance.
VIEWS ON THIS POST

281

Posted on:

Thursday 27th September 2012
View Replies!

How/Where can i find all swing properties keys ?

Hi Recently i needed to override dome default values of swing properties...and i got the perfect answer from Rob Prime in this thread After that i interested to find a way to have all these pairs (simply HashTable keys and values elements) to override them at the startup of applications to make custom values. So firstly I checked the documentations and source codes of jdk6u17 APIs and currently passing lots of pages of Google results and the most and only useful things i found were two code snippets mentioned below : public static void main(String[] args) { printUIManagerDefaults(); } static void printUIManagerDefaults() { Object[] objs = javax.swing.UIManager. getLookAndFeel().getDefaults().keySet().toArray(); //java.util.Arrays.sort( objs ); for( int i = 0; i < objs.length; i++ ) { System.out.println(objs[i]+ ", "+javax.swing.UIManager.getDefaults().get(objs[i])); } }
VIEWS ON THIS POST

110

Posted on:

Thursday 27th September 2012
View Replies!

please can anyone check the code

Can anyone help with a code please! import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.util.ArrayList; import javax.swing.JFrame; import javax.swing.JPanel; public class MFrame extends JFrame { int count; public void init(JPanel panel, Graphics g) { JPanel p = new JPanel(); // Graphics2D g = (Graphics2D) panel.getGraphics(); Graphics2D g2 = (Graphics2D) g; ArrayList complexNumbers = new ArrayList(); double width = 4; double height = 3.2; double widthSpacing = width / panel.getWidth(); double heightSpacing = height / panel.getHeight(); Complex d = new Complex(0, 0); // for (int i = 0; i < 100; i++) { for (int x = 0; x < panel.getWidth(); x++) { for (int y = 0; y < panel.getHeight(); y++) { Complex c = new Complex(x * widthSpacing, y * heightSpacing); complexNumbers.add(c); } } for (int j = 0; j < 100; j++) { Complex complex; Complex random = (Complex) complexNumbers.get(j); int x = (int) (random.getReal() / widthSpacing); int y = (int) (random.getImaginary() / heightSpacing); random.square(); random.add(d); complex = random; if (complex.modulusSquared() > 4) { break; } count = count + 1; drawPixel(g2); g.drawLine(x, y, x, y); } // this.add(p); // p.add(panel); this.add(panel); this.setVisible(true); this.setSize(700, 700); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void drawPixel(Graphics2D g) { if (count
VIEWS ON THIS POST

88

Posted on:

Friday 28th September 2012
View Replies!

How to limit the numbers that can be entered in JFormattedTextField.

Everyone, I am new to Swing. I have a JTextField in which i can enter only values less that hundred and no values more than 100 should be allowed to enter in the field. what should be done...
VIEWS ON THIS POST

86

Posted on:

Friday 28th September 2012
View Replies!

how can I set coordinates of JFrame on JPanel

, I have a JPanel and I want JFrame to be exactly at coordinate(10,10.5) on a JPanel how can I do that I need a double in there if setLocation makes 2 ints...
VIEWS ON THIS POST

73

Posted on:

Saturday 29th September 2012
View Replies!

can't see the background color of a frame , why?

today in college i was trying to set the background color of a jframe but it only shows the color when i resize the frame and not when i just select the radio button but if i set the background color of a panel instead frame it works fine can you explain me why we cant see the background color of a frame /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javachallenge; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; /** * * @author Admin */ public class JavaChallenge extends JFrame implements ActionListener{ /** * @param args the command line arguments */ JRadioButton green,red; JPanel panel; void foo() { panel = new JPanel(); ButtonGroup btngroup = new ButtonGroup(); red = new JRadioButton("Red"); btngroup.add(red); green = new JRadioButton("Green"); btngroup.add(green); panel.add(red); panel.add(green); add(panel,BorderLayout.SOUTH); pack(); red.addActionListener(this); green.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] args) { // TODO code application logic here new JavaChallenge().foo(); } @Override public void actionPerformed(ActionEvent e) { if(red.isSelected()) { setBackground(Color.RED); setExtendedState(JFrame.MAXIMIZED_BOTH); // panel.updateUI(); }else { setBackground(Color.GREEN); setExtendedState(JFrame.MAXIMIZED_BOTH); //panel.updateUI(); } } }
VIEWS ON THIS POST

143

Posted on:

Saturday 29th September 2012
View Replies!