Close Frame
How is the command for closing a JFrame window. Not hiding but really closing, and but not closing the whole application.
Mark.
By default when the user closes a JFrame the JFrame is hidden but not disposed of. You can change this by doing:
myJFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);This will hide and dispose of the frame when the user closes it. This removes the frame from the screen and frees up any resources used by it.
Similar Messages
-
Double click the icon (upper left) to close frame
hi to all
how can i close a JInternalFrame/JFrame if i will double click
the upper left icon which can be found before the title of the
frame
i don't know that to put, or what kind of listener..
plse someone help...
thanks
kentUse, if the intframe is closable,
jitf.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);but, normally, it is the default behavior.
Have you created your jitf with the "closable" property to "true" ?
Denis -
When I attempt to sign out of Hot Mail by clicking "Sign Out," I get the "Sign In" instruction as I always have, however, the green Firefox navigation button remains on bright green (not going to gray) and my MSN home page will not close automatically as usual. I click on the green arrow and I get an instruction to "Sign Out" again. I click on that and get the "Sign In" again but the arrow stays green. I can repeat this countless times and never get signed out and always remaining on the MSN home page. The only way I can close is to go to File and click on Close Window and then my homepage will close and go back to desktop. I've been using Firefox for a couple of years now (IE prior to that for ten years) and have never had this problem. After using "Close Window" I go back onto my home page, from the desktop, and the navigation button is grayed out normally until I sign in again and we start the cycle over again. Have I been hacked?
== This happened ==
Every time Firefox opened
== Approximately a month ago.I was doing a side-by-side comparison of the new and old server (we backed up the server before the reformat) and I can see that, evidently, CR XI was installed. We have the directory C:\Program Files\Common Files\Business Objects\3.0 and all the versions match what is located in the project's bin directory. Does this confirm that I did have XI installed and licensed at one time?
If I purchase a more recent version, couldn't I update the reports to use the newer version? I have all the source code.
Thanks for your help, it is a nice sanity check for me after hours of reading forums and documentation.
Also, just a shot in the dark, but I'm assuming it wouldn't do me any good to simply restore the aforementioned folder to my C drive? Would that work if I registered all the dll's?
Edited by: Eric Hollering on Dec 2, 2009 6:40 PM
To be clear, I do have VS 2003 & 2005, and I have the source code. I just have never used Crystal Reports in any of my .NET apps because the need wasn't there, so recompiling is not out of the question.
Edited by: Eric Hollering on Dec 2, 2009 6:49 PM
Also, I looked at the CrystalDecisions.CrystalReports.Engine.dll that was in the C:\Program Files\Common Files\Business Objects\3.0\Managed folder and when I right-click and view the properties, then the Version tab, in addition to the 11.0.9500.2 version number, there is a property called Product Version that has the value .NET. Does that mean that this dll was bundled with Visual Studio?
I also found this directory on the old server...does this tell you anything?
C:\Program Files\Business Objects\BusinessObjects Enterprise 11
I did see that you can still buy XI from CDW. I have a call into them currently to check with Business Objects for any registrations from my company.
Edited by: Eric Hollering on Dec 2, 2009 8:27 PM -
Problem to close Frame(not JFrame)
I ese the following method:
class MyWindowAdaptr extends WindowAdapter{
SampleFr1 sampleFr1;
public MyWindowAdaptr(SampleFr1 sampleFr1){
this.sampleFr1=sampleFr1;
public void WindowClosing(WindowEvent we){
System.exit(0);
//dispose();
sampleFr1.setVisible(false);
}But my frame window is not closing.....plz HELP!!!!!Try this:
class MyWindowAdaptr{
SampleFr1 sampleFr1;
public MyWindowAdaptr(SampleFr1 sampleFr1){
this.sampleFr1=sampleFr1;
sampleFr1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sampleFr1.setVisible(true);
} -
Close frame attachments in shopping cart details screen
Hi,
i'm working in SRM rel 5.0 and i have this requirement.
In detail screen of shopping cart document i need to see texts screen but not attachments screen.
I see that this operation is managed by BBP_PDH_TEXT service and there is gs_ui_control_flags structure that have HIDE_ATT_SCREEN field, set to blank.
I try, in debug, to change this value with 'X' and result is that no attachments screen is showed.
How can i set this field? Perhaps in attribute of my service using SICF transaction?
Thank's in advance.
Best regards
Maurizio OrtolaniHi,
We had a similar reqt.However we finally modified the ITS template in service BBP_PDH_TEXT for that.however this will disable the attachement feature for all the documents(SC,Bi etc..) as this is a common template being used across.
The commented statements are:
`BBPGroupBoxBegin(LABEL_ATT_HEADER.label)`
if ( (GV_MODE == "E") || (GV_MODE == "C") || (GV_INTERNAL_ATTACH_MODE == "X") )`
<table><tr><td class="instruction" tabindex="0">`#LBL_ATT_INSTRUCTION`</td></tr></table>
`BBPVSpace()`
`TABLE(class="format")`
`TR()`
`TD(class="label")`<label for="`GS_SCR_TEXT-FILENAME.name`">`#LBL_ATT_DESCRIPTION`</label>
`TD(class="data", nowrap="X")`<input `if (GV_ATT_EDIT_MODE != "")`disabled readonly `end`type="text" id="`GS_SCR_TEXT-FILENAME.name`" name="`GS_SCR_TEXT-FILENAME.name`" value="`GS_SCR_TEXT-FILENAME.value`" maxlength="64" size="30">
`TR()``Lines()`
`if (GV_CONFIG_DEACTIVATE_APPLET != "")`
`TR()`
`TD(class="label")` <label for="`GS_SCR_TEXT_FILEPATH.name`">`#LBL_ATT_PATH`</label>
`TD(class="data", nowrap="X")`<input `if (GV_ATT_EDIT_MODE != "")`disabled readonly `end`type="FILE" id="`GS_SCR_TEXT-FILEPATH.name`" title="`#HELP_ATT_PATHINPUT`" name="`GS_SCR_TEXT-FILEPATH.name`" maxlength="255" size="30">
`TR()``Lines()`
`end`
`if (GS_UI_CONTROL_FLAGS-SHOW_ATT_CATEGORY_SELECTION.value != "")`
`TR()`
`TD(class="label")`<label for="`GS_SCR_TEXT-FILENAME.name`">`#LBL_ATT_CATEGORY_SELECTION`</label>
`TD(class="data", nowrap="X")`
<input type="hidden" name="`GV_CATEGORY_SELECTED.name`" VALUE=" ">
`if (GV_DISABLE_CATEGORY_SELECTION == "")`
`BBPCheckbox (GV_CATEGORY_SELECTED.name,"","X")`
`else`
`BBPCheckbox (GV_CATEGORY_SELECTED.name,"","")`
`end`
`TR()``Lines()`
`end`
`endTABLE()`
`BBPVSpace()`
`BBPButtonBegin()`
`if (GV_CONFIG_DEACTIVATE_APPLET != "")`
`if (GV_ATT_EDIT_MODE == "")`
`BBPButton("TEXT_ATT_ADD", BUTTON_ATT_ADD.label)`
`else`
`BBPDisabledButton(BUTTON_ATT_ADD.label)`
`end`
`else`
`if (GV_ATT_EDIT_MODE == "")`
`BBPButton("", BUTTON_ATT_APPLET_ADD.label,"launchAppletCreate()", "")`
`else`
`BBPDisabledButton(BUTTON_ATT_APPLET_ADD.label)`
`end`
`end`
`BBPButtonEnd()`
`BBPVSpace()`
`BBPVSpace()`
`BBPVSpace()`
`end`
<table><tr><td class="instruction" tabindex="0">`#MSG_ATT_NO_ATTACHMENTS`</td></tr></table>
HTH.
BR,
Disha.
Pls reward points for useful answers. -
Frame 7.2 and InDesign CS3 Distiller conflict
I am using Frame 7.2b128, Distiller 7.0. I recently installed InDesign CS3, which uses Distiller 8.0.
Whenever I work in InDesign and create a final PDF, and then go back to working in Frame and generate a PDF by using Save As ..PDF (working in a book with all files open), I get "Internal Error 7204..."
In the past, the only way I could recover was to uninstall and reinstall Frame. Today even that won't work.
1. How can I generate a PDF in Frame? I get the same error when I use Print to file...
2. How can I configure my system to use either Distiller 7.0 or Distiller 8.0 all the time, and which should it be? Will this fix the problem?Indesign's interaction with Distiller is no different from Frame's: From
either application you can print to the Adobe PDF printer instance. From
there, Acrobat takes over and the originating application (Frame or
Indesign) no longer plays a part in the PDF creation process.
Do you run into the same problem when you Export to PDF from Indesign?
Indesign's Export to PDF does not involve Distiller in any way.
Have you tried redirecting the Adobe PDF printer's output to File,
instead of to the Adobe PDF port (in the Ports tab of the Adobe PDF
printer instance)? This shouldn't change anything for you, except to
separate the two processes (printing and distilling). My guess is that
the error you're seeing is a problem with Distiller, not with Frame. But
if you're printing to the Adobe PDF port it's kind of hard to figure out
where things are going wrong. If you change the port to File, you can
print to a PS file from Frame, close Frame, and then distill the PS
file. Obviously any error you see at that point is not from Frame.
Have you tried uninstalling and reinstalling Acrobat 7?
I wouldn't bother buying Acrobat 8 just to fix this problem, although
uninstalling Acrobat 7 and reinstalling some version of Acrobat might
fix it. Plenty of people are running IDCS3, Frame 7.2, and Acrobat 7
without these problems (me being one of them).
Kenneth Benson
Pegasus Type, Inc.
www.pegtype.com -
// how to close frame
import java.awt.*;*
* import java.awt.event.*;
class Myframe1 extends Frame
public static void main(String args[])
Myframe1 obj = new Myframe1();
obj.setTitle("shekar");
obj.setSize(400,400);
obj.setVisible(true);
obj.addWindowListener(new Myclose());
//to close the frame we should add a listner to the component (frame is also a component)
//we we should add an appropirate listner to a component , this is done by addxxxxxlistener() method
class Myclose implements WindowListener
public void WindowActivated(WindowEvent e){ }
public void WindowClosed(WindowEvent e){ }
public void WindowClosing(WindowEvent e)
System.exit(0);
public void WindowDeactivated(WindowEvent e){ }
public void WindowDeiconified(WindowEvent e){ }
public void WindowIconified(WindowEvent e){ }
public void WindowOpened(WindowEvent e){ }
D:\my programs\awt>javac Myframe1.java
Myframe1.java:22: Myclose is not abstract and does not override abstract method windowDeactivated(java
.awt.event.WindowEvent) in java.awt.event.WindowListener
class Myclose implements WindowListener
^
1 errorThat method is
windowDeactivated
not
WindowDeactivatedWhy are you using AWT, rather than Swing? The Swing JFrame even has a nice little setDefaultCloseOperation(int) method that makes closing the frame, easy. -
Sharing to VideoCamera...lots of dropped frames
Hi,
I am attempting to share an iMovie video creation with my Canon Elura 40MC connected via firewire. The camera is the only thing on the firewire bus.
However, when viewing the iMovie either on the desktop or after sharing with the camera I am getting a LOT of dropped frames and pauses. The video/audio will pause quite often and then start again. It's rather frustrating and I don't know how to fix this. Any ideas on why this is happening and how to solve it? I have shut down other applications (unless I am somehow missing something). I have 768MB of RAM and about 25GB free disk space. Any help or ideas would be much appreciated. Right now I feel like I have wasted all of my time because I have an iMovie that just doesn't "work".
Thanks,
-TigeMacHi Tiger
There are may ways to get in Your situation:
I would:
- Delete iMovie pref files (easiest way I think is to start a new account though
there will be more pref-files than just iMovies that will be re-done)
- May be there are a fragmentation problem. Then if You have an ext FW-disk
then move Your project folder to this and copy it back to Your int hd
OBSERVATION: Only if the ext. HD is Mac OS Extended formatted - if not
You will destroy Your project.
- Take a close (frame to frame) look on Your movie so that the drop-outs aren't
there already. Then You have to redo Your project from the very beginning and
find out why You got the dropouts in the first place.
- Can it be so that You used LP-mode when recording with Your Camera.
If so You got problems: I only been able to save a project once when done this.
I did go to iMovie pref and turn off the function that imports AS INDIVIDUAL CLIPS
so I got my movie as one clip (or several 9.xx min clips)
Then edited from this.
Yours Bengt W -
Im very new too Java(Few Weeks). I have created a compression program in C++ and tried to convert it to Java. Just few mins after i started, i got a problem.
Here it is. I cant close Frame frmMain. Does anybody knows what im doing wrong here?
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import java.*;
public class Compression {
private Frame frmMain = new Frame();
public static void main( String args[] )
new Compression();
Compression()
initGUI();
long getFileSize( String sFile )
return 0;
long fileExist( String sFile )
return 0;
void initGUI()
frmMain.setTitle( "Compression Program" );
frmMain.setSize( 400, 200 );
frmMain.show();
// Not working windowClosing
public boolean handleEvent( Event e )
if( e.id == Event.WINDOW_DESTROY )
System.exit( 0 );
return frmMain.handleEvent( e );
}How to Make Frames:
http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html -
Hi.
I'm writing a software with one frame and in its contentPane in made up with two JPanel which changes continuously. The problem is that when I close that main frame the whole computer stops and seemes to enter into deadlock.
Can someone tell me which is the best method to close frames, dialogs and panels (I think it's the reason for my problem).
Now I'm using setVisible for panels and dialogs.
ThanksTry something like :-
public class MyFrame
extends JFrame
public MyFrame()
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent wndwEvnt)
dispose();
System.exit(0);
}There are other constants (e.g. WindowConstants.DISPOSE_ON_CLOSE if memory serves), that you can use depending on what you want to do when you 'close'. -
Reading from file into an array
Hello, new to Java and we need to modify a mortgage calculator to read interest rate from a file into an array and not have them hard coded in the program. I have read many post on how to perform this but am lost on where to put the new code and format. Here is my code and I hope I posted this right.
import javax.swing.*; // Imports the Main Swing Package
import javax.swing.event.*;
import javax.swing.text.*; // Used for Text Box Caret Position
import java.awt.*; // Imports the main AWT Package
import java.awt.event.*; // Event handling class are defined here
import java.text.NumberFormat;
import java.text.*; // Imports the Main Text Package
import java.util.*; // Imports the Main Utility Package
public class mortgageCalculator1 extends JFrame implements ActionListener // Creates class mortgageCalculator
JLabel AmountLabel = new JLabel(" Enter Mortgage Amount:$ "); // Declares Mortgage Amount Label
JTextField mortgageAmount = new JTextField(10); // Declares Mortgage Amount Text Field
JButton IntandTerm1B = new JButton("7 years at 5.35%"); // Declares 1st Mortgage Term and Interest Rate
JButton IntandTerm2B = new JButton("15 years at 5.50%"); // Declares 2nd Mortgage Term and Interest Rate
JButton IntandTerm3B = new JButton("30 years at 5.75%"); // Declares 3rd Mortgage Term and Interest Rate
JLabel PaymentLabel = new JLabel(" Monthly Payment: "); // Declares Monthly Payment Label
JTextField monthlyPayment = new JTextField(10); // Declares Monthly Payment Text Field
JButton exitButton = new JButton("Exit"); // Declares Exit Button
JButton newcalcButton = new JButton("New Calculation"); // Declares New Calculation Button
JTextArea mortgageTable = new JTextArea(35,65); // Declares Mortgage Table Area
JScrollPane scroll = new JScrollPane(mortgageTable); // Declares ScrollPane and puts the Mortgage Table inside
public mortgageCalculator1() // Creates Method
super("MORTGAGE CALCULATOR"); // Title of Frame
JMenuBar mb = new JMenuBar(); // Cretes Menu Bar
JMenu fileMenu = new JMenu("File"); // Creates File Menu
fileMenu.setMnemonic('F'); // Enables alt + f to Access File Menu
JMenuItem exitItem = new JMenuItem("Exit"); // Creates Exit in File Menu
fileMenu.add(exitItem); // Adds Exit to File Menu
exitItem.addActionListener(new ActionListener() // Adds Action Listener to the Exit Item
public void actionPerformed(ActionEvent e) // Tests to Verify if File->Exit is Pressed
System.exit(0); // Exits the Programs when File->Exit is Pressed
mb.add(fileMenu); // Adds the File Menu
setJMenuBar(mb);
setSize(600, 400); // Sets Size of Frame
setLocation(200,200); // Sets the Location of the Window
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Command on how to close frame
JPanel pane = new JPanel(); // Declares the JPanel
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); // Sets Panel Layout to BoxLayout
Container grid = getContentPane(); // Declares a Container called grid
grid.setLayout(new GridLayout(4,3,5,5)); // Sets grid Layout to GridLayout
pane.add(grid); // Adds the grid to the Panel
pane.add(scroll); // Addes the scrollPane to the Panel
grid.setBackground(Color.yellow); // Set grid color to Yellow
setCursor(new Cursor(Cursor.HAND_CURSOR)); // Makes the cursor look like a hand
mortgageAmount.setBackground(Color.black); // Sets mortgageAmount JPanel JTextField Background Color
mortgageAmount.setForeground(Color.white); // Sets mortgageAmount JPanel JTextField Foreground Color
mortgageAmount.setCaretColor(Color.white); // Sets mortgageAmount JPanel JTextField Caret Color
mortgageAmount.setFont(new Font("Lucida Sans Typewriter", Font.PLAIN, 18)); // Sets mortgageAmount JPanel JTextField Font
monthlyPayment.setBackground(Color.black); // Sets monthlyPayment JPanel JTextField Background Color
monthlyPayment.setForeground(Color.white); // Sets monthlyPayment JPanel JTextField Foreground Color
monthlyPayment.setFont(new Font("Lucida Sans Typewriter", Font.PLAIN, 18)); // Sets monthlyPayment JPanel JTextField Font
mortgageTable.setBackground(Color.yellow); // Sets mortgageTable JTextArea Background Color
mortgageTable.setForeground(Color.black); // Sets mortgageTable JTextArea Foreground Color
mortgageTable.setFont(new Font("Arial", Font.PLAIN, 18)); // Sets JTextArea Font
grid.add(AmountLabel); // Adds the Mortgage Amount Label
grid.add(mortgageAmount); // Adds the Mortgage Amount Text Field
grid.add(IntandTerm1B); // Adds 1st Loan and Rate Button
grid.add(PaymentLabel); // Adds the Payment Label
grid.add(monthlyPayment); // Adds the Monthly Payment Text Field
monthlyPayment.setEditable(false); // Disables editing in this Text Field
grid.add(IntandTerm2B); // Adds 2nd Loan and Rate Button
grid.add(exitButton);
grid.add(newcalcButton); // Adds the New Calc Button
grid.add(IntandTerm3B); // Adds the Exit Button
setContentPane(pane); // Enables the Content Pane
setVisible(true); // Sets JPanel to be Visable
exitButton.addActionListener(this); // Adds Action Listener to the Exit Button
newcalcButton.addActionListener(this); // Adds Action Listener to the New Calc Button
IntandTerm1B.addActionListener(this); // Adds Action Listener to the 1st loan Button
IntandTerm2B.addActionListener(this); // Adds Action Listener to the 2nd loan Button
IntandTerm3B.addActionListener(this); // Adds Action Listener to the 3rd loan Button
mortgageAmount.addActionListener(this); // Adds Action Listener to the Mortgage Amount Text Field
monthlyPayment.addActionListener(this); // Adds Action Listener to the Monthly payment Text Field
public void actionPerformed(ActionEvent e) // Tests to Verify Which Button is Pressed
Object command = e.getSource(); // Enables command to get data
if (command == exitButton) //sets exitButton // Activates the Exit Button
System.exit(0); // Exits from exit button // Exits from exit button
int loanTerm = 0; // Declares loanTerm
if (command == IntandTerm1B) // Activates the 1st Loan Button
loanTerm = 0; // Sets 1st value of Array
if (command == IntandTerm2B) // Activates the 2nd Loan Button
loanTerm = 1; // Sets 2nd value of Array
if (command == IntandTerm3B) // Activates the 3rd Loan Button
loanTerm = 2; // Sets 3rd value of Array
double mortgage = 0; // Declares and Initializes mortgage
double rate = 0; // Declares and Initializes rate
double [][] loans = {{7, 5.35}, {15, 5.50}, {30, 5.75},}; // Array Data for Calculation
try
mortgage = Double.parseDouble(mortgageAmount.getText()); // Gets user input from mortgageAmount Text Field
catch (NumberFormatException nfe) // Checks for correct number fformatting of user input
JOptionPane.showMessageDialog (this, "Error! Invalid input!"); // Outputs error if number is wrong format or nothing is entered
return;
double interestRate = loans [loanTerm][1]; // Sets interestRate amount
double intRate = (interestRate / 100) / 12; // Calculates Interst Rate
double loanTermMonths = loans [loanTerm] [0]; // Calculates Loan Term in Months
int months = (int)loanTermMonths * 12; // Converts Loan Term to Months
double interestRateMonthly = (intRate / 12); // monthly interst rate
double payment = mortgage * intRate / (1 - (Math.pow(1/(1 + intRate), months))); // Calculation for Monthly payment
double remainingLoanBalance = mortgage; // Sets Reamaining Balance
double monthlyPaymentInterest = 0; // holds current interest payment
double monthlyPaymentPrincipal = 0; // holds current principal payment
NumberFormat myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US); // Number formatter to format output in table
monthlyPayment.setText(myCurrencyFormatter.format(payment));
mortgageTable.setText("Month\tPrincipal\tInterest\tEnding Balance\n" + // Formats morgageTable Header
"---------\t----------\t------------\t---------------------\n");
for (;months > 0 ; months -- )
monthlyPaymentInterest = (remainingLoanBalance * intRate); // Calculation for Monthly Payment Toward Interest
//Calculate H = R x I
monthlyPaymentPrincipal = (payment - monthlyPaymentInterest); // Calculation for Monthly Payment Toward Principal
//Calculate C = P - H
remainingLoanBalance = (remainingLoanBalance - monthlyPaymentPrincipal); // Calculation for Reamining loan Balance
// Calculate R = R - C
// H = monthlyPaymentInterest
// R = remainingLoanBalance
// P = payment
// C = monthlyPaymentPrincipal
// I = interestRateMonthly
mortgageTable.setCaret (new DefaultCaret()); // Sets Scroll position to the top left corner
mortgageTable.append(String.valueOf(months) + "\t" + // Pulls in data and formats MortgageTable
myCurrencyFormatter.format(monthlyPaymentPrincipal) + "\t" +
myCurrencyFormatter.format(monthlyPaymentInterest) + "\t" +
myCurrencyFormatter.format(remainingLoanBalance) + "\n");
if(command == newcalcButton) // Activates the new calculation Button
mortgageAmount.setText(null); //clears mortgage amount fields
monthlyPayment.setText(null); //clears monthly payment fields
mortgageTable.setText(null); //clears mortgage table
public static void main(String[] args) //This is the signature of the entry point of all the desktop apps
new mortgageCalculator1();
}OK, making a little progress but am still very confused.
What I have is a file (int&term.dat) with three lines;
5.75, 30
5.5, 15
5.35 ,7
I have three JButtom that I what to read a seperate line and place the term in a term TextField and a rate in a Rate TextField
I have added the following code and all it does now is output a black space to the screen; I am working with one Button and Just the rate for now to try and get it to work. I have been looking at the forums, reading the internet and several books to try and figure this out. I think I may be getting closer.
public static void read()
String line;
StringTokenizer tokenizer;
String rate;
String term;
try
FileReader fr = new FileReader ("int&term.dat");
BufferedReader inFile = new BufferedReader (fr);
line = inFile.readLine();
while (line != null)
tokenizer = new StringTokenizer(line);
rate = tokenizer.nextToken();
line = inFile.readLine();
inFile.close();
System.out.println(new String());
catch (FileNotFoundException exception)
System.out.println ("The file was not found.");
catch (IOException exception)
System.out.println (exception);
} -
How can I add JScrollpane to one of the panels of a JFrame????
I want to generate a screen with one JFrame and two JPanels.one panel to the left of the Frame and another to the right.
I want to add a Jscrollpane to left panel,to which i am adding images so that they can be scrolled.How can I achieve this ???????????
please reply me.............
this is Basic Frame class.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class BasicFrame
private JFrame frame = null;
private JPanel CanvasPanel = new JPanel();
private JPanel libraryPanel = null;
public static void main(String args[])
new BasicFrame();
public BasicFrame()
frame = new JFrame( "Java3d Demo of VRML Loading ");
frame.setSize( 800, 600 );
frame.setLayout(new BorderLayout());
frame.add(CanvasPanel,BorderLayout.EAST);
frame.add(new LibraryPanel(),BorderLayout.WEST);
frame.setMenuBar(createMenuBar());
frame.setVisible( true );
// kill the window on close
frame.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent winEvent)
System.exit(0);
public MenuBar createMenuBar()
MenuBar menubar = new MenuBar();
Menu menu;
Menu subMenu;
MenuItem menuItem;
menu = new Menu("File");
menuItem = new MenuItem("New");
menu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("Load");
menu.add(menuItem);
//menuItem.addActionListener(this);
subMenu = new Menu("Save");
menu.add(subMenu);
menuItem = new MenuItem("VRML97");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("X3D");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
subMenu = new Menu("Print");
menu.add(subMenu);
menuItem = new MenuItem("VRML97");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("X3D");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("Quit");
menu.add(menuItem);
//menuItem.addActionListener(this);
menubar.add(menu);
menu = new Menu("View");
menuItem = new MenuItem("Reset");
menu.add(menuItem);
menuItem.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
menubar.add(menu);
return menubar;
this is Library panel class.To this,I want to add Jscrollpane to scroll the images displayed in this panel.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class LibraryPanel extends JPanel
private ArrayList<String> imageList = new ArrayList<String>();
private ImageIcon imageIcon;
private JLabel imageLabel[] = new JLabel[100];
private String path = "small images";
private JList list;
LibraryPanel()
setSize(400, 600);
setBorder(BorderFactory.createLineBorder(Color.black));
setLayout(new FlowLayout());
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
indexFiles();
for(int imageNo=0;imageNo<imageList.size();imageNo++)
try
imageIcon = new ImageIcon(path + "/" + imageList.get(imageNo));
imageLabel[imageNo] = new JLabel(imageIcon);
//scrollPane.getViewport().
add(imageLabel[imageNo]);
catch (IllegalArgumentException illegalArgEx)
illegalArgEx.printStackTrace();
add(comboBox(),FlowLayout.CENTER);
add(vbar,FlowLayout.CENTER);
public JComboBox comboBox()
String[] comboTypes = { "Sachin", "YuvRaj", "Ganguly", "Dravid", "Sehwag", "Dhoni" };
// Create the combo box, and set 2nd item as Default
JComboBox comboTypesList = new JComboBox(comboTypes);
comboTypesList.setSelectedIndex(0);
return comboTypesList;
public void indexFiles()
File dir = new File(path);
String[] children = dir.list();
if (children == null)
System.err.println("Error: The directory doesn't exists!");
System.exit(1);
else
imageList.ensureCapacity(children.length);
for (int i = 0; i < children.length; i++)
if(children.endsWith(".jpg"))
imageList.add(children[i]);
please reply meimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class BasicFrame
private JFrame frame = null;
private JPanel CanvasPanel = new JPanel();
private JPanel libraryPanel = null;
public static void main(String args[])
new BasicFrame();
public BasicFrame()
frame = new JFrame( "Java3d Demo of VRML Loading ");
frame.setSize( 800, 600 );
frame.setLayout(new BorderLayout());
frame.add(CanvasPanel,BorderLayout.EAST);
frame.add(new LibraryPanel(),BorderLayout.WEST);
frame.setMenuBar(createMenuBar());
frame.setVisible( true );
// kill the window on close
frame.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent winEvent)
System.exit(0);
public MenuBar createMenuBar()
MenuBar menubar = new MenuBar();
Menu menu;
Menu subMenu;
MenuItem menuItem;
menu = new Menu("File");
menuItem = new MenuItem("New");
menu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("Load");
menu.add(menuItem);
//menuItem.addActionListener(this);
subMenu = new Menu("Save");
menu.add(subMenu);
menuItem = new MenuItem("VRML97");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("X3D");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
subMenu = new Menu("Print");
menu.add(subMenu);
menuItem = new MenuItem("VRML97");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("X3D");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("Quit");
menu.add(menuItem);
//menuItem.addActionListener(this);
menubar.add(menu);
menu = new Menu("View");
menuItem = new MenuItem("Reset");
menu.add(menuItem);
menuItem.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
menubar.add(menu);
return menubar;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class LibraryPanel extends JPanel
private ArrayList<String> imageList = new ArrayList<String>();
private ImageIcon imageIcon;
private JLabel imageLabel[] = new JLabel[100];
private String path = "small images";
private JList list;
LibraryPanel()
setSize(400, 600);
setBorder(BorderFactory.createLineBorder(Color.black));
setLayout(new FlowLayout());
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
indexFiles();
for(int imageNo=0;imageNo<imageList.size();imageNo++)
try
imageIcon = new ImageIcon(path + "/" + imageList.get(imageNo));
imageLabel[imageNo] = new JLabel(imageIcon);
//scrollPane.getViewport().
add(imageLabel[imageNo]);
catch (IllegalArgumentException illegalArgEx)
illegalArgEx.printStackTrace();
add(comboBox(),FlowLayout.CENTER);
add(vbar,FlowLayout.CENTER);
public JComboBox comboBox()
String[] comboTypes = { "Sachin", "YuvRaj", "Ganguly", "Dravid", "Sehwag", "Dhoni" };
// Create the combo box, and set 2nd item as Default
JComboBox comboTypesList = new JComboBox(comboTypes);
comboTypesList.setSelectedIndex(0);
return comboTypesList;
public void indexFiles()
File dir = new File(path);
String[] children = dir.list();
if (children == null)
System.err.println("Error: The directory doesn't exists!");
System.exit(1);
else
imageList.ensureCapacity(children.length);
for (int i = 0; i < children.length; i++)
if(children.endsWith(".jpg"))
imageList.add(children[i]); -
This is a fix.
I typically use Framemaker to edit structured DITA xml documents. I recently got a Win 7/64 bit machine and decided this was a good time to upgrade to Framemaker 9. I installed Frame 9 directly onto this new machine. It worked fine with my xml files.
Then I had to switch projects and work on some unstructured documents. In order to document the application these unstructured documents were for I had to turn off Windows Themes, as the application I needed to document had display problems with those on. After I finished the unstructured documentation, I switched back to my DITA XML documents. But they would not open. I selected an XML file from the Open dialog and immediately FrameMaker 9 crashed. I tried turning Themes back on and chose the recommended Aero theme. No change. My XML files still crashed FrameMaker 9 as soon as I selected one to open. The error message came post-crash and did not come from FrameMaker: it said Windows was trying to find some information about the crash, but could not find any.
This problem may be specific to DITA or it may occur with other structured-unstructured switches. I don't know, I only work with DITA XML.
But I just found a workaround and would like to share it in case anyone else encounters this:
1. Open an unstructured file.
2. In the upper right corner of the screen you’ll see AUTHORING. Open the drop-down and choose DITA AUTHORING (or whatever type you use for structured documents).
3. Open the Structure Tools menu and select Set Structured Application.
4. In the dialog, select the structure application you want to use with the XML file you want to open, DITA-TOPIC-FM, for example.
5. Now open a structured XML file. It will open now.
6. Close the unstructured document without saving any changes to it.
7. Save your structured document then work with it.You only have to do this once. The next time you open an XML file, FrameMaker will open it correctly. It persists even after you close Frame 9 and reopen it.
It suprised me that Framemaker 9 didn't automatically switch back to Dita/structured mode upon opening an XML file, but I was glad there was an easy way to fix this.pvanbavel wrote:
crashes no MATTER what I try-- administrator mode FAIL. upgrade to version 2 FAIL. uniinstall followed by complete registry cleanup then reinstall FAIL.
Contacted customer service-- their ownly solution is to pull out the memory card and use a card reader. Not acceptable because that does NOT create folders by day-- an extremely usefull tool if you take a lot of pictures. nor does it prevent multiple loads of files. customer service intidicated the software was written by an unknown australian company-- no information on who they are or how to contact them.
It used to work just fine and still works on my laptop also using windows 7 64 bit.
A suspicious item is that it always asks for permission to modify or install software, long after it was installed; shows the standard windows dialog when loading new software. suggesting that an attempt is made to modify a protected or forbidden file region.
I would like to see a serious attempt by canon to solve this problem, its gone on too long and many others have it.
The program runs on your laptop and on countless other 64-bit Windows 7 computers - including one located less than three feet from me as I type this. It doesn't run on your other computer, and the error messages suggest a file permission problem. And it's Canon's fault. That may be true; Canon's software is certainly not bug-free. But if I were a betting man, I'd bet that your problem is in your computer.
Bob
Boston, Massachusetts USA -
Can't insert text cursor; text is selected as image?
Hi all. Occasionally, as I type in Structured FrameMaker, this happens.
When I try to insert a text cursor the entire page is selected with black dots in the page corners and the middle of each margin. Basically the page is selcted as if it were an image and I can not insert a cursor; all it does is select the page as one entity (with the black dots). I don't even know what this is and the only way I seem to be able to fix it is to close Frame and restart Windows (just closing doesn't work). Can someone tell me what this is and how I can rectify this situation without closing FrameMaker?
A hint: I think this happens if I accidentally click one of the modifier keys (CTL, Command, etc.) but nothing I do after changes it back. I am using Frame in Virtual Box Windows on a Mac.
thanks
michaelThanks for the response. I have done the margin thing ad nauseum and it never works. I do see a hollow arrow that appears so I will remember the crtl+click and see if that works but the outside the margin did nothing except allow me to select the text as an image again when I went back inside the margin. (The cursor changed back into a hollow arrow when I went back inside the margin.)
michael -
Hi, odd error in my code with a draw circle method
Hey, I am a first year computer science student who uses java in class.
We have recently been playing with guis
I have created code that when it runs it draws random circles with random gradiants.
However, the code will sometimes draw a random square, any ideas.
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
* Class for animations, if I dont finish this lab I will have egg on my face
public class AnimationStation {
private JFrame frame; //the jframe
private IView viewer; //the viewer
* Constructor
public AnimationStation() {
frame = new JFrame(); //makes jframe
viewer = new IView(); //makes iview
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //window closes
frame.setSize(300, 500); //biggie or smallie
frame.getContentPane().add(BorderLayout.CENTER,viewer); //place it
frame.setVisible(true);
* Main Method
public static void main(String[] args) {
AnimationStation cutie = new AnimationStation();
* The IView inner class
class IView extends JPanel {
int x = 0; //x pos
int y = 0; //w pos
int d = 0; //diameter
Color randomColor1; //random color
Color randomColor2; // random color
private boolean imageOn = true; //do we care about the background, or are we looking for that square?
* Default constructor
public IView() {
//wonders... is this neccessary.... ::thinks:: well it works so lets not mess with it
* Builds our pretty pictures
public void paintComponent(Graphics g) {
g.setColor(Color.white); //make background
g.fillRect(0,0,this.getWidth(),this.getHeight()); //background
for(int x = 0; x < 10; x++) { //no? draw ovals
drawOval(g);
* Method to make ovals
*(and apparently a random square, although I think its good luck if you do! So its a feature, not a bug)
public void drawOval(Graphics g) {
d = (int)((Math.random() * 10) + (this.getWidth() / 5)); //set diameter
x = (int)(Math.random() * (this.getWidth() - d)); //set x dont let it off the screen
y = (int)(Math.random() * (this.getHeight() - d)); //set y dont let it off the screen
randomColor1 = randomColor(); //set random color one
randomColor2 = randomColor(); //set random color two
Graphics2D g2d = (Graphics2D) g; //make a graphics 2d object, helps with gradiants
GradientPaint gradient; //make gradiant
gradient = new GradientPaint(x, y, randomColor1, x+d, y+d, randomColor2); //set gradiant
g2d.setPaint(gradient); //set paint
g2d.fillOval(x,y,d,d); //make that oval
* Method which makes a random color
public Color randomColor() {
Color a = new Color((int)(Math.random() * 255), (int)(Math.random() * 255), (int)(Math.random() * 255));
return a;
* Checks to see if a file is an image file (I REALLY hope this is not how other programs do it,
* becuase technically I can make this a graphic "mv ImageViewer.java fake.gif")
public boolean isImageFile(String filename) {
String ending = "" + filename.charAt(filename.length() - 4) + filename.charAt(filename.length() - 3) + filename.charAt(filename.length() - 2) +
filename.charAt(filename.length() - 1); //make a string with the last four letters
if(ending.equalsIgnoreCase(".jpg") || ending.equalsIgnoreCase(".gif") || ending.equalsIgnoreCase(".bmp")) { //is it an image?
return true; //yes
} else {
return false; //no
}thanks,
Bachmannwell, let me explain some more. Its more of an irritation, then a crippling error....
The squares are quite clear. I mean, its not like a small circle that looks squareish, I have seen a square appear and it could be larger than the circles that I see.
It is also very rare, so yeah, it could have something to do with the random aspects.
It just kinda bothers me since nither me, my classmates, or my professor can figure out why this happens and no one else has mentioned this problem.
Maybe you are looking for
-
How can I tell if my iPhone has been hacked?
First off, I have an iPhone 5s with the most recent software. Today, out of the blue, my phone started showing the cellular provider as 'Maritime' instead of AT&T. I Googled around and saw some sort of joint venture thing that AT&T has with providing
-
Bapi wrapper- MODIFY Wrapper For SyncBo
Modify Wrapper :ZGET_AM_P2P For SyncBO I have read the requirement : -replace entire item data with entries of table parameters pls tell me the code will work or not if i put in syncBo someone pls help me..... FUNCTION ZGET_AM_P2P. ""Local interface:
-
FITE_EXPENSES -- Available Travel Requests / Plans
Hi Experts, I've got a question concerning the creation of travel expenses and the data acquisition of the respective travel request. Let's say I've sent a Travel Request and it has been approved by the respective approver, i.e. status of the process
-
Is it normal for every line, including the primary line to have a $9.99 Line Charge? We have an $80 plan with three lines and all three of them have a $9.99 Line Charge. I thought the $80 included the first line.
-
Prematurely exit enumeration loop
i am enumerating thru a loop upon a certain condition, i want to exit the loop, while keeping the object of the current enumeration in tact. Foo foo = null; Enumeration = fooVector.elements(); while(Enumeration.hasMoreElements()) foo = (Foo) enumer