Identificarte

Versión Completa : Splash Screen


Sponsored links
.




nevsoft
febrero 7, 2007, 02:40
salu2 laneros

estoy haciendo un programa que quisiera ponerle una funcion que es la siguiente.

no se si han visto (creo que es obio) cuando carga word aparece una ventanita de cargando y luego entra en el programa, eso es lo que quiero meter, una ventana que cargue, pero que no se vea la barra de cerrar, minimizar.

les agradezco informacion

WhItEPoWeR
febrero 7, 2007, 03:14
salu2 laneros

estoy haciendo un programa que quisiera ponerle una funcion que es la siguiente.

no se si han visto (creo que es obio) cuando carga word aparece una ventanita de cargando y luego entra en el programa, eso es lo que quiero meter, una ventana que cargue, pero que no se vea la barra de cerrar, minimizar.

les agradezco informacion

Si es en java


/*
* (C) 2004 - Geotechnical Software Services
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
package no.geosoft.cc.ui;



import java.net.URL;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.Timer;
import javax.swing.JWindow;



/**
* Class representing an application splash screen.
* <p>
* Typical usage:
* <pre>
* SplashScreen splashScreen = new SplashScreen ("/com/company/splash.jpg");
* splashScreen.open (3000);
* </pre>
*
* @author <a href="mailto:jacob.dreyer@geosoft.no">Jacob Dreyer</a>
*/
public class SplashScreen extends JWindow
{
private Image image_;
private int x_, y_, width_, height_;



/**
* Create a new splash screen object of the specified image.
* The image file is located and referred to through the deployment, not
* the local file system; A typical value might be "/com/company/splash.jpg".
*
* @param imageFileName Name of image file resource to act as splash screen.
*/
public SplashScreen (String imageFileName)
{
super (new Frame());

try {
Toolkit toolkit = Toolkit.getDefaultToolkit();

URL imageUrl = getClass().getResource (imageFileName);
image_ = toolkit.getImage (imageUrl);

MediaTracker mediaTracker = new MediaTracker (this);
mediaTracker.addImage (image_, 0);
mediaTracker.waitForID (0);

width_ = image_.getWidth (this);
height_ = image_.getHeight (this);

Dimension screenSize = toolkit.getScreenSize();

x_ = (screenSize.width - width_) / 2;
y_ = (screenSize.height - height_) / 2;
}
catch (Exception exception) {
exception.printStackTrace();
image_ = null;
}
}



/**
* Open the splash screen and keep it open for the specified duration
* or until close() is called explicitly.
*/
public void open (int nMilliseconds)
{
if (image_ == null) return;

Timer timer = new Timer (Integer.MAX_VALUE, new ActionListener() {
public void actionPerformed (ActionEvent event) {
((Timer) event.getSource()).stop();
close();
};
});

timer.setInitialDelay (nMilliseconds);
timer.start();

setBounds (x_, y_, width_, height_);
setVisible (true);
}



/**
* Close the splash screen.
*/
public void close()
{
setVisible (false);
dispose();
}



/**
* Paint the splash screen window.
*
* @param graphics The graphics instance.
*/
public void paint (Graphics graphics)
{
System.out.println ("paint");
if (image_ == null) return;
graphics.drawImage (image_, 0, 0, width_, height_, this);
}
}

Tomado de http://geosoft.no/software/splashscreen/SplashScreen.java.html

Si es en java 6 he escuchado que ya existe una clase que hace eso

Tael Yang
febrero 7, 2007, 06:49
mejo necesitamos saber en que lenguaje porque nos queda como dificil adivinar

Oesoto
febrero 7, 2007, 08:02
Eso se llama un Splash Screen.

En Visual Basic está el asistente para hacer Splash Screens. Yo tengo una con este código

Public NotInheritable Class SplashScreen1
Public count As Integer = 3

'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
' of the Project Designer ("Properties" under the "Project" menu).


Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set up the dialog text at runtime according to the application's assembly information.

'TODO: Customize the application's assembly information in the "Application" pane of the project
' properties dialog (under the "Project" menu).

'Application title
If My.Application.Info.Title <> "" Then

Else
'If the application title is missing, use the application name, without the extension

End If

'Format the version information using the text set into the Version control at design time as the
' formatting string. This allows for effective localization if desired.
' Build and revision information could be included by using the following code and changing the
' Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar. See
' String.Format() in Help for more information.
'
' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)



'Copyright info
Timer1.Interval = 1000
Timer1.Enabled = True


End Sub


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
count = count - 1
If count = 0 Then
Timer1.Enabled = False
Me.Visible = False
Form1.Visible = True
Me.Close()
End If
End Sub
End Class

y en un adjunto le dejo el ejemplo para Java. La clase que tiene el main es TestSplash.java

Grissom.
febrero 7, 2007, 09:27
int main( int argc, char **argv )
{
QApplication app( argc, argv );
QPixmap pixmap( "splash.jpg" );
QSplashScreen *splash = new QSplashScreen( pixmap );
splash->show();
QMainWindow *mainWin = new QMainWindow;
...
app.setMainWidget( mainWin );
mainWin->show();
splash->finish( mainWin );
delete splash;
return app.exec();
}

UAC-Guille
febrero 7, 2007, 11:46
Ese ultimo ejemplo es en C++/QT??

Tael Yang
febrero 8, 2007, 05:57
Oesoto (http://www.laneros.com/member.php?u=7285) ese codigo se pone en un formulario, en un modulo de clase, en un modulo sencillo???

Oesoto
febrero 8, 2007, 06:11
Oesoto (http://www.laneros.com/member.php?u=7285) ese codigo se pone en un formulario, en un modulo de clase, en un modulo sencillo???


Yo aquí lo tengo en un proyecto como la clase SplashScreen1.vb y en el momento de la creación se le dice que va a ser de tipo SplashScreen.

En las propiedades del proyecto se le dice que cuando arranque la aplicación se haga con ese SplashScreen.

No se mucho de esto porque como VB maneja eso con asistentes entonces muchas de las configuraciones y hasta parte del código lo pone automáticamente.

Grissom.
febrero 8, 2007, 09:22
Ese ultimo ejemplo es en C++/QT??

Sí, así es.