AT300 - need help with display brightness
Hello! Help solve the problem with the AT300 tablet.
Balanced consumption charge off, automatic brightness control is also disabled. But when watching videos, surfing and gaming brightness still varies depending on the color of the image. If the image is dark, the brightness decreases, if the picture is brighter - the screen gets brighter. How do to fix the brightness?
Thanks!
Hello,
I have the same problem like flash85.
When I scroll down on bright websites and a darker picture is shown on the screen,
the whole display becomes much darker and even the colors on the screen change.
Yesterday I've tried the same website on an IPad and the background and colors perfectly
stays the same.
Also the display permanently dimms down or up if the automatic brightness control is
enabled. This is also very disturbing.
I can't imagine that this behaviour is normal. I read many tests before and none of it mentioned this.
Similar Messages
-
Hi guys need Help with Displaying Splash Screen?!!?
Hi Guys.
Sorry for the last incomplete post my mistake!
I need help displaying a splash screen as an advertisment or something before i have my main application run.
Here is the code i wrote (it works as if it were a seperate application)
package MajourProject;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Robot;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JWindow;
* @author Matt
public class SplashScreen extends JWindow
public SplashScreen()
int UpTime = 20000;
Start(UpTime);
public void Start(int UpTime)
ImageIcon ii = new ImageIcon("src/1.jpg");
JScrollPane jsp = new JScrollPane(new JLabel(ii));
JProgressBar Bar = new JProgressBar();
getContentPane().add(jsp);
setSize(853,303);
centerScreen();
setVisible(true);
try
Thread.sleep(20000);
dispose();
catch(Exception IE)
private void centerScreen()
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((d.getWidth() - getWidth()) / 2);
int y = (int) ((d.getHeight() - getHeight()) / 2);
setLocation(x, (y-100));
public static void main(String [] args)
new SplashScreen();
}but i now have a problem as i already have a main application done as i wrote this seperately. I now need to combine the two together. So what i did was in my Main Application wrote:
Splash_Screen SS = new Splash_Screen();it then runs my Splash Screen class which i re-wrote to look as such:
package MajourProject;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Robot;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JWindow;
* @author Matt
public class SplashScreen extends JWindow
public SplashScreen()
int time = 15000;
Start(time);
public void Start(int UpTime)
ImageIcon ii = new ImageIcon("src/1.jpg");
JScrollPane jsp = new JScrollPane(new JLabel(ii));
JProgressBar Bar = new JProgressBar();
getContentPane().add(jsp);
setSize(853,303);
centerScreen();
setVisible(true);
try
Thread.sleep(20000);
dispose();
catch(Exception IE)
private void centerScreen()
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((d.getWidth() - getWidth()) / 2);
int y = (int) ((d.getHeight() - getHeight()) / 2);
setLocation(x, (y-100));
}it obviously runs the default constructor which then runs the other methods in the class but it doesn't seem to show can anybody help me to find out whats wrong? It seems to be there just before the main application launches but only for a split second. And when i am waiting while the thread is sleeping the area i have defined the Content pane for he cursor goes to the loading icon! I don't know if this makes any sence to you but if you can help me it would be most apreciated.
Thanks.SpearOne wrote:
Hi Encephalopathic
why would it work if i put it in it's own application surely it wouldn't be caused by this thread.sleep?? everything after it is in fact put to sleep. In its "own" application, nothing happens after it is displayed.
if it is the problem then could you please give me some code to add quickly to test??
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JWindow;
import javax.swing.Timer;
public class SplashScreen extends JWindow
private static final String IMAGE_PATH = "src/1.jpg";
private static final int UP_TIME = 15000;
public SplashScreen()
Start();
public void Start()
ImageIcon ii = new ImageIcon(IMAGE_PATH);
JScrollPane jsp = new JScrollPane(new JLabel(ii));
//JProgressBar Bar = new JProgressBar();
getContentPane().add(jsp);
setSize(853, 303);
centerScreen();
private void centerScreen()
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((d.getWidth() - getWidth()) / 2);
int y = (int) ((d.getHeight() - getHeight()) / 2);
setLocation(x, (y - 100));
public static void main(String[] args)
final JFrame frame = new JFrame("Main Frame");
frame.setPreferredSize(new Dimension(300, 200));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
final SplashScreen splash = new SplashScreen();
splash.setVisible(true);
Timer swingTimer = new Timer(UP_TIME, new ActionListener()
public void actionPerformed(ActionEvent e)
splash.dispose();
frame.setVisible(true);
swingTimer.setRepeats(false);
swingTimer.start();
} -
Need help with displaying content on multiple pages
Hi I'm kind of a dreamweaver newbie and i'm a little in over
my head. I'm trying to design a web site with the same content
appearing on multiple pages. Here's the current site...
http://home.comcast.net/~gascec/cecnh20/index.html
I'm trying to establish the top bar and side bars of links
and the logo on each page from one point so i don't have to change
forty pages if i update a link.
I know there's a way to do this and i thought it was using a
CSS page but i can't figure it out and i'm running out of time.
HelpGot it. Thank you. I'm having one other problem though. I
keep getting this bizare message every time i save or try to use
the template:
The is an error at line 41 column 7 (absolute position 2486)
of "~pathandfilename.dwt": Nested editable regions
The only thing at line 41 is the <body> tag. I took all
the formating out to try to trim this out... any thoughts about
this one.
Thanks G -
I need help with display settings on
When Im watching movies is their any way to change the contrast or anything because it only lets me change brightness
Only brightness can be changed. You could email the developers relations and ask them to make a contrast settings
-
Need help with JTextArea and Scrolling
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import javax.swing.*;
public class MORT_RETRY extends JFrame implements ActionListener
private JPanel keypad;
private JPanel buttons;
private JTextField lcdLoanAmt;
private JTextField lcdInterestRate;
private JTextField lcdTerm;
private JTextField lcdMonthlyPmt;
private JTextArea displayArea;
private JButton CalculateBtn;
private JButton ClrBtn;
private JButton CloseBtn;
private JButton Amortize;
private JScrollPane scroll;
private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
private JComboBox rateTermList;
double interest[] = {5.35, 5.5, 5.75};
int term[] = {7, 15, 30};
double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
int termInMonths, month, termLoop, monthLoop;
public MORT_RETRY()
Container pane = getContentPane();
lcdLoanAmt = new JTextField();
lcdMonthlyPmt = new JTextField();
displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
rateTermList = new JComboBox(rateTerm);
scroll = new JScrollPane(displayArea);
scroll.setSize(600,170);
scroll.setLocation(150,270);//DEFINE BUTTONS
CalculateBtn = new JButton("Calculate");
ClrBtn = new JButton("Clear Fields");
CloseBtn = new JButton("Close");
Amortize = new JButton("Amortize");//DEFINE PANEL(S)
keypad = new JPanel();
buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
keypad.add(new JLabel("Loan Amount$ : "));
keypad.add(lcdLoanAmt);
keypad.add(new JLabel("Term of loan and Interest Rate: "));
keypad.add(rateTermList);
keypad.add(new JLabel("Monthly Payment : "));
keypad.add(lcdMonthlyPmt);
lcdMonthlyPmt.setEditable(false);
keypad.add(new JLabel("Amortize Table:"));
keypad.add(displayArea);
displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
buttons.add(CalculateBtn);
buttons.add(Amortize);
buttons.add(ClrBtn);
buttons.add(CloseBtn);//ADD ACTION LISTENER
CalculateBtn.addActionListener(this);
ClrBtn.addActionListener(this);
CloseBtn.addActionListener(this);
Amortize.addActionListener(this);
rateTermList.addActionListener(this);//ADD PANELS
pane.add(keypad, BorderLayout.NORTH);
pane.add(buttons, BorderLayout.SOUTH);
pane.add(scroll, BorderLayout.CENTER);
addWindowListener( new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
public void actionPerformed(ActionEvent e)
String arg = lcdLoanAmt.getText();
int combined = Integer.parseInt(arg);
if (e.getSource() == CalculateBtn)
try
JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
catch(NumberFormatException ev)
JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
if ((e.getSource() == CalculateBtn) && (arg != null))
try{
if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
monthlyInterest = interest[0] / (12 * 100);
termInMonths = term[0] * 12;
monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest, -termInMonths))));
lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
monthlyInterest = interest[1] / (12 * 100);
termInMonths = term[1] * 12;
monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest, -termInMonths))));
lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
monthlyInterest = interest[2] / (12 * 100);
termInMonths = term[2] * 12;
monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest, -termInMonths))));
lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
catch(NumberFormatException ev)
JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
} //IF STATEMENTS FOR AMORTIZATION
if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
loopy(7, 5.35);
if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
loopy(15, 5.5);
if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
loopy(30, 5.75);
if (e.getSource() == ClrBtn)
rateTermList.setSelectedIndex(0);
lcdLoanAmt.setText(null);
lcdMonthlyPmt.setText(null);
displayArea.setText(null);
if (e.getSource() == CloseBtn)
System.exit(0);
private void loopy(int lTerm,double lInterest)
double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
int amount, months, termloop, monthloop;
String lcd2 = lcdLoanAmt.getText();
amount = Integer.parseInt(lcd2);
termloop = 1;
paid = 0.00;
monthlyrate = lInterest / (12 * 100);
months = lTerm * 12;
monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
total = months * monthly;
balance = amount;
while (termloop <= lTerm)
displayArea.setCaretPosition(0);
displayArea.append("\n");
displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
displayArea.append("\n");
displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
monthloop = 1;
while (monthloop <= 12)
monthint = balance * monthlyrate;
monthprin = monthly - monthint;
balance -= monthprin;
paid += monthly;
displayArea.setCaretPosition(0);
displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
monthloop ++;
termloop ++;
public static void main(String args[])
MORT_RETRY f = new MORT_RETRY();
f.setTitle("MORTGAGE PAYMENT CALCULATOR");
f.setBounds(600, 600, 500, 500);
f.setLocationRelativeTo(null);
f.setVisible(true);
}need help with displaying the textarea correctly and the scroll bar please.
Message was edited by:
new2this2020What's the problem you're having ???
PS. -
Need Help with Address Display
I need help with APEX.
Here's my situation:
I have a report that displays brief employee information. Among the information displayed is the Address. Right now, it's display as:
Mr X
Employee Id
Accounting Department
Address 1
Mr X
Employee Id
Accounting Department
Address 2
I would like it to display
Mr X
Employee Id
Accounting Department
Address 1
Address 2
1) I have thought of using the Break functionality; however, the function only allows break at column 1, 2, 3. As you can see Address starts at column 4. Also, Address has a few columns; Address Line 1, Address Line 2, City, State, Zipcode.
2) Stragg functions - I'm not sure how to implement it since it has more than 1 columns.
Any ideas?
Thanks in advance
AndrewThe example I gave you, using analytic functions is a simple one.
Now, you are saying:
1. some of the employees may have two adresses?
2. if this is the case, your employee appears in the report twice?
3. you don't want his name, employee id and accounting department to appear twice?
4. only his address has to be displayed?
If the answer to all the questions is yes, this kind of query will help you. I repeat:
SELECT CASE
WHEN LAG (employee_id) OVER (ORDER BY employee_id) =
employee_id
THEN NULL
ELSE employee_name
END employee_name,
CASE
WHEN LAG (employee_id) OVER (ORDER BY employee_id) =
employee_id
THEN NULL
ELSE employee_id
END employee_id,
CASE
WHEN LAG (employee_id) OVER (ORDER BY employee_id) =
employee_id
THEN NULL
ELSE accounting_department
END accounting_department,
street, postal_code, city, state, country
FROM your_employees_table;Give it a try.
Denes Kubicek -
Need help on displaying the callers name on ip phone with cme using external directory
Hello Guys,
Need help on displaying the callers name on ip phone with cme while using external directory
Thank you,
KhajaThanks for your help,
Does it 100% work with CME. We use SIP and 2ring for external directory? Thanks you. -
I need help with shooting in my flash game for University
Hi there
Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
listed below should be the correct code
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
listed below is my entire code
import flash.display.MovieClip;
//declare varibles to create mines
//how much time before allowed to shoot again
var cTime:int = 0;
//the time it has to reach in order to be allowed to shoot (in frames)
var cLimit:int = 12;
//whether or not the user is allowed to shoot
var shootAllow:Boolean = true;
var minesInGame:uint;
var mineMaker:Timer;
var cursor:MovieClip;
var index:int=0;
var tankMine_mc:MovieClip;
var antiTankmine_mc:MovieClip;
var maxHP:int = 100;
var currentHP:int = maxHP;
var percentHP:Number = currentHP / maxHP;
function initialiseMine():void
minesInGame = 15;
//create a timer fires every second
mineMaker = new Timer(6000, minesInGame);
//tell timer to listen for Timer event
mineMaker.addEventListener(TimerEvent.TIMER, createMine);
//start the timer
mineMaker.start();
function createMine(event:TimerEvent):void
//var tankMine_mc:MovieClip;
//create a new instance of tankMine
tankMine_mc = new Mine();
//set the x and y axis
tankMine_mc.y = 513;
tankMine_mc.x = 1080;
// adds mines to stage
addChild(tankMine_mc);
tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal(evt:Event):void{
evt.target.x -= Math.random()*5;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseMine();
//declare varibles to create mines
var atmInGame:uint;
var atmMaker:Timer;
function initialiseAtm():void
atmInGame = 15;
//create a timer fires every second
atmMaker = new Timer(8000, minesInGame);
//tell timer to listen for Timer event
atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
//start the timer
atmMaker.start();
function createAtm(event:TimerEvent):void
//var antiTankmine_mc
//create a new instance of tankMine
antiTankmine_mc = new Atm();
//set the x and y axis
antiTankmine_mc.y = 473;
antiTankmine_mc.x = 1080;
// adds mines to stage
addChild(antiTankmine_mc);
antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal_2(evt:Event):void{
evt.target.x -= Math.random()*10;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseAtm();
function moveForward():void{
bg_mc.x -=10;
function moveBackward():void{
bg_mc.x +=10;
var tank_mc:Tank;
// create a new Tank and put it into the variable
// tank_mc
tank_mc= new Tank;
// set the location ( x and y) of tank_mc
tank_mc.x=0;
tank_mc.y=375;
// show the tank_mc on the stage.
addChild(tank_mc);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
//creates the movement
function onMovementKeys(evt:KeyboardEvent):void
//makes the tank move by 10 pixels right
if (evt.keyCode==Keyboard.D)
tank_mc.x+=5;
//makes the tank move by 10 pixels left
if (evt.keyCode==Keyboard.A)
tank_mc.x-=5
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
if (tank_mc.hitTestObject(antiTankmine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(antiTankmine_mc);
if (tank_mc.hitTestObject(tankMine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(tankMine_mc);
//var maxHP:int = 100;
//var currentHP:int = maxHP;
//var percentHP:Number = currentHP / maxHP;
//Incrementing the cTime
//checking if cTime has reached the limit yet
if(cTime < cLimit){
cTime ++;
} else {
//if it has, then allow the user to shoot
shootAllow = true;
//and reset cTime
cTime = 0;
function updateHealthBar():void
percentHP = currentHP / maxHP;
healthBar.barColor.scaleX = percentHP;
if(currentHP <= 0)
currentHP = 0;
trace("Game Over");
updateHealthBar();USe the trace function to analyze what happens and what fails to happen in the code you showed. trace the conditional values to see if they are set up to allow a shot when you press the key
-
I need help with this script please ASAP
So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
The script (Sorry if it's a bit long):
#------------Startup-------------
display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
set Lolz to (button returned of the result)
if Lolz is "Cyaaaa" then
killapp()
else if Lolz is "Take the Quiz" then
do shell script "say -v samantha Ok starting in 3…2…1…GO!"
#------------Question 1-----------
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 2--------
display dialog "Most children were taught
to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------------Question 3---------
display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
set A3 to (button returned of the result)
if A3 is "Great Awakening" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-----------Question 4--------
display dialog "_______ was
a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
set A4 to (button returned of the result)
if A4 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 5-------
display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
set A5 to (button returned of the result)
if A5 is "Land" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 6--------
display dialog "The first step toward guaranteeing these rights came in 1215. That
year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
set A6 to (button returned of the result)
if A6 is "Magna Carta" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 7--------
display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
set A7 to (button returned of the result)
if A7 is "Parliament" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 8-----
display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
set A8 to (button returned of the result)
if A8 is "King James II" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 9------
display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
set A9 to (button returned of the result)
if A9 is "William/Mary/Glorius Revolution" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 10-----
display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
set A10 to (button returned of the result)
if A10 is "Rights" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 11------
display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
set A11 to (button returned of the result)
if A11 is "Ohio" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------Question 12---------
display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
set A12 to (button returned of the result)
if A12 is "George Washington" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 13-------
display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
set A13 to (button returned of the result)
if A13 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 14------
display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
set A14 to (button returned of the result)
if A14 is "" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-------Question 15-------
display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
set A15 to (button returned of the result)
if A15 is "Command an attack against French" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------TheLolQuestion-----
display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
set LOOL to (button returned of the result)
if LOOL is "Mr.White" then
do shell script "say -v samantha Congratulations…you…have…common…sense"
else
do shell script "say -v alex Do…you…have…eyes?"
#------END------
display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
set endmenu to (button returned of the result)
if endmenu is "I did!" then
do shell script "say -v samantha Your awesome"
else
do shell script "say -v alex Go outside and run a lap"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end ifUse code such as:
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
#----------Question 2--------
display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
(90444) -
I need Help with a website I've created
I need help with a website I've created (www.jonathanhazelwood.com/lighthouse) I created the folowing site with dreamweaver at my current resolution 1366 by 768. Looks great on my screen resolution but if it is viewed on other resolutions the menu moves and some of the text above and below. How can I keep all content centered and working like it does on 1366 by 768 on all resolutions. The htm to my site is below I started off with a blank template through dreamweaver CS5.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Lighthouse Church</title>
<style type="text/css">
<!--
body {
font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
background: #42413C;
margin: 0;
padding: 0;
color: #000;
background-color: #000;
/* ~~ Element/tag selectors ~~ */
ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
padding: 0;
margin: 0;
h1, h2, h3, h4, h5, h6, p {
margin-top: 0; /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
padding-right: 15px;
padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
border: none;
/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
a:link {
color: #42413C;
text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
a:visited {
color: #6E6C64;
text-decoration: underline;
a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
text-decoration: none;
/* ~~ this fixed width container surrounds all other elements ~~ */
.container {
width: 960px;
background: #FFF;
margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
/* ~~ This is the layout information. ~~
1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
.content {
padding: 10px 0;
/* ~~ miscellaneous float/clear classes ~~ */
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
float: left;
margin-right: 8px;
.clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
#apDiv1 {
position:absolute;
width:352px;
height:2992px;
z-index:1;
top: 171px;
left: 507px;
#apDiv2 {
position:absolute;
width:961px;
height:1399px;
z-index:1;
left: 187px;
top: 1px;
#apDiv3 {
position:absolute;
width:961px;
height:1001px;
z-index:1;
top: -2px;
#apDiv4 {
position:absolute;
width:963px;
height:58px;
z-index:1;
left: 0px;
top: 101px;
#apDiv5 {
position:absolute;
width:961px;
height:1505px;
z-index:1;
top: -5px;
#apDiv6 {
position:absolute;
width:962px;
height:150px;
z-index:1;
left: 0px;
top: -1px;
#apDiv7 {
position:absolute;
width:361px;
height:25px;
z-index:2;
left: 35px;
top: 1308px;
#apDiv8 {
position:absolute;
width:320px;
height:24px;
z-index:2;
left: 200px;
top: 1479px;
#apDiv9 {
position:absolute;
width:962px;
height:63px;
z-index:3;
left: -10px;
top: -1292px;
#apDiv10 {
position:absolute;
width:270px;
height:27px;
z-index:2;
left: 200px;
top: 1478px;
#apDiv11 {
position:absolute;
width:961px;
height:44px;
z-index:3;
left: 195px;
top: 183px;
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#apDiv12 {
position:absolute;
width:295px;
height:23px;
z-index:4;
left: 198px;
top: 1px;
#apDiv13 {
position:absolute;
width:135px;
height:22px;
z-index:5;
left: 1001px;
top: 3px;
#apDiv14 {
position:absolute;
width:309px;
height:992px;
z-index:1;
left: 33px;
top: 479px;
#apDiv15 {
position:absolute;
width:327px;
height:999px;
z-index:1;
left: 324px;
#apDiv16 {
position:absolute;
width:262px;
height:1000px;
z-index:2;
left: 674px;
top: 477px;
#apDiv17 {
position:absolute;
width:85px;
height:34px;
z-index:1;
left: -379px;
top: 1001px;
#apDiv18 {
position:absolute;
width:200px;
height:115px;
z-index:6;
#apDiv19 {
position:absolute;
width:168px;
height:31px;
z-index:3;
left: 448px;
top: 1451px;
#apDiv20 {
position:absolute;
width:94px;
height:33px;
z-index:3;
left: 384px;
top: 1477px;
body {
background-color: #000;
margin-left: 0px;
margin-right: 0px;
#apDiv21 {
position:absolute;
width:920px;
height:200px;
z-index:4;
left: 19px;
top: 233px;
</style>
</head>
<body>
<div class="container">
<div class="content">
<div id="apDiv5">
<div id="apDiv16">
<div id="apDiv17">
<map name="Map2" id="Map2">
<area shape="rect" coords="4,2,77,28" href="http://www.myspace.com/lighthousechurch1" />
</map>
<img src="paypal-donate-button.png" width="83" height="33" border="0" usemap="#Map" />
<map name="Map" id="Map">
<area shape="rect" coords="2,2,80,30" href="https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=HgApKd0bxyPQv1ixwBW3HgWXaLxPIiT Po9gSsRELLQp72IZ2-_8uvSmCLRO&dispatch=5885d80a13c0db1f8e263663d3faee8d9384d85353843a619606 282818e091d0" />
</map>
</div>
</div>
<div id="apDiv21">
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p><img src="faithexplosion.png" width="314" height="225" /></p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</div>
<div id="apDiv14">
<div id="apDiv15">
<div>
<div>
<p> Special Message from Perry Stone </p>
<h2> Was Jesus Born on December 25?</h2>
<p> 12/20/2010 </p>
<p><img alt="iStock_000003631829XSmall" src="http://www.voe.org/images/iStock_000003631829XSmall.jpg" width="300" height="234" /></p>
<p>Last year, in response to the growing number of Christians who celebrate Hanukkah but hate Christmas, I wrote an article for this website titled “Hanukkah or Christmas?” I explained why I think Jesus was either conceived or birthed on December 25.</p>
</div>
</div>
<div>
<div><a href="http://www.voe.org/Prophecy-Update/what-happened-to-global-warming.html"> READ MORE</a>
<p> Prophecy Update </p>
<h2> What Happened to Global Warming?</h2>
<p> 12/17/2010 </p>
<p> </p>
</div>
</div>
<div>
<div></div>
</div>
<div>
<div></div>
</div>
</div>
<div>
<p><font size="2">Special Word</font></p>
<p><font size="2">January 7th, 2011</font></p>
<p> <font size="2">Dear Viewers:</font></p>
<p><font size="2">We have now entered into one of the most trying times; but also one of the most glorious times in church history. Many things are coming upon the world and also upon the church and we (the church) must be totally prepared to take up our cross daily and venture out into the lost and</font></p>
<p> <a href="http://sermon.lighthousechurchinc.org/2011/01/07/special-word-1711-evangelist-barbara-lync h.aspx" target="_parent">Click Here for More</a></p>
</div>
<p> </p>
<div></div>
<div>
<!--// weAddFlash("lhi09hdr.swf",800, 100,"true","true","high","showall","true","#ffffff"); //--></div>
<div></div>
<p> </p>
</div>
<img src="lighthousegraphic2.jpg" width="960" height="1509" />
<div id="apDiv20"><img src="myspacebutton.jpg" width="89" height="30" border="0" usemap="#Map3" />
<map name="Map3" id="Map3">
<area shape="rect" coords="3,2,87,28" href="http://www.myspace.com/lighthousechurch1" />
</map>
</div>
</div>
<p> </p>
</div>
<!-- end .container --></div>
<div id="apDiv10"><font size="1"><font color="#FFFFFF">Copyright 2011 The Lighthouse Church Inc.</font></font></div>
<div id="apDiv11">
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="#">Home</a> </li>
<li><a href="#" class="MenuBarItemSubmenu">Our Pastor</a>
<ul>
<li><a href="#">Fresh Word</a></li>
<li><a href="#">Itinerary</a></li>
<li><a href="#">Prophetic Word</a></li>
<li><a href="#">Sermons</a></li>
<li><a href="#">Special Words</a></li>
<li><a href="#">Word of Month</a></li>
</ul>
</li>
<li><a href="#">Men Ministry</a></li>
<li><a href="#" class="MenuBarItemSubmenu">Ministers</a>
<ul>
<li><a href="#">Chris Gore</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">Our Church</a>
<ul>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Donate</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Our Store</a></li>
<li><a href="#">Prayer Request</a></li>
<li><a href="#">Salvation</a></li>
<li><a href="#">Subscribe</a></li>
<li><a href="#">Vision</a></li>
<li><a href="#">We Believe</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">Resources</a>
<ul>
<li><a href="#">Prepare for Disaster</a></li>
<li><a href="#">How to Fast</a></li>
<li><a href="#">Heaven & Hell</a></li>
<li><a href="#">Warfare Prayers</a></li>
<li><a href="#">Wisdom Words</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">Prophetic</a>
<ul>
<li><a href="#">Article Archive</a></li>
<li><a href="#">Audio Prophecies</a></li>
<li><a href="#">Color for Year</a></li>
<li><a href="#">Major Articles</a></li>
<li><a href="#">Prophecy Archive</a></li>
<li><a href="#">Prophetic Articles</a></li>
<li><a href="#">Word for Year</a></li>
</ul>
</li>
</ul>
</div>
<div id="apDiv12"><font size="1"><font color="#FFFFFF">6 South Railroad Ave Wyoming,DE 19934</font></font></div>
<div id="apDiv13"><font size="1"><font color="#FFFFFF">Phone:(302) 697-1472</font></font></div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>Look at all the apdiv's you have. Those are absolutely positioned layers. I'm assuming by your post that you are very new to Dreamweaver and HTML and CSS. I would highly recommend not using absolutely positioned layers until you have a better grasp on HTML and CSS.
Looking at your code I would suggest that you consider using one of Dreamweaver's built in, or downloadable templates as a starting point and work from there.
http://www.adobe.com/devnet/dreamweaver/articles/dreamweaver_custom_templates.html -
Need help with calculator project for an assignment...
Hi all, I please need help with my calculator project that I have to do for an assignment.
Here is the project's specifications that I need to do"
"""Create a console calculator applicaion that:
* Takes one command line argument: your name and surname. When the
program starts, display the date and time with a welcome message for the
user.
* Display all the available options to the user. Your calculator must include
the arithmetic operations as well as at least five scientific operations of the
Math class.
-Your program must also have the ability to round a number and
truncate it.
-When you multiply by 2, you should not use the '*' operator to perform the
operation.
-Your program must also be able to reverse the sign of a number.
* Include sufficient error checking in your program to ensure that the user
only enters valid input. Make use of the String; Character, and other
wrapper classes to help you.
* Your program must be able to do conversions between decimal, octal and
hex numbers.
* Make use of a menu. You should give the user the option to end the
program when entering a certain option.
* When the program exits, display a message for the user, stating the
current time, and calculate and display how long the user used your
program.
* Make use of helper classes where possible.
* Use the SDK to run your program."""
When the program starts, it asks the user for his/her name and surname. I got the program to ask the user again and again for his/her name and surname
when he/she doesn't insert anything or just press 'enter', but if the user enters a number for the name and surname part, the program continues.
Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??
Here is the programs code that I've written so far:
{code}
import java.io.*;
import java.util.*;
import java.text.*;
public class Project {
private static String nameSurname = "";
private static String num1 = null;
private static String num2 = null;
private static String choice1 = null;
private static double answer = 0;
private static String more;
public double Add() {
answer = (Double.parseDouble(num1) + Double.parseDouble(num2));
return answer;
public double Subtract() {
answer = (Double.parseDouble(num1) - Double.parseDouble(num2));
return answer;
public double Multiply() {
answer = (Double.parseDouble(num1) * Double.parseDouble(num2));
return answer;
public double Divide() {
answer = (Double.parseDouble(num1) / Double.parseDouble(num2));
return answer;
public double Modulus() {
answer = (Double.parseDouble(num1) % Double.parseDouble(num2));
return answer;
public double maximumValue() {
answer = (Math.max(Double.parseDouble(num1), Double.parseDouble(num2)));
return answer;
public double minimumValue() {
answer = (Math.min(Double.parseDouble(num1), Double.parseDouble(num2)));
return answer;
public double absoluteNumber1() {
answer = (Math.abs(Double.parseDouble(num1)));
return answer;
public double absoluteNumber2() {
answer = (Math.abs(Double.parseDouble(num2)));
return answer;
public double Squareroot1() {
answer = (Math.sqrt(Double.parseDouble(num1)));
return answer;
public double Squareroot2() {
answer = (Math.sqrt(Double.parseDouble(num2)));
return answer;
public static String octalEquivalent1() {
int iNum1 = Integer.parseInt(num1);
String octal1 = Integer.toOctalString(iNum1);
return octal1;
public static String octalEquivalent2() {
int iNum2 = Integer.parseInt(num2);
String octal2 = Integer.toOctalString(iNum2);
return octal2;
public static String hexadecimalEquivalent1() {
int iNum1 = Integer.parseInt(num1);
String hex1 = Integer.toHexString(iNum1);
return hex1;
public static String hexadecimalEquivalent2() {
int iNum2 = Integer.parseInt(num2);
String hex2 = Integer.toHexString(iNum2);
return hex2;
public double Round1() {
answer = Math.round(Double.parseDouble(num1));
return answer;
public double Round2() {
answer = Math.round(Double.parseDouble(num2));
return answer;
SimpleDateFormat format1 = new SimpleDateFormat("EEEE, dd MMMM yyyy");
Date now = new Date();
SimpleDateFormat format2 = new SimpleDateFormat("hh:mm a");
static Date timeIn = new Date();
public static long programRuntime() {
Date timeInD = timeIn;
long timeOutD = System.currentTimeMillis();
long msec = timeOutD - timeInD.getTime();
float timeHours = msec / 1000;
return (long) timeHours;
DecimalFormat decimals = new DecimalFormat("#0.00");
public String insertNameAndSurname() throws IOException{
boolean inputCorrect = false;
while (inputCorrect == false) {
while (nameSurname == null || nameSurname.length() == 0) {
for (int i = 0; i < nameSurname.length(); i++) {
if ((nameSurname.charAt(i) > 'a') && (nameSurname.charAt(i) < 'Z')){
inputCorrect = true;
else{
inputCorrect = false;
break;
try {
BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
System.out.print("Please enter your name and surname: ");
nameSurname = inStream.readLine();
inputCorrect = true;
}catch (IOException ex) {
System.out.println("You did not enter your name and surname, " + nameSurname + " is not a name, please enter your name and surname :");
inputCorrect = false;
System.out.println("\nA warm welcome " + nameSurname + " ,todays date is: " + format1.format(now));
System.out.println("and the time is now exactly " + format2.format(timeIn) + ".");
return nameSurname;
public String inputNumber1() throws IOException {
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
System.out.print("\nPlease enter a number you want to do a calculation with and hit <ENTER>: ");
num1 = br.readLine();
double number1 = Double.parseDouble(num1);
System.out.println("\nThe number you have entered is: " + number1);
inputCorrect = true;
} catch (NumberFormatException nfe) {
System.out.println("\nYou did not enter a valid number: " + "\""+ num1 + "\" is not a number!!");
inputCorrect = false;
return num1;
public String calculatorChoice() throws IOException {
System.out.println("Please select an option of what you would like to do with this number from the menu below and hit <ENTER>: ");
System.out.println("\n*********************************************");
System.out.println("---------------------------------------------");
System.out.println("Please select an option from the list below: ");
System.out.println("---------------------------------------------");
System.out.println("1 - Add");
System.out.println("2 - Subtract");
System.out.println("3 - Multiply");
System.out.println("4 - Divide (remainder included)");
System.out.println("5 - Maximum and minimum value of two numbers");
System.out.println("6 - Squareroot");
System.out.println("7 - Absolute value of numbers");
System.out.println("8 - Octal and Hexadecimal equivalent of numbers");
System.out.println("9 - Round numbers");
System.out.println("0 - Exit program");
System.out.println("**********************************************");
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
System.out.print("Please enter your option and hit <ENTER>: ");
choice1 = inStream.readLine();
int c1 = Integer.parseInt(choice1);
System.out.println("\nYou have entered choice number: " + c1);
inputCorrect = true;
} catch (NumberFormatException nfe) {
System.out.println("You did not enter a valid choice number: " + "\""+ choice1 + "\" is not in the list!!");
inputCorrect = false;
return choice1;
public String inputNumber2() throws IOException {
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader br2 = new BufferedReader (new InputStreamReader(System.in));
System.out.print("\nPlease enter another number you want to do the calculation with and hit <ENTER>: ");
num2 = br2.readLine();
double n2 = Double.parseDouble(num2);
System.out.println("\nThe second number you have entered is: " + n2);
System.out.println("\nYour numbers are: " + num1 + " and " + num2);
inputCorrect = true;
} catch (NumberFormatException nfe) {
System.out.println("You did not enter a valid number: " + "\""+ num2 + "\" is not a number!!");
inputCorrect = false;
return num2;
public int Calculator() {
int choice2 = (int) Double.parseDouble(choice1);
switch (choice2) {
case 1 :
Add();
System.out.print("The answer of " + num1 + " + " + num2 + " is: " + decimals.format(answer));
break;
case 2 :
Subtract();
System.out.print("The answer of " + num1 + " - " + num2 + " is: " + decimals.format(answer));
break;
case 3 :
Multiply();
System.out.print("The answer of " + num1 + " * " + num2 + " is: " + decimals.format(answer));
break;
case 4 :
Divide();
System.out.print("The answer of " + num1 + " / " + num2 + " is: " + decimals.format(answer));
Modulus();
System.out.print(" and the remainder is " + decimals.format(answer));
break;
case 5 :
maximumValue();
System.out.println("The maximum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
minimumValue();
System.out.println("The minimum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
break;
case 6 :
Squareroot1();
System.out.println("The squareroot of value " + num1 + " is: " + decimals.format(answer));
Squareroot2();
System.out.println("The squareroot of value " + num2 + " is: " + decimals.format(answer));
break;
case 7 :
absoluteNumber1();
System.out.println("The absolute number of " + num1 + " is: " + decimals.format(answer));
absoluteNumber2();
System.out.println("The absolute number of " + num2 + " is: " + decimals.format(answer));
break;
case 8 :
octalEquivalent1();
System.out.println("The octal equivalent of " + num1 + " is: " + octalEquivalent1());
octalEquivalent2();
System.out.println("The octal equivalent of " + num2 + " is: " + octalEquivalent2());
hexadecimalEquivalent1();
System.out.println("\nThe hexadecimal equivalent of " + num1 + " is: " + hexadecimalEquivalent1());
hexadecimalEquivalent2();
System.out.println("The hexadecimal equivalent of " + num2 + " is: " + hexadecimalEquivalent2());
break;
case 9 :
Round1();
System.out.println("The rounded number of " + num1 + " is: " + decimals.format(answer));
Round2();
System.out.println("The rounded number of " + num2 + " is: " + decimals.format(answer));
break;
case 0 :
if (choice2 == 0) {
System.exit(1);
break;
return choice2;
public String anotherCalculation() throws IOException {
boolean inputCorrect = false;
while (inputCorrect == false) {
try {
BufferedReader br3 = new BufferedReader (new InputStreamReader(System.in));
System.out.print("\nWould you like to do another calculation? Y/N ");
more = br3.readLine();
String s1 = "y";
String s2 = "Y";
if (more.equals(s1) || more.equals(s2)) {
inputCorrect = true;
while (inputCorrect = true){
inputNumber1();
System.out.println("");
calculatorChoice();
System.out.println("");
inputNumber2();
System.out.println("");
Calculator();
System.out.println("");
anotherCalculation();
System.out.println("");
inputCorrect = true;
} else {
System.out.println("\n" + nameSurname + " thank you for using this program, you have used this program for: " + decimals.format(programRuntime()) + " seconds");
System.out.println("the program will now exit, Goodbye.");
System.exit(0);
} catch (IOException ex){
System.out.println("You did not enter a valid answer: " + "\""+ more + "\" is not in the list!!");
inputCorrect = false;
return more;
public static void main(String[] args) throws IOException {
Project p1 = new Project();
p1.insertNameAndSurname();
System.out.println("");
p1.inputNumber1();
System.out.println("");
p1.calculatorChoice();
System.out.println("");
p1.inputNumber2();
System.out.println("");
p1.Calculator();
System.out.println("");
p1.anotherCalculation();
System.out.println("");
{code}
*Can you please run my code for yourself and have a look at how this program is constructed*
*and give me ANY feedback on how I can better this code(program) or if I've done anything wrong from your point of view.*
Your help will be much appreciated.
Thanks in advanceSmirre wrote:
Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??You cannot restrict the user. It is a sad fact in programming that the worst bug always sits in front of the Computer.
What you could do is checking the input string for numbers. If it contains numbers, just reprompt for the Name.
AND you might want to ask yourself why the heck a calculator needs to know the users Name. -
Need help with Berkeley XML DB Performance
We need help with maximizing performance of our use of Berkeley XML DB. I am filling most of the 29 part question as listed by Oracle's BDB team.
Berkeley DB XML Performance Questionnaire
1. Describe the Performance area that you are measuring? What is the
current performance? What are your performance goals you hope to
achieve?
We are measuring the performance while loading a document during
web application startup. It is currently taking 10-12 seconds when
only one user is on the system. We are trying to do some testing to
get the load time when several users are on the system.
We would like the load time to be 5 seconds or less.
2. What Berkeley DB XML Version? Any optional configuration flags
specified? Are you running with any special patches? Please specify?
dbxml 2.4.13. No special patches.
3. What Berkeley DB Version? Any optional configuration flags
specified? Are you running with any special patches? Please Specify.
bdb 4.6.21. No special patches.
4. Processor name, speed and chipset?
Intel Xeon CPU 5150 2.66GHz
5. Operating System and Version?
Red Hat Enterprise Linux Relase 4 Update 6
6. Disk Drive Type and speed?
Don't have that information
7. File System Type? (such as EXT2, NTFS, Reiser)
EXT3
8. Physical Memory Available?
4GB
9. Are you using Replication (HA) with Berkeley DB XML? If so, please
describe the network you are using, and the number of Replica’s.
No
10. Are you using a Remote Filesystem (NFS) ? If so, for which
Berkeley DB XML/DB files?
No
11. What type of mutexes do you have configured? Did you specify
–with-mutex=? Specify what you find inn your config.log, search
for db_cv_mutex?
None. Did not specify -with-mutex during bdb compilation
12. Which API are you using (C++, Java, Perl, PHP, Python, other) ?
Which compiler and version?
Java 1.5
13. If you are using an Application Server or Web Server, please
provide the name and version?
Oracle Appication Server 10.1.3.4.0
14. Please provide your exact Environment Configuration Flags (include
anything specified in you DB_CONFIG file)
Default.
15. Please provide your Container Configuration Flags?
final EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exist, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
// subsystem.
envConf.setLockDetectMode(LockDetectMode.MINWRITE);
envConf.setThreaded(true);
envConf.setErrorStream(System.err);
envConf.setCacheSize(1024*1024*64);
envConf.setMaxLockers(2000);
envConf.setMaxLocks(2000);
envConf.setMaxLockObjects(2000);
envConf.setTxnMaxActive(200);
envConf.setTxnWriteNoSync(true);
envConf.setMaxMutexes(40000);
16. How many XML Containers do you have? For each one please specify:
One.
1. The Container Configuration Flags
XmlContainerConfig xmlContainerConfig = new XmlContainerConfig();
xmlContainerConfig.setTransactional(true);
xmlContainerConfig.setIndexNodes(true);
xmlContainerConfig.setReadUncommitted(true);
2. How many documents?
Everytime the user logs in, the current xml document is loaded from
a oracle database table and put it in the Berkeley XML DB.
The documents get deleted from XML DB when the Oracle application
server container is stopped.
The number of documents should start with zero initially and it
will grow with every login.
3. What type (node or wholedoc)?
Node
4. Please indicate the minimum, maximum and average size of
documents?
The minimum is about 2MB and the maximum could 20MB. The average
mostly about 5MB.
5. Are you using document data? If so please describe how?
We are using document data only to save changes made
to the application data in a web application. The final save goes
to the relational database. Berkeley XML DB is just used to store
temporary data since going to the relational database for each change
will cause severe performance issues.
17. Please describe the shape of one of your typical documents? Please
do this by sending us a skeleton XML document.
Due to the sensitive nature of the data, I can provide XML schema instead.
18. What is the rate of document insertion/update required or
expected? Are you doing partial node updates (via XmlModify) or
replacing the document?
The document is inserted during user login. Any change made to the application
data grid or other data components gets saved in Berkeley DB. We also have
an automatic save every two minutes. The final save from the application
gets saved in a relational database.
19. What is the query rate required/expected?
Users will not be entering data rapidly. There will be lot of think time
before the users enter/modify data in the web application. This is a pilot
project but when we go live with this application, we will expect 25 users
at the same time.
20. XQuery -- supply some sample queries
1. Please provide the Query Plan
2. Are you using DBXML_INDEX_NODES?
Yes.
3. Display the indices you have defined for the specific query.
XmlIndexSpecification spec = container.getIndexSpecification();
// ids
spec.addIndex("", "id", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
spec.addIndex("", "idref", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// index to cover AttributeValue/Description
spec.addIndex("", "Description", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_SUBSTRING, XmlValue.STRING);
// cover AttributeValue/@value
spec.addIndex("", "value", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// item attribute values
spec.addIndex("", "type", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// default index
spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// save the spec to the container
XmlUpdateContext uc = xmlManager.createUpdateContext();
container.setIndexSpecification(spec, uc);
4. If this is a large query, please consider sending a smaller
query (and query plan) that demonstrates the problem.
21. Are you running with Transactions? If so please provide any
transactions flags you specify with any API calls.
Yes. READ_UNCOMMITED in some and READ_COMMITTED in other transactions.
22. If your application is transactional, are your log files stored on
the same disk as your containers/databases?
Yes.
23. Do you use AUTO_COMMIT?
No.
24. Please list any non-transactional operations performed?
No.
25. How many threads of control are running? How many threads in read
only mode? How many threads are updating?
We use Berkeley XML DB within the context of a struts web application.
Each user logged into the web application will be running a bdb transactoin
within the context of a struts action thread.
26. Please include a paragraph describing the performance measurements
you have made. Please specifically list any Berkeley DB operations
where the performance is currently insufficient.
We are clocking 10-12 seconds of loading a document from dbd when
five users are on the system.
getContainer().getDocument(documentName);
27. What performance level do you hope to achieve?
We would like to get less than 5 seconds when 25 users are on the system.
28. Please send us the output of the following db_stat utility commands
after your application has been running under "normal" load for some
period of time:
% db_stat -h database environment -c
% db_stat -h database environment -l
% db_stat -h database environment -m
% db_stat -h database environment -r
% db_stat -h database environment -t
(These commands require the db_stat utility access a shared database
environment. If your application has a private environment, please
remove the DB_PRIVATE flag used when the environment is created, so
you can obtain these measurements. If removing the DB_PRIVATE flag
is not possible, let us know and we can discuss alternatives with
you.)
If your application has periods of "good" and "bad" performance,
please run the above list of commands several times, during both
good and bad periods, and additionally specify the -Z flags (so
the output of each command isn't cumulative).
When possible, please run basic system performance reporting tools
during the time you are measuring the application's performance.
For example, on UNIX systems, the vmstat and iostat utilities are
good choices.
Will give this information soon.
29. Are there any other significant applications running on this
system? Are you using Berkeley DB outside of Berkeley DB XML?
Please describe the application?
No to the first two questions.
The web application is an online review of test questions. The users
login and then review the items one by one. The relational database
holds the data in xml. During application load, the application
retrieves the xml and then saves it to bdb. While the user
is making changes to the data in the application, it writes those
changes to bdb. Finally when the user hits the SAVE button, the data
gets saved to the relational database. We also have an automatic save
every two minues, which saves bdb xml data and saves it to relational
database.
Thanks,
Madhav
[email protected]Could it be that you simply do not have set up indexes to support your query? If so, you could do some basic testing using the dbxml shell:
milu@colinux:~/xpg > dbxml -h ~/dbenv
Joined existing environment
dbxml> setverbose 7 2
dbxml> open tv.dbxml
dbxml> listIndexes
dbxml> query { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }
dbxml> queryplan { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }Verbosity will make the engine display some (rather cryptic) information on index usage. I can't remember where the output is explained; my feeling is that "V(...)" means the index is being used (which is good), but that observation may not be accurate. Note that some details in the setVerbose command could differ, as I'm using 2.4.16 while you're using 2.4.13.
Also, take a look at the query plan. You can post it here and some people will be able to diagnose it.
Michael Ludwig -
Need help with a simple process with FTP Adapter and File Adapter
I am trying out a simple BPEL process that gets a file in opaque mode from a FTP server using a FTP adapter and writes it to the local file system using a File Adapter. However, the file written is always empty (zero bytes). I then tried out the FTPDebatching sample using the same FTP server JNDI name and this work fine surprisingly. I also verified by looking at the FTP server logs that my process actually does hit the FTP server and seems to list the files based on the filtering condition - but it does not issue any GET or RETR commands to actually get the files. I am suspecting that the problem could be in the Receive, Assign or Invoke activities, but I am not able identify what it is.
I can provide additional info such as the contents of my bpel and wsdl files if needed.
Would appreciate if someone can help me with this at the earliest.
Thanks
Jaypersiandude wrote:
Topic: Need help with if, else, and which statements and loops.
How would I display 60 < temp. <= 85 in java
System.out.println("60 < temp. <= 85 in java");
another question is how do I ask a question like want to try again (y/n) after a output and asking that everytime I type in yes after a output and terminate when saying No.Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
[http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806]. -
Need help with my usecase based on transient ViewObject
I am using 11.1.1.4.0 Jdev version. I need help with my usecase.Been trying it for 2 days but couldn't figure out the issue.
I have a transientVO . In this VO Rows will be populated programmatically. CountryId is an attribute of this VO. I have created a viewAccessor "CountriesVA" from Country VO of HR schema.
I have a LOV for the countryId which is based on this VA ,getting countries from CountryTable.
This is the model part which works fine.
Before the page load i have called a method to create a row for this transientVO.Once the row is created i can see the SOC in my page which i have created as below.
Now i want to insert a row in the transientVO if user selects a country and restrict duplicate entry . (As One row is already created 1st time there will be no rows created.after that rows will be inserted)
The issue is :: Suppose there are 2 countries. A & B .When user does the following actions :
Insert A . Done //as 1st entry
Insert B . Done //as 1st time entry
Insert A . duplicate not inserted
Insert B . getting inserted // the bug.
<af:selectOneChoice value="#{bindings.CountryId.inputValue}"
label="#{bindings.CountryId.label}"
required="#{bindings.CountryId.hints.mandatory}"
shortDesc="#{bindings.CountryId.hints.tooltip}" id="soc1"
immediate="true" autoSubmit="true"
valueChangeListener="#{pageFlowScope.managedBean.countryIdVC}">
public void countryIdVC(ValueChangeEvent valueChangeEvent) {
// Add event code here...
String oldValue=null;
setEL("#{bindings.CountryId.inputValue}", valueChangeEvent.getOldValue());
if(evaluateEL("#{bindings.CountryId.attributeValue}")!=null)
oldValue =evaluateEL("#{bindings.CountryId.attributeValue}").toString();
setEL("#{bindings.CountryId.inputValue}", valueChangeEvent.getNewValue());
String newValue=evaluateEL("#{bindings.CountryId.attributeValue}").toString();
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("ViewObj1Iterator");
//access the underlying RowSetIterator
RowSetIterator rsi = dciter.getRowSetIterator();
boolean duplicate=true;
if(oldValue!=null){
rsi.getCurrentRow().setAttribute("CountryId", oldValue);
// Row row= rsi.findByKey(new Key(new Object[] { newValue}), 1)[0];
Key key =new Key(new Object[] { newValue});
Row row=rsi.getRow(key);
if(row==null){
System.err.println(duplicate);
duplicate=false;
}else{
rsi.setCurrentRow(row);
if(!duplicate){
//get handle to the last row
Row lastRow = rsi.last();
//obtain the index of the last row
int lastRowIndex = rsi.getRangeIndexOf(lastRow);
//create a new row
Row newRow = rsi.createRow();
newRow.setAttribute("CountryId", newValue);
//initialize the row
newRow.setNewRowState(Row.STATUS_INITIALIZED);
//add row to last index + 1 so it becomes last in the range set
rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);
//make row the current row so it is displayed correctly
rsi.setCurrentRow(newRow);I read the reply from Andrejus Baranovskis and thought of studying and implementing that in my useCase.Well it worked . I implemented the same Logic but rowIteration was done in AppModule.
Con-Fusion, Bugs, Facts &amp; Workarounds: Iterating through View Object RowIterator Bug.(NOT ADF BUG, Development B…
http://docs.oracle.com/cd/E15523_01/web.1111/b31974/bcservices.htm#sm0206
9.7.6 What You May Need to Know About Programmatic Row Set Iteration
The problem is solved ,the above links helped me solve the problem.
what i did is i have created a method in appmodule to iterate rows and all the method y operation bindings and my logic works fine ....
MY Advice to all Adf developers ,though i am not an expert but i can assure you to follow the above process for rowIteration.If you use the iterator binding in the manage bean to navigate the rows u'll face issues which are unexpected.
In AppModule :::::
public boolean createRow(String oldValue,String newValue){
System.err.println(oldValue+""+newValue);
ViewObjectImpl vo=getViewObj1();
boolean duplicate=false;
if(oldValue!=null){
RowSetIterator iter = vo.createRowSetIterator(null);
System.err.println("iterating rows ");
while (iter.hasNext()) {
Row r = iter.next();
System.err.println(iter.getRangeIndexOf(r)+" row is "+r.getAttribute("CountryId"));
if(r.getAttribute("CountryId").toString().equals(newValue)){
duplicate=true;
break;
// Do something with the current row.
// close secondary row set iterator
iter.closeRowSetIterator();
return duplicate;
In ManageBean :::::
public void countryIdVC(ValueChangeEvent valueChangeEvent) {
// Add event code here...
String oldValue=null;
System.err.println("Old Value"+valueChangeEvent.getOldValue());
setEL("#{bindings.CountryId.inputValue}", valueChangeEvent.getOldValue());
if(evaluateEL("#{bindings.CountryId.attributeValue}")!=null)
oldValue =evaluateEL("#{bindings.CountryId.attributeValue}").toString();
setEL("#{bindings.CountryId.inputValue}", valueChangeEvent.getNewValue());
String newValue=evaluateEL("#{bindings.CountryId.attributeValue}").toString();
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
//access the name of the iterator the table is bound to. Its "allDepartmentsIterator"
//in this sample
DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("ViewObj1Iterator");
//access the underlying RowSetIterator
RowSetIterator rsi = dciter.getRowSetIterator();
if(oldValue!=null){
rsi.getCurrentRow().setAttribute("CountryId", oldValue);
OperationBinding operation = bindings.getOperationBinding("createRow");
operation.getParamsMap().put("oldValue", oldValue);
operation.getParamsMap().put("newValue", newValue);
if(!(Boolean)operation.execute()){
//get handle to the last row
Row lastRow = rsi.last();
//obtain the index of the last row
int lastRowIndex = rsi.getRangeIndexOf(lastRow);
//create a new row
Row newRow = rsi.createRow();
newRow.setAttribute("CountryId", newValue);
//initialize the row
newRow.setNewRowState(Row.STATUS_INITIALIZED);
//add row to last index + 1 so it becomes last in the range set
System.err.println("Inserting row at index "+lastRowIndex+1);
rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);
//make row the current row so it is displayed correctly
rsi.setCurrentRow(newRow);
else{
System.err.println("Data found So not inserting,only setting current Row");
Key key =new Key(new Object[] { newValue});
rsi.setCurrentRow(rsi.getRow(key)); -
Need help with my addressbook program
hi,
i need help with my program here. this one should works as:
- saves user input into a txt file
- displays name of the saved person on the jlist whenever i run the program
- displays info about the person when clicked via textboxes given by reading the txt file where the user inputs are
- should scroll when the list exceeds the listbox
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.JList;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.event.*;
import java.io.FilterInputStream;
public class AddressList extends JPanel implements ActionListener
JTextField txt1 = new JTextField();
JTextField txt2 = new JTextField();
JTextField txt3 = new JTextField();
DefaultListModel mdl = new DefaultListModel();
JList list = new JList();
JScrollPane listScroller = new JScrollPane(list);
ListSelectionModel listSelectionModel;
File fob = new File("Address3.txt");
String name;
char[] chars;
public void ListDisplay()
try
RandomAccessFile rand = new RandomAccessFile(fob,"rw");
BufferedReader br = new BufferedReader(new FileReader("Address3.txt"));
if(fob.exists())
while((name = rand.readLine()) != null)
chars = name.toCharArray();
if(chars[0] == '*')
mdl.addElement(name);
list.setModel(mdl);
if(chars[0] == '#')
continue;
else
System.out.println("No such file..");
catch(IOException a)
System.out.println(a.getMessage());
public AddressList()
this.setLayout(null);
listSelectionModel = list.getSelectionModel();
listSelectionModel.addListSelectionListener(new ListInfo());
list.setBounds(10,40,330,270);
listScroller.setBounds(320,40,20,100);
add(list);
add(listScroller);
JLabel lbl4 = new JLabel("Name: ");
lbl4.setBounds(400,10,80,30);
add(lbl4);
JLabel lbl5 = new JLabel("Cellphone #: ");
lbl5.setBounds(400,50,80,30);
add(lbl5);
JLabel lbl6 = new JLabel("Address: ");
lbl6.setBounds(400,90,80,30);
add(lbl6);
JLabel lbl7 = new JLabel("List ");
lbl7.setBounds(10,10,100,30);
add(lbl7);
txt1.setBounds(480,10,200,30);
add(txt1);
txt2.setBounds(480,50,200,30);
add(txt2);
txt3.setBounds(480,90,200,30);
add(txt3);
JButton btn1 = new JButton("Add");
btn1.setBounds(480,130,100,30);
btn1.addActionListener(this);
btn1.setActionCommand("Add");
add(btn1);
JButton btn2 = new JButton("Save");
btn2.setBounds(480,170,100,30);
btn2.addActionListener(this);
btn2.setActionCommand("Save");
add(btn2);
JButton btn3 = new JButton("Cancel");
btn3.setBounds(480,210,100,30);
btn3.addActionListener(this);
btn3.setActionCommand("Cancel");
add(btn3);
JButton btn4 = new JButton("Close");
btn4.setBounds(480,250,100,30);
btn4.addActionListener(this);
btn4.setActionCommand("Close");
add(btn4);
public static void main(String[]args)
JFrame frm = new JFrame("Address List");
AddressList panel = new AddressList();
frm.getContentPane().add(panel,"Center");
frm.setSize(700,350);
frm.setVisible(true);
panel.ListDisplay();
public void actionPerformed(ActionEvent e)
String cmd;
cmd = e.getActionCommand();
if(cmd.equals("Add"))
txt1.setText("");
txt2.setText("");
txt3.setText("");
else if(cmd.equals("Save"))
mdl.addElement(txt1.getText());
list.setModel(mdl);
try
RandomAccessFile rand = new RandomAccessFile(fob,"rw");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
LineNumberReader line = new LineNumberReader(br);
if(fob.exists())
rand.seek(fob.length());
rand.writeBytes("* " + txt1.getText());
rand.writeBytes("\r\n" + "# " + txt2.getText());
rand.writeBytes("\r\n" + "# " + txt3.getText() + "\r\n");
else
System.out.println("No such file..");
txt1.setText("");
txt2.setText("");
txt3.setText("");
catch(IOException a)
System.out.println(a.getMessage());
else if(cmd.equals("Cancel"))
txt1.setText("");
txt2.setText("");
txt3.setText("");
else if(cmd.equals("Close"))
System.exit(0);
class ListInfo implements ListSelectionListener
public void valueChanged(ListSelectionEvent e)
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
int minIndex = lsm.getMinSelectionIndex();
int maxIndex = lsm.getMaxSelectionIndex();
try //*this one should display the info of the person whenever i click the person's name at the list box via textbox.. but i cant seem to get it right since it always display the info of the first person inputed.. i tried to get the program to display them whenever it reads lines with * on them....
File fob = new File("Address3.txt");
RandomAccessFile rand = new RandomAccessFile(fob,"rw");
BufferedReader br = new BufferedReader(new FileReader("Address3.txt"));
LineNumberReader line = new LineNumberReader(br);
if(fob.exists())
for(int i = minIndex; i<=maxIndex; i++)
if(lsm.isSelectedIndex(i))
while((name = rand.readLine()) != null)
chars = name.toCharArray();
if(chars[0] == '#')
continue;
if(chars[0] == '*')
txt1.setText(rand.readLine());
txt2.setText(rand.readLine());
txt3.setText(rand.readLine());
else
System.out.println("No such file..");
catch(IOException a)
System.out.println(a.getMessage());
}the only problem now is about how it should display the right info about the person whenever i click its name on the list.. something about file reading or something, i just cant figure it out.
and also about how to make it scroll once it exceeds the list.. i cant make it work, maybe something about wrong declaration..
thanks in advance..
Edited by: syder on Mar 14, 2008 2:26 AMLike said before, do one thing at a time. At startup, something like:
//put all the content in a list
ArrayList<String> lines = new ArrayList<String>();
while(String line=rand.readLine()!=null) {
lines.add(line);
}If you follow the good advice to create a class to encapsulate the entries, you could populate a list of such entries like this:
static final int ENTRY_SIZE = 3;//you have 3 fields now, better to have a constant if that changes
ArrayList<Entry> entries = new ArrayList<Entry>();
for(int i=0; i<lines.size(); i+=ENTRY_SIZE) {
Entry entry = new Entry(lines.get(i), lines.get(i+1), lines.get(i+2);
entries.add(newEntry);
}You could also do both of the above in one run, but I think you will understand better what's happening if you do one thing at a time.
If you don't want to put the entries in an encapsulating class, you can still access this without looping:
int listStartIdx = <desired_entry_index>*ENTRY_SIZE;
String att1 = lines.get(listStartIdx).substring(1);
String att2 = lines.get(listStartIdx+1).substring(1);
String att3 = lines.get(listStartIdx+2).substring(1);
Maybe you are looking for
-
Storing files on erased external hard drive
I'm an amateur at using external hard drives,so the first time I used one( Seagate Backup Plus 1T),I partitioned it so that way I could use half for Time Machine and the other half for storage.When I first partitioned it, I used the "erase" button" f
-
DVI to Composite adapter zooms setting of my cinema screen 400%
When I plug in a brand new DVI to Composite adapter (Nothing else attached) my 23" screen goes first to blue, then it magnifies the entire screen content by about 400%. The signal delivered is also set to 400% of the required screen content. I have c
-
Apple Apps not connecting.
I just moved to a new apartment, and now have Comcast as my primary internet provider. But, my Macbook Pro is my main computer at the moment, and any Apple related software (itunes, safari, software update, etc.) say that I am not connected to the in
-
I understand i need to download these softwares before i can update my at&t Lumia 1520 to denim. Is there a link to download firmware : 02061.00074.14273.33019 and firmware 1028.3562.1407.1001 Solved! Go to Solution.
-
Network folders for "other" user
I have managed to set up a lab of iMacs (new) bound to AD via Windows Server. I had users make shortcuts to their 3 main network folders. Works fine. Users can't always get to "their" workstations though so I'd like to set up the "other" user to load