Creating Undo Menu on Swing GUI
Undo Menu is to be Created on Swing GUI on the Graphics. In the Tutorial, Undo with Text is given. But on implementing the logic of Undo with Text , some Errors come.
You can use javax.swing.undo.* stuff only with classes implementing
javax.swing.text.Document interface.
To add undo/redo functionality for some Graphic components you should program this mechanism by yourself.
So create your own object model, track all changes and implement/add appropriate listeners.
Similar Messages
-
How to create file menu in the swing?
How to create file menu or any menu in the swing?
Please help me.How to create file menu or any menu in the
swing?
Please help me.By file menu, do you mean where you can choose a file to open or save to? If so, have you had a look at the File Chooser component? If not, please click on the link in the previous sentence to the Sun tutorial.
Good luck
/Pete -
My Swing GUI has a JMenuBar with several items. The main panel has a "controls" pane and an "results" pane. The results must be displayed when selecting options/actions on the "controls" pane.
However, I want the contents of the "controls" pane to depend on the menu item selected.
What should be my strategy to achieve this?
My best guess would be to create all of the "controls" panes and only show one of them when using the menu. But I need a litlle bit more help on this.
Thanks,
joozjuCardLayout seems helpful. Although I seem to have some problem with the cl.show() method. The other cards are not drawn when I select a menuitem:
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test implements ActionListener {
JPanel controlCardsPanel;
JPanel ccDef, ccOne, ccTwo;
public static void main(String[] args) {
try{
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Test - Under Construction");
Test t = new Test();
frame.setJMenuBar(t.createMenuBar());
frame.setContentPane(t.createContentPane());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
public JPanel createContentPane() {
JPanel jp = new JPanel(new BorderLayout(5,5)); //BorderLayout must be defined here
jp.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
jp.setPreferredSize(new Dimension(640, 480));
jp.setBackground(Color.LIGHT_GRAY);
ccDef = new JPanel();
ccDef.add(new JLabel("Use the Menu"));
ccOne = new JPanel();
ccOne.add(new JLabel("Press One"));
ccOne.add(new JButton("One"));
ccTwo = new JPanel();
ccTwo.add(new JLabel("Select Two"));
ccTwo.add(new JCheckBox("High"));
ccTwo.add(new JCheckBox("Low"));
CardLayout cl = new CardLayout();
controlCardsPanel = new JPanel();
controlCardsPanel.setLayout(cl);
controlCardsPanel.add(ccDef, "I am ccDefault");
controlCardsPanel.add(ccOne, "I am ccOne");
controlCardsPanel.add(ccTwo, "I am ccTwo");
jp.add(controlCardsPanel, BorderLayout.LINE_START);
jp.setOpaque(true);
return jp;
public JMenuBar createMenuBar() {
//Create menu bar
JMenuBar jmb = new JMenuBar();
//Build File menu
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
//Add Control One MenuItem
JMenuItem fileMenuControlOne = new JMenuItem("Card One");
fileMenuControlOne.setActionCommand("ccOne");
fileMenuControlOne.addActionListener(this);
fileMenu.add(fileMenuControlOne);
//Add Control Two MenuItem
JMenuItem fileMenuControlTwo = new JMenuItem("Card Two");
fileMenuControlTwo.setActionCommand("ccTwo");
fileMenuControlTwo.addActionListener(this);
fileMenu.add(fileMenuControlTwo);
//Add Quit MenuItem
JMenuItem fileMenuQuit = new JMenuItem("Quit");
fileMenuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
fileMenuQuit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.exit(0);
fileMenu.add(fileMenuQuit);
jmb.add(fileMenu);
return jmb;
public void actionPerformed(ActionEvent ae) {
CardLayout cl = (CardLayout)(controlCardsPanel.getLayout());
cl.show(controlCardsPanel, (String)ae.getActionCommand());
}I expect the othe cards to appear when I select "Card One" from the File menu. But they don't. I use the Ctrl-F11 key in eclipse when I test my app.
Thanks,
Joost -
Loading large files in Java Swing GUI
Hello Everyone!
I am trying to load large files(more then 70 MB of xml text) in a Java Swing GUI. I tried several approaches,
1)Byte based loading whith a loop similar to
pane.setText("");
InputStream file_reader = new BufferedInputStream(new FileInputStream
(file));
int BUFFER_SIZE = 4096;
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
String line;
while ((bytesRead = file_reader.read(buffer, 0, BUFFER_SIZE)) != -1)
line = new String(buffer, 0, bytesRead);
pane.append(line);
}But this is gives me unacceptable response times for large files and runs out of Java Heap memory.
2) I read in several places that I could load only small chunks of the file at a time and when the user scrolls upwards or downwards the next/previous chunk is loaded , to achieve this I am guessing extensive manipulation for the ScrollBar in the JScrollPane will be needed or adding an external JScrollBar perhaps? Can anyone provide sample code for that approach? (Putting in mind that I am writting code for an editor so I will be needing to interact via clicks and mouse wheel roatation and keyboard buttons and so on...)
If anyone can help me, post sample code or point me to useful links that deal with this issue or with writting code for editors in general I would be very grateful.
Thank you in advance.Hi,
I'm replying to your question from another thread.
To handle large files I used the new IO libary. I'm trying to remember off the top of my head but the classes involved were the RandomAccessFile, FileChannel and MappedByteBuffer. The MappedByteBuffer was the best way for me to read and write to the file.
When opening the file I had to scan through the contents of the file using a swing worker thread and progress monitor. Whilst doing this I indexed the file into managable chunks. I also created a cache to further optimise file access.
In all it worked really well and I was suprised by the performance of the new IO libraries. I remember loading 1GB files and whilst having to wait a few seconds to perform the indexing you wouldn't know that the data for the JList was being retrieved from a file whilst the application was running.
Good Luck,
Martin. -
(Youtube-) Video in a Swing GUI
Hey everyone,
I'm currently trying to play a video in my Swing GUI with JMF but I really can't get it to work.
With the help of google I got this far:
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.swing.JFrame;
public class MediaPanel extends JFrame {
public MediaPanel() {
setLayout(new BorderLayout()); // use a BorderLayout
// Use lightweight components for Swing compatibility
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
URL mediaURL = null;
try {
mediaURL = new URL("http://www.youtube.com/watch?v=Q7_Z_mQUBa8");
} catch (MalformedURLException ex) {
System.err.println(ex);
try {
// create a player to play the media specified in the URL
Player mediaPlayer = Manager.createRealizedPlayer(mediaURL);
// get the components for the video and the playback controls
Component video = mediaPlayer.getVisualComponent();
Component controls = mediaPlayer.getControlPanelComponent();
if (video != null) {
add(video, BorderLayout.CENTER); // add video component
if (controls != null) {
add(controls, BorderLayout.SOUTH); // add controls
mediaPlayer.start(); // start playing the media clip
} // end try
catch (NoPlayerException noPlayerException) {
System.err.println("No media player found");
} // end catch
catch (CannotRealizeException cannotRealizeException) {
System.err.println("Could not realize media player");
} // end catch
catch (IOException iOException) {
System.err.println("Error reading from the source");
} // end catch
} // end MediaPanel constructor
}But all I get is errors:
Warning: The URL may not exist. Please check URL
No media player found
Can you please please help me get this working? I would really appreciate a little walkthrough
Best regards,
Patrick
Edited by: 954807 on Aug 24, 2012 6:52 AMJust use \ tags. People don't like to go to external sites.
I really advise you to consider using JavaFX 2 here. Swing is old and not really supported anymore, JMF is also old and absolutely not supported anymore. -
Hi all,
can anyone tell me how to create an Help menu in Swing??
i mean, like the Help menu options that you can see in Windows.
I mean, again, by clicking on the Help option, you should see Contents etc..
is it possible to do it in Swing? if so, how?
thanx and regards
marcoThere's no class called "HelpMenu" or anything like that, you'd have to create your own using tabbed panes and JTrees.
-
In this case, can I modify swing GUI out of swing thread?
I know the Swing single thread rule and design (Swing is not thread safe).
For time-consuming task, we are using other thread to do the task and
we use SwingUtilities.invokeAndWait() or SwingUtilities.invokeLater (or SwingWorker) to update Swing GUI.
My problem is, my time-consuming task is related to Swing GUI stuff
(like set expanded state of a huge tree, walk through entire tree... etc), not the classic DB task.
So my time-consuming Swing task must executed on Swing thread, but it will block the GUI responsivity.
I solve this problem by show up a modal waiting dialog to ask user to wait and
also allow user to cancel the task.
Then I create an other thread (no event-dispatch thread) to do my Swing time-consuming tasks.
Since the modal dialog (do nothing just allow user to cancel) is a thread spawn by
Swing event-dispatch thread and block the Swing dispatch-thread until dialog close.
So my thread can modify Swing GUI stuff safely since there are no any concurrent access problem.
In this case, I broke the Swing's suggestion, modify Swing stuff out of Swing event-dispatch thread.
But as I said, there are no concurrent access, so I am safe.
Am I right? Are you agree? Do you have other better idea?
Thanks for your help.If you drag your modal dialog around in front of the background UI, then there is concurrent access: paint requests in your main window as the foreground window moves around.
-
I have to embed a spreadsheet facility in a SWING GUI, what is the best and easiest way to do this ??
I am not quite sure what your problem is.
The way I see it, your question is one of the following:
1. How do I (generally) make a user interface on top of my dos-based program?
2. How do I make user interfaces in swing?
If your question is the first, I'm afraid I can't tell you either. Would seem pretty obvious to me, make a simple dialog based app, using menu's or actions to trigger tha actions that were formerly triggered by numbers, etc...
In the other case, I recommend the java swing tutorial at http://java.sun.com/docs/books/tutorial/uiswing/
Greetings,
Gert -
What is menu area? can we create a menu exit with tht?
Hi experts,
what is menu area? can we create a menu exit with tht? is areamenu(se43n) diff frm menu exit?Hi
Menu Exits
Menu exits add items to the pull down menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications.
SAP creates menu exits by defining special menu items in the Menu Painter. These special entries have function codes that begin with "+" (a plus sign). You specify the menu items text when activating the item in an add-on project.
Menu exits allow you to add your own functionallity to menus. Menu exits are implemented by SAP, and are reserved menu entries in the GUI interface. The developer can add his/her own text and logic for the menu.
Function codes for menu exits all start with "+"
Example
We want to create a new menu item in the Office menu. The text for the menu should be "Run ZTEST", and the menu will
run report ZTEST.
Goto transaction SE43 Area Menu Maintenance
In Area Menu Paramenter type 'S000' (S triple Zero)
Select Change and ignore all the warning screens
Expand the office menu. In the buttom of the office tree you will find a menu named "Customer function"
Double click on the text. In the pop-up screen change the text to "Run ZTEST". Note that the trsnaction code is +C01
Goto transaction SE93 and create transaction +C01 that calls report ZTEST.
Now you will se the menu displayed in the office tree. If you delete transaction +C01 again, the new menu will dissapear.
There are 'only' 177 Menu exits in standard - I couldn't see the right one, too.
But you could search the implemented exits, this should be only a small number. Go to transaction CMOD, enter * and F4, information system (F5), show all selections (Shift+F7) and then you can restrict to search only menu exits.
Of course there is the possibility, that these are added in a different way...
... at least you can be sure, if it's a normal menu exit.
Check this sap help..
http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
http://www.sapbrainsonline.com/TUTORIALS/default.html
You can achieve this functionality by configuring in IMG.
Please find the info regarding User-Exit's in the following links:
http://help.sap.com/saphelp_nw04/helpdata/en/bf/ec07a25db911d295ae0000e82de14a/frameset.htm
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
Re: doubt on user exits
user exits and Badis
User exits is the enhancements provided by SAP
You can use them in transactions. Each transaction will have user exits.
If you want to use your own requirements by making your coding while the transaction is run you can use user exits.
For example if you want to run the MRP in MD02 specific to MRP controller you can user exit.
Please also refer the document below.
USEREXIT
Userxits allow us to add our own functionality to SAP standard program
without modifying it . These are implemented in the form of subroutines and hence are also known as FORM EXITs. The userexits are generally collected in includes and attached to the standard program by the SAP.
All Userexits start with the word USEREXIT_...
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once the correct userexit is found the necessary customer code is inserted in the customer include starting with the z.. in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is no longer being followed for newer extensions instead they are using EXITs which come bundeled in enhancement packages . Neverthiless existing USEREXITS will be supported by SAP an all the newer versions of SAP.
HOW TO FIND USEREXITS
Userexits can be found in number of ways:
1) To find userexits in SD module , goto object navigator(SE80) and select
development class from the list and enter VMOD in it. All of the userexits in SD are contained in the development class VMOD. Press enter and you will find all the includes which contain userexits in SD for different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it and start coding .
Some examples of userexits in SD(SALES & DISTRIBUTION ) are:
1)ADDING OF NEW FIELDS IN PRICING
In Pricing in SD the fields on the basis of which pricing is done are derived from the FIELD CATALOG which is a structure KOMG .This structure is used to transfer transaction data to the pricing procedure in SD and is also known as communication structure.This structure KOMG consists of two tables KOMK for Header related fields and KOMP for item related fields. The fields which are not in either of the two tables KOMK and KOMP cannot be used in pricing .Sometimes a need arises when the pricing is to be based on some other criteria which is not present in the form of fields in either of the two tables. This problem can be solved by using USEREXITS which are provided for pricing in SD. Pricing takes place both when the SALES ORDER ( Transaction VA01) is created as well as when INVOICING ( Transaction VF01) is done.Hence SAP provides 2 userexits ,one for sales order processing which is
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
Depending upon which table (KOMK or KOMP) the new fields were inserted we use either of the above two userexits.These userexits are found in include MV45AFZZ of the standard SAP sales order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these
are provided in the include RY60AFZZ which is in the standard SAP program SAPMV45A. The name of the userexits are same. i.e
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits are used for passing the data from the communication structure to the pricing procedure, for this we have to fill the newely created field in the communication structure KOMG for this we fill the code in the above userexit using the MOVE statement after the data that has to be passed is taken from the database table by using the SELECT statement. The actual structure which is visible in these userexits and which is to be filled for that particular field is TKOMP or TKOMK.
Before the coding for these userexits is done ,it is necessary to create a new field in either of the two tables KOMK or KOMP .For this purpose includes are provided in each of them .
To create the field in header data(KOMK) the include provided is KOMKAZ
and to create the field in item data(KOMP) the include provided is KOMPAZ.
One possible example for the need of creating new fields can be e.g. Frieght to be based upon transportation zone ,for this no field is available in field catalog and hence it can be created in KOMK and then above userexits can be used to fill the transportation data to it.
2)The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3)The other method of finding userexits is to find the include in case of SD/MM applications where the userexits are located ,this can be found in the SAP reference IMG generally in the subfolder under SYSTEM MODIFICATION.
Some other examples of userexits in SD are:
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when
the document (sales order VA01) is just about to be saved.This userexit is used generally for custom checks on different fields , to display some information before the order will be saved or for making changes to certain fields before the sales order will be saved.
Exits & Enhancements
There are mainly six types of EXITs in sap which have been collected in the form of enhancement packages and attached to standard code in SAP.
These are different from USEREXIT in the way that they are implemented
in the form of FUNCTIONs while in USEREXITS we use form routines for their implementation. These are also sometimes known as function exits .
These start from the word EXIT_ followed by the program name and then followed by a three digit number.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1)MENU EXITS
2)FUNCTION EXITS
3)TABLE EXITS
4)SCREEN EXITS
5)KEYWORD EXITS
6)FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is required to create the project by using CMOD
selecting the enhancement e.g. V45A0002 and selecting the component
(one which fulfills our need) i.e the exit which will be implemented in SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code . These start from the word EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any tupe of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
This is in contrast to USEREXITs where PERFORM statement is used to call
the required userexit.
To implement the FUNCTION EXITs first of all the project is created and a suitable enhancement package is selected and from its compnents the function exit to be implemented is selected and on double clicking it the exit code will appear in ABAP EDITOR(se38) where a Z include will be found and the customer code should be entered in this include.
e.g.
ADDING A DEFAULT SOLD-TO-PARTY in Sales Order Creation
To show a default sold-to-party in this field when the user creates a sales order (VA01) we can use a function exit .This function exit is located in enhancement no V45A0002 . Before we can choose the exit we have to create a project in CMOD after that enter V45A0002 in the enhancement field and click on the components . In the components you will see the exit EXIT_SAPMV45A_002 . This exit is used for our purpose.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in exporting parameter which is E_KUNNR of type KNA1-KUNNR i.e if we move the desired customer name to this structure(E_KUNNR) it will be shown in the field as the default value when we create the sales order. This function also contains a customer include ZXVVA04 . This include will be used to write our custom code .
Double clicking on this include and it will prompt us that this include does not exists do you want to create this object ,select yes and the include will be created .In this include we can write our own code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created , sold-to-party field will come up with a predefined customer .
FIELD EXITS
The field exits are managed,created,activated through program RSMODPRF. The field exit is associated with a data element existing in ABAP dictionary and hence to the screen field using that data element.
The format of field exit is :
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the screens containing that data element.
The function module associated with field exit shows two parameters
INPUT and OUTPUT. Input parameter contains the data passed to the field exit when the field exit was invoked by the R/3 , We can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES. -
Need help with threading in Swing GUI !!!
I've written an app that parses and writes
files. I'm using a Swing GUI. The app
could potenially be used to parse hundreds or even
thousands of files. I've included a JProgressBar
to monitor progress. The problem is when I parse
a large number of files the GUI freezes and only
updates the values of the progress bar when the
parsing and writing process is finished.
I assume I need to start the process in a seperate thread. But, I'm new to threads and I'm not sure
whether to start the Progressbar code in a seperate
thread or the parsing code. As a matter of fact I really
don't have any idea how to go about this.
I read that Swing requires repaints be done in the
event dispatch thread. If I start the parsing in a seperate
thread how do I update the progressbar from the other
thread? I'm a thread neophyte.
I need a cigarette.In other words do this:
Inside event Thread:
handle button action
start thread
return from action listener
Inside worker Thread:
lock interface
loop
perform action
update progress bar
unlock interface
return from worker ThreadDoesn't updating the progress bar (and locking/unlocking the interface components) from within the worker thread violate the rule that you shouldn't mess with Swing components outside the event thread? (Do I have that rule right?)
In any case, is there any way to just post some kind of event to the progress bar to update it from within the worker thread, thereby insuring that the GUI progress bar update is being invoked from the event thread? This would also obviate the need to use a timer to poll for an update, which I think is a waste especially when the monitored progress is at a variable rate, (or for number crunching, is executing on different speed machines).
Also, doesn't using invokeLater() or invokeAndWait() still block the event dispatching thread? I don't understand how having a chunk of code started in the event thread doesn't block the event thread unless the code's executed in a "sub-thread", which would then make it not in the event thread.
I'm also looking to have a progress bar updated to monitor a worker thread, but also want to include a "Stop" button, etc. and need the event queue not to be blocked.
The last thing I can think of is to implement some kind of original event-listener class that listens to events that I define, then register it with the system event queue somehow, then have the worker thread post events to this listener which then calls setValue() in the progress bar to insure that the bar is updated from the event queue and when I want it to be updated. I don't know yet if it's possible to create and register these kinds of classes (I'm guessing it is).
Thanks,
Derek -
Can not create or modify objects via GUI
I have installed Oracle SQL Developer version 1.5.1. The option to create/modify tables via the GUI is not available when i right click i get the options to explore directory, notepad, refresh, apply filter, clear filter (grayed), capture table (grayed), capture into existing model (grayed), quick migrate (grayed) and help i have looked aroung the entire workbench and have not found the option to create/modify tables with advanced options via teh GUI. i can create and modify tables if i type in sql commands but do not have the GUI. Is that a separeate adapter you have to install.
Thanks
NGMHi NGM
Could that be related to the user privileges? Please control with another account that can make create/alter table ?
What are the privileges of your user?
It works fine for me on the release : Oracle IDE 1.5.1.54.40.
Try to Check for Updates in the help menu. -
Recommended Tool for devloping Swing GUI's?
Hello everyone.
I was wondering what a good tool kit was for building swing gui's?
I heard NetBean was one, any others you recommend?
Currently I use Rational Software Architect to do all my java coding but I don't see any options in this IDE for creating drag and drop GUI development.
Thanks!You have 2 very different answers to consider. Before making your final decision, I'd ask yourself, which of the two responders is a Swing expert and which isn't. That should put a whole lot of added weight to one of the recs. Just my two scheckel's worth.
-
Launching Swing GUI from Oracle Forms Web Based
Hi there,
I have oracle forms which call a shell script which initiates the java swing gui. I am using host command to run this script. When I am doing it on unix server everything works fine. Now we want same application on web now i am getting problem. The host command is not working in this case. It can not launch the java gui. Can anybody tell me what will be the nice approach to do it.
Thanks
RanjanHi,
you'll have to create a Java Bean in Forms that calls the runtime. You can also use webutil, available on otn to call a client side host command.
Frank -
Multi-Client TCP Server /w Swing GUI
Hi everybody,
i have to develop a Multi-Client TCP Server with a Swing GUI. The GUI mainly consists of a JTable which shows various trace messages from processes running on other computers. As the data needs to be filtered i�m using a custom TableModel derived from AbstractTableModel. I�m creating a new thread for every client that connects as shown in http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html
Now every client thread reads data from its TCP connection and puts it into the JTable by calling the method addRow of the model. But i�m getting strange NullPointerExceptions and IndexOutOfBoundExceptions when data arrives (i�m using ArrayList in the model). These exceptions never show in a single-threaded Swing app (i�ve tested this already, so i don�t think it�s a bug in my model), so i think this is a problem with Swing�s thread unsafety? Do you have any hints on how to get away with it? Also general design tips for a Multi-Client TCP Server /w Swing GUI are greatly appreciated.
Thanks in advance!
Best regards,
Disposable_HeroOf course, but i don�t think it is the model (as said before it works fine in a single thread swing app)
Here�s the code:
public class LogTableModel extends AbstractTableModel{
private Vector dataVector;
private Vector filterVector;
private String[] columnIdentifiers;
private Vector filteredbyProcess;
private Vector filteredbyLoglevel;
private boolean bEnableRefresh;
/** Creates a new instance of LogTableModel */
public LogTableModel() {
dataVector=new Vector(0);
columnIdentifiers=new String[]{"LogTime","HostName","IP","ProcessName","LogLevel","Handle","PID","TID","LogData"};
filteredbyProcess=new Vector(0);
filteredbyLoglevel=new Vector(0);
filterVector=new Vector(0);
bEnableRefresh=true;
public synchronized void enableRefresh(boolean bEnableRefresh){
this.bEnableRefresh=bEnableRefresh;
if(bEnableRefresh){
this.buildIndexListBasedOnFilter();
public synchronized void addRow(LogLine row){
dataVector.add(row);
if(bEnableRefresh)
this.buildIndexListBasedOnFilter();
public synchronized void addFilter(Filter filter){
filterVector.add(filter);
if(filter.isActive())
this.buildIndexListBasedOnFilter();
public synchronized void setFilterActive(String name,boolean active){
int i;
for(i=0;i<filterVector.size();i++)
if(((Filter)filterVector.elementAt(i)).getName().equals(name))
break;
Filter tmp=(Filter)filterVector.elementAt(i);
tmp.setActive(active);
if(active)
this.buildIndexListBasedOnFilter();
public synchronized void setFilterLoglevel(String name,int Loglevel){
int i;
for(i=0;i<filterVector.size();i++)
if(((Filter)filterVector.elementAt(i)).getName().equals(name))
break;
Filter tmp=(Filter)filterVector.elementAt(i);
tmp.setLoglevel(Loglevel);
if(tmp.isActive()==false)
this.buildIndexListBasedOnFilter();
private void buildIndexListBasedOnFilter(){
filteredbyProcess.clear();
filteredbyLoglevel.clear();
applyProcessFilter();
applyLoglevelFilter();
if(bEnableRefresh)
this.fireTableDataChanged();
private void applyProcessFilter(){
LogLine line=null;
Filter filter=null;
for(int i=0;i<dataVector.size();i++){
for(int j=0;j<filterVector.size();j++){
filter=(Filter)filterVector.elementAt(j);
line=(LogLine)dataVector.elementAt(i);
if(filter.isActive()&&(filter.getName().equals(line.getProcessName()))){
line.setHidden(true);
break;
else{
line.setHidden(false);
if(line.getHidden()!=true)
filteredbyProcess.add(new Integer(i));
private void applyLoglevelFilter(){
for(int i=0;i<filteredbyProcess.size();i++){
int index=((Integer)filteredbyProcess.get(i)).intValue();
LogLine line=(LogLine)dataVector.elementAt(index);
for(int j=0;j<filterVector.size();j++){
if(((Filter)filterVector.elementAt(j)).getName().equals(line.getProcessName())){
Filter filter=(Filter)filterVector.elementAt(j);
if((filter.getLoglevel()&line.getLogLevelAsInt())!=line.getLogLevelAsInt())
line.setHidden(true);
else
filteredbyLoglevel.add(new Integer(index));
break;
public synchronized String getColumnName(int columnIndex){
return columnIdentifiers[columnIndex];
public synchronized void clearData(){
dataVector.clear();
filteredbyProcess.clear();
filteredbyLoglevel.clear();
public synchronized int getColumnCount() {
return columnIdentifiers.length;
public synchronized int getRowCount() {
return filteredbyLoglevel.size();
public synchronized Object getValueAt(int rowIndex, int columnIndex) {
int iIndex=((Integer)filteredbyLoglevel.get(rowIndex)).intValue();// hier krachts warum???
LogLine tmp=(LogLine)dataVector.elementAt(iIndex);
switch(columnIndex){
case 0:
return tmp.getLogTime();
case 1:
return tmp.getHostName();
case 2:
return tmp.getIP();
case 3:
return tmp.getProcessName();
case 4:
return tmp.getLogLevel();
case 5:
return tmp.getHandle();
case 6:
return tmp.getProcessID();
case 7:
return tmp.getThreadID();
case 8:
return tmp.getLogData();
default:
return null; -
Why is Encore 6.0 giving me the "blue screen of death" when I try to create a menu?
When I purchased my student edition 6.0 (which I love by the way), Encore did not have any of the libraries loaded up on it. After reading some discussions, I downloaded the missing folders.
Now, when I try to create a menu, my computer shuts down and gives me "the blue screen of death" as they call it (a blue screen with white writting, counting up to 100%, and saying Windows is preparing to crash...or something about the hard drive crashing....I can't remember because it goes off the screen so quickly).
I've done this several times - my computer only does this when I try to create a menu in encore, and not in any other part of encore. It hasn't happened in any of the other programs either (Premiere Pro and Audition are the only other programs I have used so far), or any other times I have my laptop.
Because of this, I am not too concerned since it seems Encore is the problem. However, I do not want any other problems to escalade from this either.
Am I doing something wrong? Can someone please help me? I'm working on my Senior Thesis (a video) this year, and I really really cannot afford to have my computer crash on me.
Please and thank you,
MeghinRead Bill Hunt on BSOD http://forums.adobe.com/thread/772169
-and an Encore fix http://forums.adobe.com/thread/1060443
Maybe you are looking for
-
Master Page Editing in Sharerpoint 2013
I want to add a Clickable image next to . This is what I have tried so far; 1. downloaded seattle.html and seattle.master. 2. Renamed to seattle custom.html and tried to edit it, but the suite bar branding Delegate is not present in the Html file 3.
-
Aperture not uploading to Mobile Me gallery
I have a iMac and MacBook with Aperture 2.1.4 and MacOS 10.6.4. I have been trying to upload a new gallery to my Mobile Me site, to no avail. It goes through the motions like it is uploading, but the gallery never appears when I go to it. I have trie
-
Hey all, I have created a software for a school, and yes I am managing it quite well. I am not very well versed with the latest technologies and the latest design patterns. My software is functioning well but I am facing two problems in it, one of wh
-
How On mouse click on the table [0][m] the pop up window will display
hi , I need your help I am working on a application in which in a table when i click on the first column cell i.e. column must be first and the row may be any then the pop up window will display in swing .For exp if I click on the second row and the
-
Win8 can not find and connect the wireless network which created in win7
I am a fan of DOTA, sometimes i play it with my roommate. But after i installed win8, my roommate and i can not connect to each other. He used win7 to set up a wireless network, but i could not find the network. And i used win8 to set up a wireless n