Monday, June 27, 2016

JAVAFX THREAD



JAVAFX THREAD TO CHANGE UI (USER INTERFACE) FORM DYNAMICALLY


import javafx.application.Platform;

Platform.setImplicitExit(false);
            Task task = new Task<Void>() {
                @Override
                public Void call() throws Exception {
                    int i = 0;
                    Thread.sleep(100);

                    Platform.runLater(new Runnable() {
                        public void run() {

                           
                            proViewContlr.getProView().getScroll()
                                    .setVvalue(0.70);
                        }
                    });

                    return null;

                }
            };
            Thread th = new Thread(task);
            th.setDaemon(true);
            th.start();

DESKTOP NOTIFICATION IN JAVA (SWING)

DESKTOP NOTIFICATION IN JAVA (SWING)



import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;


public class Notification
{
    public static void init()
    {
                String message ="ALL POWER IS WITH IN YOU ,YOU CAN DO ANYTHING AND EVERYTHING BELIVE IN THAT";
                String header = "NOTIFICATION MESSAGE";
                final JFrame frame = new JFrame();
                frame.setSize(300,125);
                frame.setUndecorated(true);
                frame.setLayout(new GridBagLayout());
                GridBagConstraints constraints = new GridBagConstraints();
                constraints.gridx = 0;
                constraints.gridy = 0;
                constraints.weightx = 1.0f;
                constraints.weighty = 1.0f;
                constraints.insets = new Insets(5, 5, 5, 5);
                constraints.fill = GridBagConstraints.BOTH;
                JLabel headingLabel = new JLabel(header);
                ImageIcon img=new ImageIcon("question_icon1.png");
                headingLabel .setIcon(img); // --- use image icon you want to be as heading image.
                headingLabel.setOpaque(false);
                frame.add(headingLabel, constraints);
                constraints.gridx++;
                constraints.weightx = 0f;
                constraints.weighty = 0f;
                constraints.fill = GridBagConstraints.NONE;
                constraints.anchor = GridBagConstraints.NORTH;
                JButton cloesButton = new JButton(new AbstractAction() {
              
                    public void actionPerformed(ActionEvent e) {
                        // TODO Auto-generated method stub
                        frame.dispose();
                      
                    }
            });
                cloesButton.setText("X");
                cloesButton.setMargin(new Insets(1, 4, 1, 4));
              
                cloesButton.setFocusable(false);
                frame.add(cloesButton, constraints);
                constraints.gridx = 0;
                constraints.gridy++;
                constraints.weightx = 1.0f;
                constraints.weighty = 1.0f;
                constraints.insets = new Insets(5, 5, 5, 5);
                constraints.fill = GridBagConstraints.BOTH;
                JLabel messageLabel = new JLabel("<HtMl>"+message);
                frame.add(messageLabel, constraints);
                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();// size of the screen
                Insets toolHeight = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());// height of the task bar
                frame.setLocation(scrSize.width - frame.getWidth(), scrSize.height - toolHeight.bottom - frame.getHeight());
                frame.setVisible(true);
    }
    public static void main(String args[])
    {
        init();
      
    }

}

Tuesday, June 14, 2016

ANDROID TAB NAVIGATION




ANDROID TAB NAVIGATION


 
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;


public class AndroidTabLayoutActivity extends TabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_android_tab_layout);
        TabHost tabHost = getTabHost();
       
        // Tab for Insert new Element
        TabSpec photospec = tabHost.newTabSpec("Insert");
        // setting Title and Icon for the Tab
        photospec.setIndicator("Insert", getResources().getDrawable(R.drawable.tick_icon));
        Intent photosIntent = new Intent(this, PhotosActivity.class);
        photospec.setContent(photosIntent);
        
        // Tab For to view
        TabSpec songspec = tabHost.newTabSpec("View");       
        songspec.setIndicator("View", getResources().getDrawable(R.drawable.minutes_icon1));
        Intent songsIntent = new Intent(this, SongsActivity.class);
        songspec.setContent(songsIntent);
        
        // Tab for delete
        TabSpec videospec = tabHost.newTabSpec("Delete");
        videospec.setIndicator("Delete", getResources().getDrawable(R.drawable.question_icon1));
        Intent videosIntent = new Intent(this, VideosActivity.class);
        videospec.setContent(videosIntent);
        
        // Adding all TabSpec to TabHost
        tabHost.addTab(photospec); // Adding photos tab
        tabHost.addTab(songspec); // Adding songs tab
        tabHost.addTab(videospec); // Adding videos tab
       
    }



}