XNA - Scrolling background problem
Hi!
I'm making a C# XNA Game in Visual Studio 2010 and I've got a problem. My scrolling background does not appear all the time, only in the beginning. Here is my code in the background class:
class BackgroundGameScreen
public Texture2D texture;
public Rectangle rectangle;
public void Draw(SpriteBatch spriteBatch)
spriteBatch.Draw(texture, rectangle, Color.White);
class Scrolling : BackgroundGameScreen
public Scrolling(Texture2D newTexture, Rectangle newRectangle)
texture = newTexture;
rectangle = newRectangle;
public void Update()
rectangle.Y += 3;
Here is my code in the Game1 class:
class Game1 : Microsoft.Xna.Framework.Game
//Some other stuff
Scrolling scrolling1;
Scrolling scrolling2;
protected override void LoadContent()
//Some other stuff
scrolling1 = new Scrolling(Content.Load<Texture2D> ("AirplaneGameScreen"), new Rectangle(0, 0, 700, 630));
scrolling2 = new Scrolling(Content.Load<Texture2D>("AirplaneGameScreen1"), new Rectangle(0, -630, 700, 630));
protected override void Update(GameTime gameTime)
//Some other stuff
if (scrolling1.rectangle.Y + scrolling1.texture.Height <= 0)
scrolling1.rectangle.Y = scrolling2.rectangle.Y + scrolling2.texture.Height;
if (scrolling2.rectangle.Y + scrolling2.texture.Height <= 0)
scrolling2.rectangle.Y = scrolling1.rectangle.Y + scrolling1.texture.Height;
scrolling1.Update();
scrolling2.Update();
protected override void Draw(SpriteBatch spriteBatch)
//Some other stuff like spriteBatch.Draw(...)
scrolling1.Draw(spriteBatch);
scrolling2.Draw(spriteBatch);
I'm glad for all help I can get! :)
//Beginner
Hi friend,
Like your title mentioned, your case related to XNA. I am afraid this is out of our support. You can consider posting it in XNA forum for more efficient responses. This is the link
http://xboxforums.create.msdn.com/forums/. Thanks for your understanding.
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Similar Messages
-
Help with scrolling background
i am following a tutorial and in it, when the Hero hits a
wall he respawns somewhere on the screen. The problem with that
was, that i didnt know where he would respawn. And In order to make
the maze bigger i used a scrolling background and I couldnt figure
out how to change the respawn location either. Here is the site
that I am following the tutorial from
http://www.emanueleferonato.com/2007/02/09/flash-game-creation-tutorial-part-51/
Below is the code that I'm using
onClipEvent (load) {
yspeed = 0;
xspeed = 0;
wind = 0.00;
power = 0.65;
gravity = 0.1;
upconstant = 0.75;
friction = 0.99;
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
xspeed = xspeed-power;
if (Key.isDown(Key.RIGHT)) {
xspeed = xspeed+power;
if (Key.isDown(Key.UP)) {
yspeed = yspeed-power*upconstant;
if (Key.isDown(Key.DOWN)) {
yspeed = yspeed+power*upconstant;
xspeed = (xspeed+wind)*friction;
yspeed = yspeed+gravity;
_root.wall._y -=yspeed;
_root.wall._x -=xspeed;
_rotation = _rotation+xspeed;
if (_root.wall.hitTest(_x, _y, true)) {
xspeed = 0;
yspeed = 0;
_root.wall._x = 2500;
_root.wall._y = 1681;
Can anyone help me?there's no width property in a2. use _width:
animator = createEmptyMovieClip('animator',1);
bg_1 = animator.attachMovie('bg_mc','bg_1',1);
bg_2 = animator.attachMovie('bg_mc','bg_2',2);
bg_1._x = -bg_1._width/2;
bg_2._x = bg_2._width/2;
speed = 1;
cloudWidth = 380;
animator.onEnterFrame = function () {
bg_1._x -= speed;
bg_2._x -= speed;
if (bg_1._x <= -bg_1._width) bg_1._x = cloudWidth;
if (bg_2._x <= -bg_2._width) bg_2._x = cloudWidth; -
Hi....
gosh so many things to do and so many problems occur!
help pls......
I'm trying to stop my back groun from scrolling when it reaches end of the back ground
.it's not working.... 'm not sure why. any suggestions
var sceneTwo:Number = sceneTwoSprite.width-stage.stageWidth;
var negate1:Number = Math.abs(sceneTwoSprite.x);
var difference2:Number = Math.abs(sceneTwo);
if ((sceneTwoSprite.x)+sceneTwoSprite.width <= stage.stageWidth) {
sceneTwoSprite.x == stage.stageWidth + difference2;
Thanks in advancei tried again but still not working... sigh...
I'm not sure what happen
i wanted a scrolling background that starts on stage coords(0,0) and scrolling to left. when the background's width reaches the stage's width, i want it to stop. Reason being that i dont want to make the background to scroll infinitely. I'm just testing on the below but it just not working, sym1 is the background that width is longer than the stage and it starts at pos (0,0). I think my logic is wrong
stage.addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void{
sym1.x -=5;
var diff:Number = Math.abs(sym1.width -stage.stageWidth);
var difference:Number = Math.abs(sym1.x);
trace(diff);
if (difference <= diff) {
sym1.x = stage.stageWidth + diff; -
Scrolling background will not stop
I am trying to make a horzontial flash scrolling background and I cant seem to get it to stop at the last frame.
animator=createEmptyMovieClip('animator',1);
bg_1=animator.attachMovie('bg_mc','bg_1',1);
bg_2=animator.attachMovie('bg_mc','bg_2',1);
bg_1._x=-bg_1.width/2;
bg_1._x=-bg_2.width/2;
speed=1;
lockerWidth=550;
animator.onEnterFrame=function(){
bg_1._x-=speed;
bg_2._x-=speed;
if(bg_1._x<=-bg_1._width)bg_1._x=lockerWidth;
if(bg_2._x<=-bg_2._width)bg_2._x=lockerWidth;
I have a attached a ms doc showing how it looks in flashare you trying to stop if from looping (if so, attach a screen shot that shows its timeline and the actions panel with the stop() in frame 30) or are you trying to stop it from moving?
and, fix the code you showed:
animator=createEmptyMovieClip('animator',1);
bg_2=animator.attachMovie('bg_mc','bg_2',1);
speed=1;
lockerWidth=550;
animator.onEnterFrame=function(){
bg_2._x-=speed;
if(bg_2._x<=-bg_2._width){
bg_2._x=lockerWidth; -
Flash game scrolling background
I am creating a flash game where the character stays in the
centre of the screen and the background image scrolls past as keys
are pressed. The scrolling works fine, and the background image
won't scroll of the screen to the left or the right. It is with the
up and down where I am having a problem. The image will scroll
upwards off the screen and won't scroll downwards as it should...
here's my code:it would indirectly solve your problem because knowing that
is key to knowing the code required to prevent your background from
scrolling off-stage.
if you double click your background you should be taken that
the background's timeline. in the viewing area the stage center
(marked by a plus) is where? the upper left of your bg graphic? the
center of your bg graphic? elsewhere? -
When I put a Lightbox Display Composition at the bottom of the page the background is black at the top of the picture (it appears to be putting the picture in the center of the browser) and once you scroll down to see the caption and the rest of the picture the background is no longer black. It only happens on Lightboxes toward the bottom of the page. See below of the examples.
First picture is when you click and open the lightbox.
Then scroll down you see this:
I put a black box because the Caption is white text. If you scroll up it looks like this:
If you don't scroll all the way down to the bottom of the page it works fine:
As soon as you scroll down past a certain point the Lightbox displays at the bottom and toward the bottom have the same problem with the black not filling the screen. How do I fix this?
By the way this seems to only be a problem in Chrome. Works fine in IE and Firefox.
June 19, 2013
This is still happening in Chrome.
Go to http://rheaknives.com/available.html
in Chrome. Click on the knife in the bottom right corner. Scorll down on the picture and it works fine. BUT if you scroll to the bottom of the page and then click the same picture and scroll down on the picture this happens.
Notice the bottom is not blacked out.Anyone...help?
-
Scroll background image???
My background image (945 px wide) is larger than my Flash
window (620 px wide). When a user moves the cursor left or right, I
want the background image to move in that direction but only as far
as the edge of the image and when the cursor stops moving so should
the image. I will also have hot spots in various places that will
be clickable. I tried this code (see below), but it doesn't quite
do what I need. For one thing it continues to scroll beyond the
left and right edge of the background image. Another problem is
that the image keeps moving even though the cursor stopped, which
make it near impossible to click on my hotspots.Hey,
I have thought of using this for the exact reason. I haven't
got around to using the hotspots but check out this tutorial. I
think this what you mean.
http://www.kirupa.com/developer/flash8/interactive_image_pan.htm -
Hi there guys!
I am making a side scrolling runner game in AIR FOR ANDROID ACTIONSCRIPT3.
I have two working buttons: One for the Jump button and One for the Run button - It is already working perfectly.
My character is placed on the center left of the stage so the user has more of a preview before they encounter an obstacle.
Now my problem is how to make the background scroll to the left when the character runs to the right, also the Character can still jump when i press the jump button. I can’t figure it out guys please help! T_T
The 'walking' and 'still' are animations for the character.
This is are my codes for the jump and run button:
var dy:Number = 0;
var gravity:Number = 1;
var canjump:Boolean = false;
hero.gotoAndStop('still');
hero.speed = 0;
hero.upval = 0;
right_btn.addEventListener(MouseEvent.MOUSE_DOWN, doRight);
jump_btn.addEventListener(MouseEvent.MOUSE_DOWN, doUp);
stage.addEventListener(MouseEvent.MOUSE_UP, doStill);
stage.addEventListener(Event.ENTER_FRAME,onenter);
function doRight(e:Event):void
hero.speed = 5;
hero.scaleX = -1;
hero.gotoAndStop('walking');
function doUp(e:Event):void
hero.upval = -20;
function doStill(e:Event):void
hero.upval = 0;
hero.speed = 0;
hero.gotoAndStop('still');
function onenter(e:Event):void
hero.x += hero.speed;
dy += gravity;
if (hero.y > 441.95)
dy = 0;
canjump = true;
if (canjump)
dy = hero.upval;
canjump = false;
hero.y += dy;Can you please check if my codes are right? I changed the MouseEvents to TouchEvent.
var dy:Number = 0;
var gravity:Number = 1;
var canjump:Boolean = false;
hero.gotoAndStop('still');
hero.speed = 0;
hero.upval = 0;
backg.speed = 0;
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
right_btn.addEventListener(TouchEvent.TOUCH_BEGIN, doRight);
jump_btn.addEventListener(TouchEvent.TOUCH_BEGIN, doUp);
stage.addEventListener(TouchEvent.TOUCH_END, doStill);
stage.addEventListener(Event.ENTER_FRAME,onenter);
function doRight(e:Event):void
hero.speed = 0;
backg.speed = -5;
hero.scaleX = -1;
hero.gotoAndStop('walking');
function doUp(e:Event):void
hero.upval = -10;
function doStill(e:Event):void
hero.upval = 0;
hero.speed = 0;
backg.speed = 0;
hero.gotoAndStop('still');
function onenter(e:Event):void
hero.x += hero.speed;
backg.x += backg.speed;
dy += gravity;
if (hero.y > 239.50)
dy = 0;
canjump = true;
if (canjump)
dy = hero.upval;
canjump = false;
hero.y += dy; -
Firefox fixed background problems
Hi,
I am getting problems with Firefox using static backgrounds:
I think the problem has something to do with z-indexes getting mixed up while scrolling.
Has anyone else had this problem? Anyone know a fix? I used one for the internet explorer scrolling here: Re: Parallax Scroll problem using FF & Chrome on Windows machine
ThanksPlease provide site url as well browser details.
Thanks,
Sanjit -
Simple button background problem
Good day,
I'm new to flex and MXML. I've gone through the initial difficulties of getting familiar with the IDE and programming language. Now that this is done, I'm really starting to enjoy it.
I'm currently facing what is probably a basic problem. I've created an MXML Button component. When I instanciate it somewhere in another component, it comes up with a weird square background under my button, like this :
My button is a single line component, like this :
<s:Button label="Measure" skinClass="skins.MeasureDistanceSkin" width="70" height="25" click="OnClick(event);" creationComplete="Init(event);" />
My button instanciation line looks like this :
<MeasureButton map="{map}" left="110" top="42" width="80" height="33" id="MyButton" />
Can anyone give me a hand with this?
Thanks,
BrunoYou couldn't have made trillions of buttons that work using that code in AS3. It would have to be something more like the following to work in AS3...
stop();
btn_page2.addEventListener(MouseEvent.CLICK, gotoPage2);
function gotoPage2(e:MouseEvent):void {
gotoAndPlay(99);
Switched places in the btn_page2 line and changed Void (AS2) to void (AS3) -
Scroll bar problems ..Please help!!!!!!
This is what the program looks like. topPanel has newItemPanel on top of it. when you click continue newItemPanel becomes invisible and newItemDescriptionPanel becomes visible. When you click continue newItemDescriptionPanel becomes invisible and priceEnterPanel becomes visible.
I want newItemDescriptionPanel and priceEnterPanel to have a scroll bar. but everything I have tried hasn't worked. I am new. You will see the code is ugly and there is an attempt to add a scrollbar.
Please help
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.lang.System;
public class MainPanel extends JFrame implements ActionListener
private boolean firstRun = true;
private final int ITEM_PLAIN = 0; // Item types
private final int ITEM_CHECK = 1;
private final int ITEM_RADIO = 2;
private JPanel topPanel;
private JPanel newItemPanel;
private JRadioButton onlineAuctionRadio;
private JRadioButton fixedPriceRadio;
private ButtonGroup bg;
private JButton continueButton;
private JLabel blankLabel; //used to give space between things
private JPanel newItemDescriptionPanel;
private JPanel takeAdditionalSpacePanelCheckBox;
private JPanel takeAdditionalSpacePanel;
private JPanel takeAdditionalSpacePanelLabel;
private JPanel takeAdditionalSpacePanelLabel2;
private JPanel takeAdditionalSpacePanel2;
private JPanel takeAdditionalSpacePanel3;
private JPanel takeAdditionalSpacePanel4;
private JPanel takeAdditionalSpacePanel5;
JScrollPane displayScroller;
JEditorPane itemDescriptionTextArea;
GridBagLayout gridbag;
GridBagConstraints gbc;
private JCheckBox secondCategoryCheckBox;
private JLabel itemTitleLabel;
private JLabel requiredLabel, requiredLabel2;
private JLabel requiredStarLabel;
private JTextField itemTitleTextField;
private JLabel subtitleLabel;
private JTextField subtitleTextField;
private JLabel itemDescriptionLabel;
private JButton itemDescriptionContinueButton;
private JLabel percentageLabel;
//------- price enter page ----------------
private JLabel startingPriceLabel;
private JLabel dollarSignLabel;
private JTextField startingPriceTextField;
private JPanel fillUpSpacePanel;
private JPanel fillUpSpacePanel1;
private JPanel fillUpSpacePanel2;
private JLabel buyItNowLabel;
private JPanel fillUpSpacePanel3;
private JLabel dollarSignLabel2;
private JTextField buyItNowTextField;
private JPanel fillUpSpacePanel4;
private JPanel fillUpSpacePanel5;
private JPanel fillUpSpacePanel6;
private JPanel fillUpSpacePanel7;
private JPanel fillUpSpacePanel8;
private JPanel fillUpSpacePanel9;
private JPanel fillUpSpacePanel10;
private JPanel fillUpSpacePanel11;
private JPanel fillUpSpacePanel12;
private JPanel fillUpSpacePanel13;
private JPanel fillUpSpacePanel14;
private JPanel fillUpSpacePanel15;
private JPanel fillUpSpacePanel16;
private JPanel fillUpSpacePanel17;
private JPanel fillUpSpacePanel18;
private JLabel donatePercentageLabel;
private JTextField donatePercentageTextField;
private JPanel fSp; // fill space panel
private JPanel fSp1;
private JPanel fSp2;
private JPanel fSp3;
private JPanel fSp4;
private JPanel fSp5;
private JPanel fSp6;
private JPanel fSp7;
private JPanel fSp8;
private JPanel fSp9;
private JLabel numberOfPicturesLabel;
private JTextField numberOfPicturesTextField;
private JCheckBox superSizePicturesCheckBox;
private JLabel superSizePicturesLabel;
private JRadioButton standardPictureRadioButton;
private JRadioButton picturePackRadioButton;
private JCheckBox listingDesignerCheckBox;
private ButtonGroup bgPictures;
private JCheckBox valuePackCheckBox;
private JCheckBox galleryPictureCheckBox;
private JCheckBox subtitleCheckBox;
private JCheckBox boldCheckBox;
private JCheckBox borderCheckBox;
private JCheckBox highlightCheckBox;
private JCheckBox featuredPlusCheckBox;
private JCheckBox galleryFeaturedCheckBox;
private JLabel homePageFeaturedLabel;
private JComboBox homePageFeaturedComboBox;
private JCheckBox giftCheckBox;
JScrollPane priceEnterPanelScroll;
private JButton backToRadioButton;
private JButton backToItemDescriptionButton;
private JPanel priceEnterPanel;
private final static String RADIOPANEL = "JPanel with radios";
private final static String DESCRIPTIONPANEL = "JPanel with description";
private final static String PRICEENTERPANEL = "JPanel with price entering";
private JPanel cards;
private JMenuBar menuBar;
private JMenu menuFile;
private JMenu menuEdit;
private JMenu menuProperty;
private JMenuItem menuPropertySystem;
private JMenuItem menuPropertyEditor;
private JMenuItem menuPropertyDisplay;
private JMenu menuFileNew;
private JMenuItem menuFileNewAccount;
private JMenuItem menuFileNewItem;
private JMenuItem menuFileOpen;
private JMenuItem menuFileSave;
private JMenuItem menuFileSaveAs;
private JMenuItem menuFileExit;
private JMenuItem menuEditCopy;
private JMenuItem menuEditCut;
private JMenuItem menuEditPaste;
public MainPanel()
requiredLabel = new JLabel ("* Required");
requiredLabel.setForeground (Color.red);
requiredLabel2 = new JLabel ("* Required");
requiredLabel2.setForeground (Color.red);
requiredStarLabel = new JLabel ("*");
requiredStarLabel.setForeground (Color.green);
setTitle( "photo galleries" );
setSize( 310, 130 );
topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
topPanel.setBorder (BorderFactory.createTitledBorder ("TopPanel"));
//topPanel.setPreferredSize(new Dimension (300,300));
getContentPane().add( topPanel );
topPanel.setVisible (false);
// For New Item Panel
ButtonListener ears = new ButtonListener();
blankLabel = new JLabel (" "); // used to give space between radio buttons and continue button
continueButton = new JButton ("Continue >");
continueButton.addActionListener (ears);
backToRadioButton = new JButton ("< back");
backToRadioButton.addActionListener (ears);
itemDescriptionContinueButton = new JButton ("Continue >");
itemDescriptionContinueButton.addActionListener (ears);
backToItemDescriptionButton = new JButton ("< back");
backToItemDescriptionButton.addActionListener (ears);
newItemPanel = new JPanel();
newItemPanel.setLayout (new BoxLayout(newItemPanel, BoxLayout.Y_AXIS));
//topPanel.add (newItemPanel, BorderLayout.NORTH);
newItemPanel.setBorder (BorderFactory.createTitledBorder ("NewItemPanel"));
newItemPanel.setVisible (false);
onlineAuctionRadio = new JRadioButton ("Sold item at online Auction" );
fixedPriceRadio = new JRadioButton ("Sold at a Fixed Price");
bg = new ButtonGroup();
bg.add(onlineAuctionRadio);
bg.add(fixedPriceRadio);
onlineAuctionRadio.addActionListener (ears);
fixedPriceRadio.addActionListener (ears);
newItemPanel.add (onlineAuctionRadio);
newItemPanel.add (fixedPriceRadio);
newItemPanel.add (blankLabel);
newItemPanel.add (continueButton);
// ------ After continue pressed ---------
newItemDescriptionPanel = new JPanel();
newItemDescriptionPanel.setLayout (new BoxLayout(newItemDescriptionPanel, BoxLayout.Y_AXIS));
newItemPanel.add (newItemDescriptionPanel, BorderLayout.NORTH);
newItemDescriptionPanel.setBorder (BorderFactory.createTitledBorder ("newItemDescriptionPanel"));
secondCategoryCheckBox = new JCheckBox ("The item was listed in a second category");
newItemDescriptionPanel.setVisible (false);
itemTitleLabel = new JLabel ("Item title");
itemTitleTextField = new JTextField (30);
subtitleLabel = new JLabel ("Subtitle ($0.50)");
subtitleTextField = new JTextField (30);
itemDescriptionLabel = new JLabel ("Item description");
itemDescriptionTextArea = new JEditorPane();
itemDescriptionTextArea.setContentType( "text/html" );
itemDescriptionTextArea.setEditable( false );
itemDescriptionTextArea.setPreferredSize(new Dimension (500,250));
itemDescriptionTextArea.setFont(new Font( "Serif", Font.PLAIN, 12 ));
itemDescriptionTextArea.setForeground( Color.black );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 4;
displayScroller = new JScrollPane( itemDescriptionTextArea );
gridbag = new GridBagLayout ();
gridbag.setConstraints( displayScroller, gbc );
itemDescriptionTextArea.setEditable( true );
takeAdditionalSpacePanelCheckBox = new JPanel(new FlowLayout(FlowLayout.LEFT));
takeAdditionalSpacePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanelLabel = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanelLabel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanel4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
takeAdditionalSpacePanel5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
//takeAdditionalSpacePanel2.setBorder (BorderFactory.createTitledBorder ("Additonal 2"));
takeAdditionalSpacePanelCheckBox.add (secondCategoryCheckBox);
newItemDescriptionPanel.add (takeAdditionalSpacePanelCheckBox);
//newItemDescriptionPanel.add (blankLabel);
takeAdditionalSpacePanelLabel.add (itemTitleLabel);
takeAdditionalSpacePanelLabel.add (requiredLabel);
newItemDescriptionPanel.add (takeAdditionalSpacePanelLabel);
//newItemDescriptionPanel.add (itemTitleTextField);
takeAdditionalSpacePanel.add(itemTitleTextField);//<--add textfield to panel
newItemDescriptionPanel.add (takeAdditionalSpacePanel);//<--add panel to boxlayout panel
takeAdditionalSpacePanelLabel2.add (subtitleLabel);
newItemDescriptionPanel.add (takeAdditionalSpacePanelLabel2);
takeAdditionalSpacePanel2.add (subtitleTextField);
newItemDescriptionPanel.add (takeAdditionalSpacePanel2);
takeAdditionalSpacePanel4.add (itemDescriptionLabel);
//takeAdditionalSpacePanel4.add (requiredLabel2);
newItemDescriptionPanel.add (takeAdditionalSpacePanel4);
takeAdditionalSpacePanel3.add (displayScroller);
newItemDescriptionPanel.add (takeAdditionalSpacePanel3);
takeAdditionalSpacePanel5.add (backToRadioButton);
takeAdditionalSpacePanel5.add (itemDescriptionContinueButton);
newItemDescriptionPanel.add (takeAdditionalSpacePanel5);
//newItemDescriptionPanel.setLayout (new BoxLayout(newItemDescriptionPanel, BoxLayout.Y_AXIS));
//----------- Price Enter Page ----------------
priceEnterPanel = new JPanel();
priceEnterPanel.setLayout (new BoxLayout(priceEnterPanel, BoxLayout.Y_AXIS));
newItemDescriptionPanel.add (priceEnterPanel, BorderLayout.NORTH);
priceEnterPanel.setBorder (BorderFactory.createTitledBorder ("Price enter Panel"));
priceEnterPanel.setVisible (false);
priceEnterPanelScroll = new JScrollPane (priceEnterPanel);
topPanel.add (priceEnterPanelScroll);
standardPictureRadioButton = new JRadioButton ("Standard");
picturePackRadioButton = new JRadioButton ("Picture Pack ($1.00 for up to 6 pictures or $1.50 for 7 to 12 pictures)");
bgPictures = new ButtonGroup();
bgPictures.add(standardPictureRadioButton);
bgPictures.add(picturePackRadioButton);
standardPictureRadioButton.addActionListener (ears);
picturePackRadioButton.addActionListener (ears);
superSizePicturesCheckBox = new JCheckBox ("Supersize Pictures ($0.75)");
listingDesignerCheckBox = new JCheckBox ("Listing designer $0.10");
valuePackCheckBox = new JCheckBox ("Get the Essentials for less! Gallery, Subtitle, Listing Designer. $0.65 (save $0.30)");
superSizePicturesCheckBox.setEnabled (false);
superSizePicturesCheckBox.addActionListener (ears);
listingDesignerCheckBox.addActionListener (ears);
valuePackCheckBox.addActionListener (ears);
startingPriceLabel = new JLabel ("Starting Price");
dollarSignLabel = new JLabel ("$");
startingPriceTextField = new JTextField (10);
buyItNowLabel = new JLabel ("Buy It Now");
dollarSignLabel2 = new JLabel ("$");
buyItNowTextField = new JTextField (10);
donatePercentageLabel = new JLabel ("Donate percentage of sale");
donatePercentageTextField = new JTextField (2);
donatePercentageTextField.setText ("0");
percentageLabel = new JLabel ("%");
// Right-justify the text
donatePercentageTextField.setHorizontalAlignment(JTextField.RIGHT);
numberOfPicturesLabel = new JLabel ("Number of pictures used");
numberOfPicturesTextField = new JTextField (1);
numberOfPicturesTextField.setText ("0");
galleryPictureCheckBox = new JCheckBox ("Gallery ($0.35) [Requires a picture]");
subtitleCheckBox = new JCheckBox ("Subtitle ($0.50)");
boldCheckBox = new JCheckBox ("Bold ($1.00)");
borderCheckBox = new JCheckBox ("Border ($3.00)");
highlightCheckBox = new JCheckBox ("Highlight ($5.00)");
featuredPlusCheckBox = new JCheckBox ("Featured Plus! ($19.95)");
galleryFeaturedCheckBox = new JCheckBox ("Gallery Featured ($19.95) [Requires a picture]");
homePageFeaturedLabel = new JLabel ("Home Page Featured ($39.95 for 1 item, $79.95 for 2 or more items)");
homePageFeaturedComboBox = new JComboBox ();
homePageFeaturedComboBox.addItem (("None..."));
homePageFeaturedComboBox.addItem (("1 item"));
homePageFeaturedComboBox.addItem (("2 or more items"));
giftCheckBox = new JCheckBox ("Show as a gift ($0.25)");
fillUpSpacePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel10 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel11 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel12 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel13 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel14 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel15 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel16 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel17 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel18 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel.add (startingPriceLabel);
fillUpSpacePanel.add (requiredLabel2);
priceEnterPanel.add (fillUpSpacePanel);
fillUpSpacePanel2.add (dollarSignLabel);
fillUpSpacePanel2.add (startingPriceTextField);
priceEnterPanel.add (fillUpSpacePanel2);
// fillUpSpacePanel1.add (backToItemDescriptionButton);
// priceEnterPanel.add (fillUpSpacePanel1);
fillUpSpacePanel3.add (buyItNowLabel);
priceEnterPanel.add (fillUpSpacePanel3);
fillUpSpacePanel4.add (dollarSignLabel2);
fillUpSpacePanel4.add (buyItNowTextField);
priceEnterPanel.add (fillUpSpacePanel4);
fillUpSpacePanel1.add (donatePercentageLabel);
priceEnterPanel.add (fillUpSpacePanel1);
fillUpSpacePanel5.add (donatePercentageTextField);
fillUpSpacePanel5.add (percentageLabel);
priceEnterPanel.add (fillUpSpacePanel5);
fillUpSpacePanel6.add (numberOfPicturesLabel);
priceEnterPanel.add (fillUpSpacePanel6);
fillUpSpacePanel7.add (numberOfPicturesTextField);
priceEnterPanel.add (fillUpSpacePanel7);
fillUpSpacePanel8.add (standardPictureRadioButton);
priceEnterPanel.add (fillUpSpacePanel8);
fillUpSpacePanel10.add (blankLabel);
fillUpSpacePanel10.add (superSizePicturesCheckBox);
priceEnterPanel.add (fillUpSpacePanel10);
fillUpSpacePanel9.add (picturePackRadioButton);
priceEnterPanel.add (fillUpSpacePanel10);
fillUpSpacePanel11.add (picturePackRadioButton);
priceEnterPanel.add (fillUpSpacePanel11);
fillUpSpacePanel12.add (listingDesignerCheckBox);
priceEnterPanel.add (fillUpSpacePanel12);
fillUpSpacePanel13.add (valuePackCheckBox);
priceEnterPanel.add (fillUpSpacePanel13);
fSp.add (galleryPictureCheckBox);
priceEnterPanel.add (fSp);
fSp1.add (subtitleCheckBox);
priceEnterPanel.add (fSp1);
fSp2.add (boldCheckBox);
priceEnterPanel.add (fSp2);
fSp3.add (borderCheckBox);
priceEnterPanel.add (fSp3);
fSp4.add (highlightCheckBox);
priceEnterPanel.add (fSp4);
fSp5.add (featuredPlusCheckBox);
priceEnterPanel.add (fSp5);
fSp6.add (galleryFeaturedCheckBox);
priceEnterPanel.add (fSp6);
fSp7.add (homePageFeaturedLabel);
priceEnterPanel.add (fSp7);
fSp8.add (homePageFeaturedComboBox);
priceEnterPanel.add (fSp8);
fSp9.add (giftCheckBox);
priceEnterPanel.add (fSp9);
newItemDescriptionPanel.add (priceEnterPanelScroll);
//Create the panel that contains the "cards".
cards = new JPanel(new CardLayout());
cards.add(newItemPanel, RADIOPANEL);
cards.add(newItemDescriptionPanel, DESCRIPTIONPANEL);
cards.add(priceEnterPanel, PRICEENTERPANEL);
topPanel.add(cards, BorderLayout.NORTH);
// Create the menu bar
menuBar = new JMenuBar();
// Set this instance as the application's menu bar
setJMenuBar( menuBar );
// Build the property sub-menu
menuProperty = new JMenu( "Properties" );
menuProperty.setMnemonic( 'P' );
// Create property items
menuPropertySystem = CreateMenuItem( menuProperty, ITEM_PLAIN,
"System...", null, 'S', null );
menuPropertyEditor = CreateMenuItem( menuProperty, ITEM_PLAIN,
"Editor...", null, 'E', null );
menuPropertyDisplay = CreateMenuItem( menuProperty, ITEM_PLAIN,
"Display...", null, 'D', null );
//Build the File-New sub-menu
menuFileNew = new JMenu ("New");
menuFileNew.setMnemonic ('N');
//Create File-New items
menuFileNewItem = CreateMenuItem( menuFileNew, ITEM_PLAIN,
"Item", null, 'A', null );
menuFileNewAccount = CreateMenuItem( menuFileNew, ITEM_PLAIN,
"Account", null, 'A', null );
// Create the file menu
menuFile = new JMenu( "File" );
menuFile.setMnemonic( 'F' );
menuBar.add( menuFile );
//Add the File-New menu
menuFile.add( menuFileNew );
// Create the file menu
// Build a file menu items
menuFileOpen = CreateMenuItem( menuFile, ITEM_PLAIN, "Open...",
new ImageIcon( "open.gif" ), 'O',
"Open a new file" );
menuFileSave = CreateMenuItem( menuFile, ITEM_PLAIN, "Save",
new ImageIcon( "save.gif" ), 'S',
" Save this file" );
menuFileSaveAs = CreateMenuItem( menuFile, ITEM_PLAIN,
"Save As...", null, 'A',
"Save this data to a new file" );
// Add the property menu
menuFile.addSeparator();
menuFile.add( menuProperty );
menuFile.addSeparator();
menuFileExit = CreateMenuItem( menuFile, ITEM_PLAIN,
"Exit", null, 'X',
"Exit the program" );
//menuFileExit.addActionListener(this);
// Create the file menu
menuEdit = new JMenu( "Edit" );
menuEdit.setMnemonic( 'E' );
menuBar.add( menuEdit );
// Create edit menu options
menuEditCut = CreateMenuItem( menuEdit, ITEM_PLAIN,
"Cut", null, 'T',
"Cut data to the clipboard" );
menuEditCopy = CreateMenuItem( menuEdit, ITEM_PLAIN,
"Copy", null, 'C',
"Copy data to the clipboard" );
menuEditPaste = CreateMenuItem( menuEdit, ITEM_PLAIN,
"Paste", null, 'P',
"Paste data from the clipboard" );
public JMenuItem CreateMenuItem( JMenu menu, int iType, String sText,
ImageIcon image, int acceleratorKey,
String sToolTip )
// Create the item
JMenuItem menuItem;
switch( iType )
case ITEM_RADIO:
menuItem = new JRadioButtonMenuItem();
break;
case ITEM_CHECK:
menuItem = new JCheckBoxMenuItem();
break;
default:
menuItem = new JMenuItem();
break;
// Add the item test
menuItem.setText( sText );
// Add the optional icon
if( image != null )
menuItem.setIcon( image );
// Add the accelerator key
if( acceleratorKey > 0 )
menuItem.setMnemonic( acceleratorKey );
// Add the optional tool tip text
if( sToolTip != null )
menuItem.setToolTipText( sToolTip );
// Add an action handler to this menu item
menuItem.addActionListener( this );
menu.add( menuItem );
return menuItem;
public void actionPerformed( ActionEvent event )
CardLayout cl = (CardLayout)(cards.getLayout());
if (event.getSource() == menuFileExit)
System.exit(0);
if (event.getSource() == menuFileNewAccount)
System.out.println ("hlkadflkajfalkdjfalksfj");
if (event.getSource() == menuFileNewItem){
if (firstRun){
newItemPanel.setVisible (true);
topPanel.setVisible (true);
cl.show(cards,RADIOPANEL);
firstRun = false;
//System.out.println( event );
private class ButtonListener implements ActionListener
public void actionPerformed(ActionEvent event)
CardLayout cl = (CardLayout)(cards.getLayout());
// cl.show(cards, (String)evt.getItem());
if (event.getSource() == continueButton){
if (!(onlineAuctionRadio.isSelected()) && !(fixedPriceRadio.isSelected()))
JOptionPane.showMessageDialog(null, "You must select at least one.", "Error", JOptionPane.ERROR_MESSAGE);
else{
if (onlineAuctionRadio.isSelected()){
cl.show (cards, DESCRIPTIONPANEL);
//newItemPanel.setVisible (false);
//newItemDescriptionPanel.setVisible (true);
if (event.getSource() == itemDescriptionContinueButton){
if (itemTitleTextField.getText().trim().equalsIgnoreCase(""))
JOptionPane.showMessageDialog(null, "You must enter a title.", "Error", JOptionPane.ERROR_MESSAGE);
else
cl.show (cards, PRICEENTERPANEL);
if (event.getSource() == backToRadioButton){
cl.show (cards, RADIOPANEL);
if (event.getSource() == backToItemDescriptionButton){
cl.show(cards, DESCRIPTIONPANEL);
if (standardPictureRadioButton.isSelected()){
superSizePicturesCheckBox.setEnabled (true);
if (picturePackRadioButton.isSelected()){
superSizePicturesCheckBox.setEnabled (false);
} //end of action performed
}Mostly I see there is about 100 times as much code as I care to look at.
So you don't know how to get a panel in a scroll pane, and then get that scroll pane into your GUI? Then try doing that by itself, not encumbered with 10000 lines of irrelevant code. Once you have it working, plug it into the big lump of code. Or if you can't get it working, ask about the small problem here. -
Dynamic SELECT conditions in background - problem
Hello,
I faced a strange problem. I have function module which uses dynamic conditions in SELECT statement. Everything works fine in foreground processing, but in background the function gives no values. You can find a piece of code below. It's a bit long but as mentioned - works fine in foreground, so seems to be non-coding error... I'd be thankful for any ideas...
data: itwa_where_cond(72) occurs 20 with header line,
wa_where_cond(72) type c,
clear: itwa_where_cond[], itwa_where_cond.
move 'BZOBJ = ''0''' to wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND KADKY >= ''' l_date_start '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND KADKY <= ''' l_date_end '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND MATNR = ''' wa_matwrk-matnr '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND WERKS = ''' wa_matwrk-werks '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate 'AND KOKRS = ''' pi_kokrs '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
if not pi_freig is initial.
clear wa_where_cond.
concatenate 'AND FREIG =''' pi_freig '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_tvers is initial.
clear wa_where_cond.
concatenate 'AND TVERS = ''' pi_tvers '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_klvar is initial.
clear wa_where_cond.
concatenate 'AND KLVAR = ''' pi_klvar '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_feh_sta is initial.
clear wa_where_cond.
concatenate 'AND FEH_STA = ''' pi_feh_sta '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_kkzma is initial.
clear wa_where_cond.
concatenate ' AND KKZMA = ''' pi_kkzma '''' into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
SELECT * FROM KEKO into corresponding fields of table it_keko
WHERE (itwa_where_cond).
Regards,
GrzegorzhI,
TAKE THIS CODE... HOPE IT WORKS FOR YOU....
clear: itwa_where_cond[], itwa_where_cond.
move `BZOBJ = '0'` to wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KADKY >= '` l_date_start `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KADKY <= '` l_date_end `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND MATNR = '` wa_matwrk-matnr `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND WERKS = '` wa_matwrk-werks `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
clear wa_where_cond.
concatenate `AND KOKRS = '` pi_kokrs `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
if not pi_freig is initial.
clear wa_where_cond.
concatenate `AND FREIG = '` pi_freig `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_tvers is initial.
clear wa_where_cond.
concatenate `AND TVERS = '` pi_tvers `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_klvar is initial.
clear wa_where_cond.
concatenate `AND KLVAR = '` pi_klvar `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_feh_sta is initial.
clear wa_where_cond.
concatenate `AND FEH_STA = '` pi_feh_sta `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
if not pi_kkzma is initial.
clear wa_where_cond.
concatenate `AND KKZMA = '` pi_kkzma `'` into wa_where_cond.
append wa_where_cond to itwa_where_cond.
endif.
SELECT * FROM KEKO into corresponding fields of table it_keko
WHERE (itwa_where_cond).
REGARDS
SIDDARTH -
Mighty Mouse scroll ball problems
I wondered if anyone could help me with a scrolling issue with the mighty mouse. Some days scrolling works vertically up and down and other times just one direction. I dont believe it is due to dirt in the mouse - it seems software related and is sporadic in its operation. Any advise you could give would be welcome
Thanks
NickDP, that is what worked best for me in the past.
After months of problems with the scrolling ball, and after trying all the suggestions found on the web, this method of using a white sheet of paper was an excellent one: my MM was again clean and working as if it was new!
However, be careful about it: don't push too much when running the MM upside down. Eventually, yes, the gunk will come out, but the ball would go down-inside the case if pressed too hard for too long. It happened to me when using this method for a second time, and I was in the need to disassemble the device in order to correct this, and I think that's exactly what I was trying to avoid in the first place.
Hope it helps.
JJ -
Mighty Mouse scroll ball problem
I have had this Mighty Mouse for about a year and a half and the only problem has been the scroll ball. Every once in a while it won't scroll down. I was told to hold it upside down and rub the ball good with a wool cloth. Basically every time it did the trick. Now it won't scroll down anymore (it scrolls everywhere else though). Is there something broken inside? Is there anyway to take it apart? Not being able to scroll down is quite annoying and I'd love to be able to do it again.
Scrolling down, the ball moves but doesn't make the little clicking like sound like it does in any other direction. Any advice?Hi. Sometimes using a clear spirit such as denatured alcohol (or vodka...) instead of the water suggested here
http://docs.info.apple.com/article.html?artnum=302417
helps - but I've had one that wouldn't be fixed, and was replaced. Good Luck. -
JTabel Horizontal scroll bar problem
Hi,
I want a horizontal scroll bar added to my table
hence I do this
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
but the problem is If I increase the size of frame
the cells do not resize hence there is a gap after
the last column.
How do I remove this gapPlease reduce the container size in the screen thru SE51 that automatically create the scroll
or check whether in the attributes of the screen "Hold scroll positio" not to be checked
a®
Maybe you are looking for
-
Cb867A HP Officejet 4500 will not connect to network
I have tried over and over to connect my cb867A HP Officejet 4500 wireless printer, and it will not work. I have changed cables, triple checked everything, uninstalled and re-installed software, and I cannot get this printer to work as a wireless pr
-
Changing DB character set for only one schema
We are interested in changing the characterset of only one user from Western European to AL32UTF8. Could you please verify if the following steps will be correct to do the same. 1. Run CSScan on the one user 2. Fix any issues 3. Export that one user
-
Itunes won't open because of this
error pops up and say's QuickTime version 7.0d0 is installed, itunes requires version 7.1.3 or later. please reinstall itunes i have done this over and over....i've might have deleted something or another but can't open itunes at all anymore. Help pl
-
How does Photos handle Aperture referenced photos
In order to keep my Aperture's working library at a reasonable size, I keep the latest 3 years of photos locally and move older photos onto my NAS drive. Aperture keeps previews and can reference/open the original files as soon as I have mounted my N
-
Best way to manage login page without Tabs in Tabbedapplication
HI fellow developers! I'm encountering a problem while building my first Tablet application. I'm using Flex that communicates with PHP, that's no problem at all. I've created a testapp to test my services and everything works fine. Now, i've started