JMenus with (JApplet inside JInternalFrame)
Hi all,
I am trying to display a JApple in JInternalFrame, all this components are in a JFrame with some JMenus
The problem: when I click a JMenu to display its JMenuItems, these JMenuItems appears to be displayed behind the JApplet.
Can any expert help me with this??
My code is something like that:
import java.awt.*;
import javax.swing.*;
public class MyFrame extends JFrame
public MyFrame()
super("My Frame");
//Create the menu bar.
JMenuBar menuBar = new JMenuBar();
this.setJMenuBar(menuBar);
//create Menus and add them to the MenuBar
JMenu fileMenu = new JMenu("File");
JMenu playMenu = new JMenu("Play");
menuBar.add(fileMenu);
menuBar.add(playMenu);
//Create MenuItems
JMenuItem new1 = new JMenuItem("New...");
JMenuItem open = new JMenuItem("Open...");
JMenuItem exit = new JMenuItem("Exit");
JMenuItem start = new JMenuItem("Start");
JMenuItem stop = new JMenuItem("Stop");
JMenuItem next = new JMenuItem("Next");
JMenuItem previous = new JMenuItem("Previous");
//add menuItems in the menus
fileMenu.add(new1);
fileMenu.add(open);
fileMenu.addSeparator();
fileMenu.add(exit);
playMenu.add(start);
playMenu.add(stop);
playMenu.add(next);
playMenu.add(previous);
//Internal Frame in the CENTER
JInternalFrame internalFrame = new JInternalFrame("Internal Frame", false, false, false);
this.add(internalFrame, BorderLayout.CENTER);
internalFrame.add(new JApplet());
internalFrame.pack();
internalFrame.setVisible(true);
public static void main(String[] args)
JFrame frame = new MyFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
frame.setExtendedState(MAXIMIZED_BOTH);
}
You need to set the menus to be heavyweight:
fileMenu.getPopupMenu().setLightWeightPopupEnabled(false);
playMenu.getPopupMenu().setLightWeightPopupEnabled(false);Read here about it:
http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#popup
Also usually, you add internal frames to a desktop pane.
Read the tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html
Similar Messages
-
Cursor problem when using inside JInternalFrame
HI there,
My problem is describe below:
JDK Environment: 1.3
Scenario: A JLabel with a mouseListener inside a JInternalFrame. The mouseListener listen to the mouseEntered and mouseExited event. When it is mouseEntered event,it change to Cursor.HAND_CURSOR , when it is mouseExited event,it change to Cursor.DEFAULT_CURSOR. This works fine inside JInternalFrame. I had tested that...
The problem occurs when the mouse move OUTSIDE of the JInternalFrame. The cursor won't convert anymore after the mouse move outside the Jinternalframe, is it a swing bug? any suggestion there?
Thank you.
Application Developer,
Chin
---------code attached for clarification -----------------
label.addMouseListener(new MouseAdapter(){
public void mouseEntered(MouseEvent me){
frame.getContentPane().setCursor (Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
public void mouseExited(MouseEvent me){
frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
WHERE label sit inside a JInternalFrame...I believe you are setting the cursor to far back in the containment hiearchy. Each JComponent could have a separate Cursor. I cannot recall how to make a JInternalFrame active so you'll have to click it to see the Cursors on the Iframeimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CursorTest extends JFrame
private JDesktopPane desk;
private JInternalFrame f;
private JLabel l;
public CursorTest()
super("Cursor Test");
setSize(500, 400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
l = new JLabel("Point Mouse Here");
l.setCursor (Cursor.getPredefinedCursor
(Cursor.HAND_CURSOR));
f = new JInternalFrame("Cursor Zone",
true, true, true, true);
f.getContentPane().setLayout(new FlowLayout());
((JComponent)f.getContentPane()).setCursor
(Cursor.getPredefinedCursor
(Cursor.CROSSHAIR_CURSOR));
f.getContentPane().add(l);
f.setVisible(true);
desk = new JDesktopPane();
desk.setCursor(Cursor.getPredefinedCursor
(Cursor.MOVE_CURSOR));
desk.add(f);
f.setBounds(50, 50, 144, 89);
setLayeredPane(desk);
public static void main(String[] args)
CursorTest cT = new CursorTest();
cT.setVisible(true);
cT.desk.getDesktopManager().
activateFrame(cT.f);
} -
JButtons in JToolbar don't work with JApplet- why?
I made a JApplet which has a toolbar, populated with burrons that manipulate data from text files. The programs works perfectly when it is not a JApplet. However, once I converted it to a JApplet it does nothing. The code was exactly the same, but, pressing buttons does nothing when it is an applet. here is the complete code;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class CSE extends JApplet implements ActionListener, ItemListener
//GUI COMPONENTS
//ToolBar components
JToolBar mainSelect = new JToolBar("Materials");
JButton materials;
String materialNames[] = {"Fur Square", "Bolt of Linen", "Bolt of Damask", "Bolt of Silk", "Glob of Ectoplasm", "Steel Ingot", "Deldrimor Steel Ingot", "Monstrous Claw", "Monstrous Eye", "Monstrous Fang", "Ruby", "Lump of Charcoal", "Obsidian Shard", "Tempered Glass Vial", "Leather Square", "Elonian Leather Square", "Vial of Ink", "Roll of Parchment", "Roll of Vellum", "Spiritwood Plank", "Amber Chunk", "Jadeite Shard"};
ImageIcon materialIcons;
//Graphic components
JDesktopPane mainGraph = new JDesktopPane();
JPanel dailyGraph = new JPanel();
JPanel weeklyGraph = new JPanel();
JPanel finalPrices = new JPanel();
Box graphs = Box.createHorizontalBox();
//The Console
JFrame CSEFrame = new JFrame();
JSplitPane mainConsoleBackdrop = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
JSplitPane dataOut = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
JTextArea prediction = new JTextArea(10,10);
JScrollPane predictionScroll;
Box finalPricesLabels = Box.createVerticalBox();
Box finalPricesLay = Box.createVerticalBox();
JLabel finalBuy = new JLabel("Net Buy Price Change: 0.00");
JLabel finalSell = new JLabel("Net Sell Price Change: 0.00");
JLabel buySell = new JLabel("We recommend you: N/A");
JTextArea priceUpdate = new JTextArea(10, 10);
JTextArea priceUpdateWeekly = new JTextArea(10, 10);
JScrollPane priceUScrollW;
JScrollPane priceUScroll;
JCheckBox weeklySelect = new JCheckBox("To show weekly price changes.", false);
JCheckBox dailySelect = new JCheckBox("To show daily price changes.", true);
ButtonGroup dataToShow = new ButtonGroup();
//COMPONENTS FOR DATE; OBTAINING CORRECT FOLDER
String days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
Calendar calSource = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
int day = calSource.get(Calendar.DAY_OF_MONTH);
int month = calSource.get(Calendar.MONTH);
int year = calSource.get(Calendar.YEAR);
int monthCheck [] = {Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER};
int dayS = day;
int monthS = month;
int yearS = year;
//if there is file found
boolean proceed = false;
//int data for analysis
int buyPrice;
int currentBuyPrice;
int sellPrice;
int currentSellPrice;
boolean weekly = false;
//tools for parsing and decoding input
String inputS = null;
String s = null;
Scanner [] week = new Scanner[7];
Scanner scanner;
int position = 0;
//weekly tools
String weekPos[] = {"Seventh", "Sixth", "Fifth", "Fourth", "Third", "Second", "First"};
int dayOfWeek = 0; //0 = 7 1 = 6...
public JButton getToolBarButton(String s)
String imgLoc = "TBar Icons/" +s +".gif";
java.net.URL imgURL = CSE.class.getResource(imgLoc);
JButton button = new JButton();
button.setActionCommand(s);
button.setToolTipText(s);
button.addActionListener(this);
if(imgURL != null)
button.setIcon(new ImageIcon(imgURL, s));
else
button.setText(s);
System.err.println("Couldn't find; " +imgLoc);
return button;
public CSE()
// super("Test CSE");
//CSEFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for(int x=0; x<materialNames.length; x++)
materials = getToolBarButton(materialNames[x]);
mainSelect.add(materials);
//checkBoxes
dataToShow.add(weeklySelect);
dataToShow.add(dailySelect);
weeklySelect.addItemListener(this);
dailySelect.addItemListener(this);
// sizes
setSize(850, 850);
//colors and fonts
weeklyGraph.setBackground(new Color(250, 30, 40));
dailyGraph.setBackground(new Color(100, 40, 200));
//text Manip.
prediction.setLineWrap(true);
priceUpdate.setLineWrap(true);
//scrolling
predictionScroll = new JScrollPane(prediction, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
priceUScroll = new JScrollPane(priceUpdate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
priceUScrollW = new JScrollPane(priceUpdateWeekly, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//main splitpane config.
mainConsoleBackdrop.setOneTouchExpandable(true);
mainConsoleBackdrop.setResizeWeight(.85);
//placement and Layout
//GraphLayout
graphs.add(Box.createHorizontalStrut(10));
graphs.add(dailyGraph);
graphs.add(Box.createHorizontalStrut(10));
graphs.add(weeklyGraph);
graphs.add(Box.createHorizontalStrut(10));
dataOut.setRightComponent(predictionScroll);
//consoleData layout
finalPricesLabels.add(Box.createVerticalStrut(10));
finalPricesLabels.add(finalBuy);
finalPricesLabels.add(Box.createVerticalStrut(10));
finalPricesLabels.add(finalSell);
finalPricesLabels.add(Box.createVerticalStrut(10));
finalPricesLabels.add(buySell);
finalPricesLay.add(finalPricesLabels);
finalPricesLay.add(Box.createVerticalStrut(10));
finalPricesLay.add(weeklySelect);
finalPricesLay.add(dailySelect);
finalPricesLay.add(priceUScroll);
dataOut.setLeftComponent(finalPricesLay);
mainConsoleBackdrop.setTopComponent(graphs);
mainConsoleBackdrop.setBottomComponent(dataOut);
getContentPane().add(mainConsoleBackdrop);
getContentPane().add(mainSelect, BorderLayout.NORTH);
//visibility
// CSEFrame.setVisible(true);
//return(CSEFrame);
public void actionPerformed(ActionEvent e)
getMonth();
inputS = e.getActionCommand();
FileReader newRead = null;
try {
newRead = new FileReader(monthS +"-" +dayS +"-" +yearS +"/" +inputS +".dat");
proceed = true;
catch(FileNotFoundException f)
System.out.println("File not found");
proceed = false;
if(proceed)
BufferedReader bufferedReader = new BufferedReader(newRead);
scanner = new Scanner(bufferedReader);
scanner.useDelimiter("\n");
//starts daily analysis
getPrice(scanner);
//starts weekly analysis
weekly(inputS);
public void itemStateChanged(ItemEvent e)
if(weeklySelect.isSelected())
priceUpdateWeekly.setText("");
finalPricesLay.remove(priceUScroll);
finalPricesLay.add(priceUScrollW);
finalPrices.updateUI();
else
priceUpdate.setText("");
finalPricesLay.remove(priceUScrollW);
finalPricesLay.add(priceUScroll);
finalPrices.updateUI();
public void weekly(String inputS)
weekly = true;
for(int x = 0; x < 7; x++)
dateToUse(month, day, year, (x+1));
try
FileReader weeklySource = new FileReader(monthS +"-" +dayS +"-" +year +"/" +inputS +".dat");
BufferedReader weeklyBuffer = new BufferedReader(weeklySource);
week[x] = new Scanner(weeklyBuffer);
week[x].useDelimiter("\n");
getPrice(week[x]);
catch(FileNotFoundException f)
JOptionPane.showMessageDialog(this, "No such weekly files- going back;" +(x+1) +"days");
weekly = false;
dateReset();
public void getPrice(Scanner scanner)
while(scanner.hasNextLine())
//puts into string the next scan token
String s = scanner.next();
//takes the scan toke above and puts it into an editable enviroment
String [] data = s.split("\\s");
for(position = 0; position < data.length; position++)
//Scanner test to make sure loop can finish, otherwise "no such line" error
if(scanner.hasNextLine()==false)
scanner.close();
break;
/*Starts data orignazation by reading from each perspective field
* 1 = day
* 2 = day of month
* 3 = month
* 4 = year
if(position == 0 && weekly == false)
String dayFromFile = data[position];
int dayNum = Integer.parseInt(dayFromFile);
priceUpdate.append(days[dayNum-1] +" ");
else if(position == 1 && weekly == false )
priceUpdate.append(data[position] + "/");
else if(position == 2 && weekly == false)
priceUpdate.append(data[position] + "/");
else if(position == 3 && weekly == false)
priceUpdate.append(data[position] +"\n");
//if it is in [buy] area, it prints and computes
else if(position == 7)
//obtains string for buy price and stores it, then prints it
String buy = data[position];
if(weekly == false)
priceUpdate.append("Buy: " +buy +"\n" );
//converts buy to string
currentBuyPrice = Integer.parseInt(buy);
//eliminates problems caused by no data from server- makes the price 0
if(currentBuyPrice < 0)
currentBuyPrice = 0;
//if it is greater it adds
if(currentBuyPrice > buyPrice)
buyPrice += currentBuyPrice;
//if it is equal [there is no change] then it does nothing
if(currentBuyPrice == buyPrice)
buyPrice +=0;
//if there is a drop, it subtracts
else
buyPrice -= currentBuyPrice;
//if it is in [sell] area, it prints, and resets the position to zero because line is over
else if(position == 8)
//puts sell data into string and prints it
String sell = data[position];
if(weekly == false)
priceUpdate.append("Sell: " + sell +"\n");
//turns sell data into int.
currentSellPrice = Integer.valueOf(sell).intValue();;
//gets rid of problems caused by no data on server side- makes it 0
if(currentSellPrice < 0)
currentSellPrice = 0;
//adds if there is an increase
if(currentSellPrice > sellPrice)
sellPrice += currentSellPrice;
//does nothing if it is the same
if(currentSellPrice == sellPrice)
sellPrice +=0;
//subtracts if there is drop
else
sellPrice -= currentSellPrice;
//further protection against "No such line" and moves it down
if(scanner.hasNextLine() == true)
scanner.nextLine();
//if scanner is finished, prints out all lines
if(scanner.hasNextLine() == false && weekly == false)
finalBuy.setText("Net Buy Price Change: "+buyPrice);
finalSell.setText("Net Sell Price Change: " +sellPrice);
buyPrice = 0;
sellPrice = 0;
position = data.length;
else if(scanner.hasNextLine() == false && weekly == true)
priceUpdateWeekly.append("\n" +weekPos[dayOfWeek] +" day of the week ended with; \nBuy Price;" +buyPrice +"\nSell Price;" +sellPrice);
buyPrice = 0;
sellPrice = 0;
position = data.length;
dayOfWeek++;
if(dayOfWeek > 6)
dayOfWeek = 0;
public void getMonth()
for(int x=0; x < monthCheck.length; x++)
if(month == monthCheck[x])
monthS = (x+1);
x = monthCheck.length;
public void dateToUse(int month, int day, int year, int increment)
//set day of source
dayS = (day - increment);
//if day of source is less then O then we have moved to another month
if(dayS <= 0)
//checks the difference between how much we have incremented and the day we have started; this tells us how far into the new month we are
int incrementDay = increment - day;
//decrements month
monthS--;
//if month is less then zero, then we have moved into another year and month has become 12
if(monthS <= 0)
yearS--;
monthS = 12;
//the following looks at the current month and if it goes below it assigns the day to the proper ammount of days of the month before minus the days into the month
if(month == 3)
dayS = 28 - incrementDay;
else if(month == 5 || month == 7)
dayS = 29 - incrementDay;
else if(month == 2 || month == 4 || month == 6 || month == 9 || month == 11)
dayS = 31 - incrementDay;
else
dayS = 30 - incrementDay;
//resets the source date to the current date once data from the week has been reached
public void dateReset()
dayS = day;
monthS = month;
yearS = year;
public void init()
//JFrame frame = new CSEFrameSet();
// this.setContentPane(CSEFrameSet());
CSE aCSE = new CSE();
public static void main(String [] args)
CSE cs = new CSE();
}I have tried uploading it to a server, running it from appletviewer, and locally using the .HTML file. The GUI works fine, everything is there, however, pressing the buttons does nothing.
Can you not use the Scanners and such with JApplets?
Yes, the directories are good.
EDIT EDIT EDIT; OK, it works with appletviewer, but still doesn't work when it is published.
Message waI can't seem to edit the post anymore, here it is again;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class CSE extends JApplet implements ActionListener, ItemListener
//GUI COMPONENTS
//ToolBar components
JToolBar mainSelect = new JToolBar("Materials");
JButton materials;
String materialNames[] = {"Fur Square", "Bolt of Linen", "Bolt of Damask", "Bolt of Silk", "Glob of Ectoplasm", "Steel Ingot", "Deldrimor Steel Ingot", "Monstrous Claw", "Monstrous Eye", "Monstrous Fang", "Ruby", "Lump of Charcoal", "Obsidian Shard", "Tempered Glass Vial", "Leather Square", "Elonian Leather Square", "Vial of Ink", "Roll of Parchment", "Roll of Vellum", "Spiritwood Plank", "Amber Chunk", "Jadeite Shard"};
ImageIcon materialIcons;
//Graphic components
JDesktopPane mainGraph = new JDesktopPane();
JPanel dailyGraph = new JPanel();
JPanel weeklyGraph = new JPanel();
JPanel finalPrices = new JPanel();
Box graphs = Box.createHorizontalBox();
//The Console
JFrame CSEFrame = new JFrame();
JSplitPane mainConsoleBackdrop = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
JSplitPane dataOut = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
JTextArea prediction = new JTextArea(10,10);
JScrollPane predictionScroll;
Box finalPricesLabels = Box.createVerticalBox();
Box finalPricesLay = Box.createVerticalBox();
JLabel finalBuy = new JLabel("Net Buy Price Change: 0.00");
JLabel finalSell = new JLabel("Net Sell Price Change: 0.00");
JLabel buySell = new JLabel("We recommend you: N/A");
JTextArea priceUpdate = new JTextArea(10, 10);
JTextArea priceUpdateWeekly = new JTextArea(10, 10);
JScrollPane priceUScrollW;
JScrollPane priceUScroll;
JCheckBox weeklySelect = new JCheckBox("To show weekly price changes.", false);
JCheckBox dailySelect = new JCheckBox("To show daily price changes.", true);
ButtonGroup dataToShow = new ButtonGroup();
//COMPONENTS FOR DATE; OBTAINING CORRECT FOLDER
String days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
Calendar calSource = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
int day = calSource.get(Calendar.DAY_OF_MONTH);
int month = calSource.get(Calendar.MONTH);
int year = calSource.get(Calendar.YEAR);
int monthCheck [] = {Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER};
int dayS = day;
int monthS = month;
int yearS = year;
//if there is file found
boolean proceed = false;
//int data for analysis
int buyPrice;
int currentBuyPrice;
int sellPrice;
int currentSellPrice;
boolean weekly = false;
//tools for parsing and decoding input
String inputS = null;
String s = null;
Scanner [] week = new Scanner[7];
Scanner scanner;
int position = 0;
//weekly tools
String weekPos[] = {"Seventh", "Sixth", "Fifth", "Fourth", "Third", "Second", "First"};
int dayOfWeek = 0; //0 = 7 1 = 6...
public JButton getToolBarButton(String s)
String imgLoc = "TBar Icons/" +s +".gif";
java.net.URL imgURL = CSE.class.getResource(imgLoc);
JButton button = new JButton();
button.setActionCommand(s);
button.setToolTipText(s);
button.addActionListener(this);
if(imgURL != null)
button.setIcon(new ImageIcon(imgURL, s));
else
button.setText(s);
System.err.println("Couldn't find; " +imgLoc);
return button;
public CSE()
// super("Test CSE");
//CSEFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for(int x=0; x<materialNames.length; x++)
materials = getToolBarButton(materialNames[x]);
mainSelect.add(materials);
//checkBoxes
dataToShow.add(weeklySelect);
dataToShow.add(dailySelect);
weeklySelect.addItemListener(this);
dailySelect.addItemListener(this);
// sizes
setSize(850, 850);
//colors and fonts
weeklyGraph.setBackground(new Color(250, 30, 40));
dailyGraph.setBackground(new Color(100, 40, 200));
//text Manip.
prediction.setLineWrap(true);
priceUpdate.setLineWrap(true);
//scrolling
predictionScroll = new JScrollPane(prediction, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
priceUScroll = new JScrollPane(priceUpdate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
priceUScrollW = new JScrollPane(priceUpdateWeekly, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//main splitpane config.
mainConsoleBackdrop.setOneTouchExpandable(true);
mainConsoleBackdrop.setResizeWeight(.85);
//placement and Layout
//GraphLayout
graphs.add(Box.createHorizontalStrut(10));
graphs.add(dailyGraph);
graphs.add(Box.createHorizontalStrut(10));
graphs.add(weeklyGraph);
graphs.add(Box.createHorizontalStrut(10));
dataOut.setRightComponent(predictionScroll);
//consoleData layout
finalPricesLabels.add(Box.createVerticalStrut(10));
finalPricesLabels.add(finalBuy);
finalPricesLabels.add(Box.createVerticalStrut(10));
finalPricesLabels.add(finalSell);
finalPricesLabels.add(Box.createVerticalStrut(10));
finalPricesLabels.add(buySell);
finalPricesLay.add(finalPricesLabels);
finalPricesLay.add(Box.createVerticalStrut(10));
finalPricesLay.add(weeklySelect);
finalPricesLay.add(dailySelect);
finalPricesLay.add(priceUScroll);
dataOut.setLeftComponent(finalPricesLay);
mainConsoleBackdrop.setTopComponent(graphs);
mainConsoleBackdrop.setBottomComponent(dataOut);
getContentPane().add(mainConsoleBackdrop);
getContentPane().add(mainSelect, BorderLayout.NORTH);
//visibility
// CSEFrame.setVisible(true);
//return(CSEFrame);
public void actionPerformed(ActionEvent e)
getMonth();
inputS = e.getActionCommand();
FileReader newRead = null;
try {
newRead = new FileReader(monthS +"-" +dayS +"-" +yearS +"/" +inputS +".dat");
proceed = true;
catch(FileNotFoundException f)
System.out.println("File not found");
proceed = false;
if(proceed)
BufferedReader bufferedReader = new BufferedReader(newRead);
scanner = new Scanner(bufferedReader);
scanner.useDelimiter("\n");
//starts daily analysis
getPrice(scanner);
//starts weekly analysis
weekly(inputS);
public void itemStateChanged(ItemEvent e)
if(weeklySelect.isSelected())
priceUpdateWeekly.setText("");
finalPricesLay.remove(priceUScroll);
finalPricesLay.add(priceUScrollW);
finalPrices.updateUI();
else
priceUpdate.setText("");
finalPricesLay.remove(priceUScrollW);
finalPricesLay.add(priceUScroll);
finalPrices.updateUI();
public void weekly(String inputS)
weekly = true;
for(int x = 0; x >< 7; x++)
dateToUse(month, day, year, (x+1));
try
FileReader weeklySource = new FileReader(monthS +"-" +dayS +"-" +year +"/" +inputS +".dat");
BufferedReader weeklyBuffer = new BufferedReader(weeklySource);
week[x] = new Scanner(weeklyBuffer);
week[x].useDelimiter("\n");
getPrice(week[x]);
catch(FileNotFoundException f)
JOptionPane.showMessageDialog(this, "No such weekly files- going back;" +(x+1) +"days");
weekly = false;
dateReset();
public void getPrice(Scanner scanner)
while(scanner.hasNextLine())
//puts into string the next scan token
String s = scanner.next();
//takes the scan toke above and puts it into an editable enviroment
String [] data = s.split("\\s");
for(position = 0; position < data.length; position++)
//Scanner test to make sure loop can finish, otherwise "no such line" error
if(scanner.hasNextLine()==false)
scanner.close();
break;
/*Starts data orignazation by reading from each perspective field
* 1 = day
* 2 = day of month
* 3 = month
* 4 = year
if(position == 0 && weekly == false)
String dayFromFile = data[position];
int dayNum = Integer.parseInt(dayFromFile);
priceUpdate.append(days[dayNum-1] +" ");
else if(position == 1 && weekly == false )
priceUpdate.append(data[position] + "/");
else if(position == 2 && weekly == false)
priceUpdate.append(data[position] + "/");
else if(position == 3 && weekly == false)
priceUpdate.append(data[position] +"\n");
//if it is in [buy] area, it prints and computes
else if(position == 7)
//obtains string for buy price and stores it, then prints it
String buy = data[position];
if(weekly == false)
priceUpdate.append("Buy: " +buy +"\n" );
//converts buy to string
currentBuyPrice = Integer.parseInt(buy);
//eliminates problems caused by no data from server- makes the price 0
if(currentBuyPrice < 0)
currentBuyPrice = 0;
//if it is greater it adds
if(currentBuyPrice > buyPrice)
buyPrice += currentBuyPrice;
//if it is equal [there is no change] then it does nothing
if(currentBuyPrice == buyPrice)
buyPrice +=0;
//if there is a drop, it subtracts
else
buyPrice -= currentBuyPrice;
//if it is in [sell] area, it prints, and resets the position to zero because line is over
else if(position == 8)
//puts sell data into string and prints it
String sell = data[position];
if(weekly == false)
priceUpdate.append("Sell: " + sell +"\n");
//turns sell data into int.
currentSellPrice = Integer.valueOf(sell).intValue();;
//gets rid of problems caused by no data on server side- makes it 0
if(currentSellPrice < 0)
currentSellPrice = 0;
//adds if there is an increase
if(currentSellPrice > sellPrice)
sellPrice += currentSellPrice;
//does nothing if it is the same
if(currentSellPrice == sellPrice)
sellPrice +=0;
//subtracts if there is drop
else
sellPrice -= currentSellPrice;
//further protection against "No such line" and moves it down
if(scanner.hasNextLine() == true)
scanner.nextLine();
//if scanner is finished, prints out all lines
if(scanner.hasNextLine() == false && weekly == false)
finalBuy.setText("Net Buy Price Change: "+buyPrice);
finalSell.setText("Net Sell Price Change: " +sellPrice);
buyPrice = 0;
sellPrice = 0;
position = data.length;
else if(scanner.hasNextLine() == false && weekly == true)
priceUpdateWeekly.append("\n" +weekPos[dayOfWeek] +" day of the week ended with; \nBuy Price;" +buyPrice +"\nSell Price;" +sellPrice);
buyPrice = 0;
sellPrice = 0;
position = data.length;
dayOfWeek++;
if(dayOfWeek > 6)
dayOfWeek = 0;
public void getMonth()
for(int x=0; x < monthCheck.length; x++)
if(month == monthCheck[x])
monthS = (x+1);
x = monthCheck.length;
public void dateToUse(int month, int day, int year, int increment)
//set day of source
dayS = (day - increment);
//if day of source is less then O then we have moved to another month
if(dayS <= 0)
//checks the difference between how much we have incremented and the day we have started; this tells us how far into the new month we are
int incrementDay = increment - day;
//decrements month
monthS--;
//if month is less then zero, then we have moved into another year and month has become 12
if(monthS <= 0)
yearS--;
monthS = 12;
//the following looks at the current month and if it goes below it assigns the day to the proper ammount of days of the month before minus the days into the month
if(month == 3)
dayS = 28 - incrementDay;
else if(month == 5 || month == 7)
dayS = 29 - incrementDay;
else if(month == 2 || month == 4 || month == 6 || month == 9 || month == 11)
dayS = 31 - incrementDay;
else
dayS = 30 - incrementDay;
//resets the source date to the current date once data from the week has been reached
public void dateReset()
dayS = day;
monthS = month;
yearS = year;
public void init()
//JFrame frame = new CSEFrameSet();
// this.setContentPane(CSEFrameSet());
CSE aCSE = new CSE();
public static void main(String [] args)
CSE cs = new CSE();
}Message was edited by:
Cybergasm -
Good Morning,
I just did a software update on my phone (finally) last night and now my phone will not come on. It keeps showing the charger pointing up to a blue circle with iTunes inside and will not go any further. Can ANYONE help me please???The phone is in restore mode and the picture is telling you what to do. Connect the phone, by cable, to iTunes in the computer you normally use for syncing, and retore the phone.
-
I'm having a weird problem with JApplet. So first I create an Applet with this code
public class japp extends JApplet {
public void init() {
Container content=getContentPane();
JButton jb=new JButton("Hello");
content.add(jb);
}and with this in the .html file;
<html>
<body>
<APPLET CODE="japp.class" WIDTH="650" HEIGHT="500"></APPLET>
</body>
</html>
And opened it in Firefox, it worked as expected. However, when I change the code in any way, i.e.
public class japp extends JApplet {
public void init() {
Container content=getContentPane();
JButton jb=new JButton("Goodbye");
content.add(jb);
}and compile it, it still shows the old button that displays "Hello". I've tried deleting the .class file from before and recompiling, that doesn't work. What am I doing wrong?
Thanks.Reloading the page usually doesn't work. You will need to open the Java Console and clear classloader cache (x). You can also use appletviewer for testing purposes.
-
I can't export my video which contains only photos, sound tracks nor play it in fullscreen iMovie it shuts down. And now my whole file won't open at all it'll open with nothing inside ??
I also have Jolly's problem. I found the iMovie 9.0.9 folder and tried to launch the older version of iMove. It would not launch. I removed all of the iMovie preferences from the Preferences folder, removed iMove 10 from the applications folder, and restarted my Mac. iMove 9.0.9 still won't launch and I can't access my videos created with the older version of iMovie. Is there a way to uninstall iMovie 10 and reinstall iMovie 9.0.9?
I am running Yosemitie on a iMac.
Paul -
I just updated to 10.8.4 and my mail program is showing a series of boxes with AAAAs inside them instead of the email addresses. Also when on Safari web pages are displaying the same AAAAAs instead of type. Firefox displays fine. Can someone help me?
Restart your Mac and immediately hold down the Shift key when you hear the startup chime to boot into Safe Mode. Keep holding the Shift key until you see a progress bar towards the bottom of the screen. You can let go of the Shift key at that point.
OS X asks you to log in (you will get this screen on a Safe Mode boot even if your Mac is set to automatically log in). Let the Mac finish booting to the desktop and then restart normally. This will clear Font Book's database and the cache files of the user account you logged into in Safe Mode.
Next, close all running applications. From an administrator account, open the Terminal app and enter the following command. You can also copy/paste it from here into the Terminal window:
sudo atsutil databases -remove
Terminal will then ask for your admin password. As you type, it will not show anything, so be sure to enter it correctly.
This removes all font cache files. Both for the system and the current user font cache files. After running the command, close Terminal and immediately restart your Mac. -
Unable to Load CSV file with comma inside the column(Sql Server 2008)
Hi,
I am not able load an CSV file with Comma inside a column.
Here is sample File:(First row contain the column names)
_id,qp,c
"1","[ ""0"", ""0"", ""0"" ]","helloworld"
"1","[ ""0"", ""0"", ""0"" ]","helloworld"
When i specify the Text Qualifier as "(Double quotes) it work in SQL Server 2012, where as fail in the SQL Server 2008, complaining with error:
TITLE: Microsoft Visual Studio
The preview sample contains embedded text qualifiers ("). The flat file parser does not support embedding text qualifiers in data. Parsing columns that contain data with text qualifiers will fail at run time.
BUTTONS:
OK
I need to do this in sql server 2008 R2 with Service pack 2, my build version is 10.50.1600.1.
Can someone let me know it is possible in do the same way it is handle in SQL Server 2012?
Or
It got resolved in any successive Cumulative update after 10.50.1600.1?
Regards HarshHello,
If you have CSV with double quotes inside double quotes and with SSIS 2008, I suggest:
in your data flow you use a script transformation component as Source, then define the ouput columns id signed int, Gp unicode string and C unicode string. e.g. Ouput 0 output colmuns
Id - four-byte signed
gp - unicode string
cc - unicode string
Do not use a flat file connection, but use a user variable in which you store the name of the flat file (this could be inside a for each file loop).
The user variable is supplied as a a readonly variable argument to the script component in your dataflow.
In the script component inMain.CreateNewOutputRows use a System.IO.Streamreader with the user variable name to read the file and use the outputbuffer addrow method to add each line to the output of the script component.
Between the ReadLine instraction and the addrow instruction you have to add your code to extract the 3 column values.
public override void CreateNewOutputRows()
Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
string line;
System.IO.StreamReader file = new System.IO.StreamReader( Variables.CsvFilename);
while ((line = file.ReadLine()) != null)
System.Windows.Forms.MessageBox.Show(line);
if (line.StartsWith("_id,qp,c") != true) //skip header line
Output0Buffer.AddRow();
string[] mydata = Yourlineconversionher(line);
Output0Buffer.Id = Convert.ToInt32(mydata[0]);
Output0Buffer.gp = mydata[1];
Output0Buffer.cc = mydata[2];
file.Close();
Jan D'Hondt - SQL server BI development -
Have you tried returning a photo book that has a binding problem? I just ordered 2 large hardcover photobooks and one arrived with the inside binding messed up. Do you know how this can get corrected? They were over $80 and it seems they should not be flawed. I would appreciate any tips. lindajenkins
Contact Apple Support - link at the bottom of every page of these forums
LN -
What can I do I got my iPad fixed at a different brand place but not apple and I have ended up a few weeks later with dust inside my screen is their anything apple can still do for me?
If another person or company serviced your iPad, your warranty has been voided. Apple will do an out-of-warranty exchange. Have you contacted the original service provider, and complained?
-
Handling ActiveX events with Javascript inside BSPs
Hi,
Has anyone any experience with handling events from ActiveX objects (using the <object> tag) with Javascript, inside BSPs?
I'm developing solely for the IE browser. Reading other threads, I know that the usual way this is done is via the below code excerpt:
<i><script type="text/javascript" for="MyObject" event="Object_Event">
js_function();
</script></i>
I create a HTML page, with the <object>, <script..for..event> tags, etc. Everything works fine when the page is run from my local system. However, when the code is run from WebAS (Activate then Test (F8)), the ActiveX object loads fine. But the javascript does not respond to events thrown by the ActiveX object.
I wonder if anyone can share their experiences on this issue.
Thank you.
AmosIt's the Skype4COM (v1.0.0.17) wrapper for the SkypeAPI, available at https://developer.skype.com/Download
(Note: NOT the v1.0.0.16, which comes with the Skype ActiveX Tools package).
I'm trying to use javascript to handle the event "CallStatus", thrown by Skype4COM, as shown in the code excerpt below.
<i><script language="javascript" type="text/javascript" for="Skype" event="CallStatus(Call, Status)">
handleCallStatus (Call, Status);
</script></i>
It works locally, but not when in a BSP.
It's rather interesting to mess with Skype calls from a webpage. Do let us know how your experience goes
Amos -
Need help with MC with links inside
Anyone can shine some light on trying to reproduce something
similar to this?
http://www.focus.ca/home.html
What I need is how to do one of those tabs that aniamtes down
and reveals links inside. I have been at this for days.
I am very new to flash and need more assistance on the
construction of this project.
So far, I know how to make a MC and animated it for
rollover/rollout, but the link inside won't work because the action
for the MC is interferring with the inside button actions. So, what
is my next step? I have my MC on one frame in the main timeline and
need to perform all animation inside that and add buttons also?
Would I put an Insible Button in their too?
I need help?As example of a text based navbar like Roddy suggested can be seen here: Text Based Navbar. With it you can have complete control of the font (just use a Web Safe Font, color, rollover color and size. You can then copy and paste the text box to each page.
OT -
I can not daowload to the I movie a DVD with video inside
I am unable to copy Dvd made by mi
in to IMOVIE ....
i check the dvd on a tv via DVD, and is working fine
i can download photo with music no problem but not a dvd with video inside
thank you TONYYou need to rip the DVD to mp4 before importing.
Download Handbrake (free, Google it).
Insert the DVD to your computer. DVD Player will come up. Quit it.
Open Handbrake. Rip the DVD to a file on your desktop.
Import that file from your desktop into iMovie. -
What kinds of error iCloud symbol with ! inside?
added song purcahsed outside of iTunes to library. iCloud symbol shows cloud with ! inside. what kind of errors produce this symbol? how to correct?
See http://support.apple.com/kb/ts4124.
-
Problems with JApplet, jar-Archive, packages and IE5
Hello!
I have a problem with a JApplet and Internet Explorer 5. I made a jar archive of my classes. The classes are
members of a package. The jar archive also contains images.
The structure of the archive:
com/mycomp/myapp/DemoApplication.class
com/mycomp/myapp/DemoApplet.class
<more classes>
com/mycomp/myapp/images/hp_logo.gif
com/mycomp/myapp/images/test.gif
<more images>
The archive is stored locally in a directory which contains also the html file.
I used the sdk 1.3.1 to compile the classes.
My problem: when I start the html file on NT with IE5, I get the error message below:
I try to create a label containing an icon with:
topLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("images"+fs+"hp_logo.gif")));It works on Sun with Netscape 4.67 and SDK 1.3.1 installed.
Should I move the images directory inside the jar archive to another place or is the html code not correct?
The error message:
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at com.mycomp.myapp.DemoApplication.initComponents(DemoApplication.java:158)
at com.mycomp.myapp.DemoApplication.<init>(DemoApplication.java:55)
at com.mycomp.myapp.DemoApplet.<init>(DemoApplet.java:24)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)The html file:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>DemoApplet</title>
</head>
<body>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#37a1a7">
<h1>DemoApplet</h1>
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<SCRIPT LANGUAGE="JavaScript"><!--
var _info = navigator.userAgent; var _ns = false; var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
//--></SCRIPT></COMMENT>
<SCRIPT LANGUAGE="JavaScript"><!--
if (_ie == true) document.writeln('<OBJECT classid="clsid:CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA" WIDTH = 695 HEIGHT = 525 codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0"><NOEMBED><XMP>');
else if (_ns == true && _ns6 == false) document.writeln('<EMBED type="application/x-java-applet;jpi-version=1.3.1" CODE = com.mycomp.myapp.DemoApplet CODEBASE = "." ARCHIVE = "DemoApplet.jar,classes12.zip" WIDTH = 800 HEIGHT = 600 scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3.1/plugin-install.html"><NOEMBED><XMP>');
//--></SCRIPT>
<APPLET CODE = com.mycomp.myapp.DemoApplet CODEBASE = "." ARCHIVE = "DemoApplet.jar,classes12.zip" WIDTH = 695 HEIGHT = 525></XMP>
<PARAM NAME = CODE VALUE = com.mycomp.myapp.DemoApplet >
<PARAM NAME = CODEBASE VALUE = "." >
<PARAM NAME = ARCHIVE VALUE = "DemoApplet.jar,classes12.zip" >
<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.1">
<PARAM NAME="scriptable" VALUE="false">
</APPLET>
</NOEMBED></EMBED></OBJECT>
<!--
<APPLET CODE = DemoApplet CODEBASE = "." ARCHIVE = "DemoApplet.jar,classes12.zip" WIDTH = 695 HEIGHT = 525>
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</body>
</html>Thank you for your help!
Gruesse,
Torstenseems like it couldn't find the image file... try to give it the absolute path to the file first to see if this is the root of the problem... and then try to find alternative ways to not give it the absolute path...
Maybe you are looking for
-
How do i remove email addresses that have been imported from my email account?
Im not sure how i did it but somehow i have a ton of email addresses in my contacts and I want to remove them....Is there a way to do this without have to remove them one at a time.....I hardly send anyone emails from my contact list and would love t
-
CS5 Bridge & Photo Downloader Bug/Feature Request
Not sure if this is the right place to post this. Hopefully Adobe reads through this forum. With CS4, my camera download workflow required using Image Capture, DNG Converter, and Bridge. With CS5, I can now perform the same workflow all in Bridge. I
-
Finding file with tomorrow's date in file name
I have a workflow where pdf files are going through a process and they could end up in an error folder. The files all have the day's date embedded in their names. I would like to set up a cron job looking for files that have dropped in an error fol
-
Account deactivation and/or deletion
In an answer to a previous question posted, in regards to open accounts I suggested that Skype should consider giving its users the option to either change their accounts, deactivate their accounts or they themselves automatically deactivate/delete t
-
Hi Guru, I config OBB8 & OBB9 for the installment. Payment Term 0009 1st. 40 % -- GR 2nd. 30% -- Inspection 3rd 10%. -- Completion of testing In PO, we purchase 1 Machine with USD1,000. (Payment Term 0009) When doing MIRO for the GR, USD400, the