Search Results

Search found 37239 results on 1490 pages for 'javax swing text'.

Page 36/1490 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • NullPointerException when showing JFileChooser

    - by Geo
    I show a JFileChooser with this snippet: public File getDestination() { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int option = chooser.showSaveDialog(null); if(option == JFileChooser.APPROVE_OPTION) { return chooser.getSelectedFile().getAbsolutePath(); } return new File("."); } Usually, the first time it's showed, it displays & works correctly. The second time, it will always throw this exception: Exception in thread "Basic L&F File Loading Thread" java.lang.NullPointerException at sun.awt.shell.Win32ShellFolder2.pidlsEqual(Unknown Source) at sun.awt.shell.Win32ShellFolder2.equals(Unknown Source) at sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Unknown Source) at sun.awt.shell.ShellFolder.isFileSystemRoot(Unknown Source) at javax.swing.filechooser.FileSystemView.isFileSystemRoot(Unknown Source) at javax.swing.filechooser.WindowsFileSystemView.isTraversable(Unknown Source) at javax.swing.JFileChooser.isTraversable(Unknown Source) at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run0(Unknown Source) at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(Unknown Source) Java -version says: java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing) And the thread I found here says I should downgrade the Java version. Should I follow their advice, or is there something I could have done wrong?

    Read the article

  • Appcelerator Titanium - auto height table views break with shortish text

    - by ceejayoz
    I posted this on the Appcelerator Titanium dev Q&A site, but maybe someone here has had this issue... KitchenSink 1.1 illustrates this issue. In table_view_api_auto_height.js, changing row: addRow(0,'This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text. This is some long text.'); to something like: addRow(0,'This is some long text. This is some long text.'); results in incorrect left padding on the row. See screenshot:

    Read the article

  • Webrat says it can't find some text, but the text is actually there

    - by Jason
    I have a webpage that has a form button on it called "delete", and a cuke scenario that has the line: And I should see "delete" When I run the scenario, I get this error: expected the following element's content to include "delete" ...and it dumps the webrat page to stdout and the "delete" is, in fact, not there. So far so good. However, when I tell webrat to show me the page before the error happens: Then show me the page And I should see "delete" ...Safari fires up and shows me the page, and in Safari there's the "delete" button, totally there. Why is webrat not finding the form button? I've also had this same problem with form fields, such as text inputs that have a value in them when the page loads, but webrat says there's nothing there. Looking at it in Safari shows, again, that the field does have the right text in it. Is this a bug, or is webrat just not suitable for checking form elements? Is there a different way to do this? Thanks!

    Read the article

  • Java, two JPanel on JFrame - Settings JPanel, StartMenu JPanel [on hold]

    - by Andy Tyurin
    There is my first question and I welcome community! I'm making a simple game and have some problems with Start menu. I have three buttons on my JPanel StartMenu and when I click "Settings" button, new JPanel will be open, but I don't know why buttons from StartMenu JPanel appeared in my Settings JPanel. My "Settings" JPanel has one ugly button "Back" in center and ugly grey background. I made some screens to see a problem. Start Menu JPanel when game launched Settings JPanel when button clicked Settings JPanel when mouse was over settings window There is code of StartMenu class: public class StartMenu extends JPanel { private GameButton startGameButton = new GameButton("Start game"); private GameButton settingsGameButton = new GameButton("Settings"); private GameButton exitGameButton = new GameButton("Exit game"); private Image bgImage = new ImageIcon(getClass().getClassLoader().getResource("ru/andydevs/astraLaserForce/bg.png")).getImage(); private int posX; private int posY; final private int WIDTH=(int)Game.SCREEN_DIMENSION.getWidth()/3; final private int HEIGHT=(int)Game.SCREEN_DIMENSION.getHeight()/2; public StartMenu() { setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); setSize(new Dimension(WIDTH, HEIGHT)); posX=(int)Game.SCREEN_DIMENSION.getWidth()/2-WIDTH/2; posY=(int)Game.SCREEN_DIMENSION.getHeight()/2-HEIGHT/2; setBounds(posX, posY,WIDTH,HEIGHT); c.ipadx=95; c.ipady=15; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(20,0,0,0); c.gridy=0; add(startGameButton, c); c.gridy=1; c.insets = new Insets(20,0,0,0); System.out.println(settingsGameButton.getWidth()); add(settingsGameButton, c); c.gridy=2; c.insets = new Insets(20,0,0,0); add(exitGameButton, c); settingsGameButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GameOptionsPanel gop = new GameOptionsPanel(); Game.container.add(gop); Game.container.setComponentZOrder(gop, 0); Game.container.revalidate(); Game.container.repaint(); } }); exitGameButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Main.currentGame.stop(); } }); } public void paintComponent(Graphics g) { g.drawImage(bgImage,0,0,WIDTH,HEIGHT,null); } } There is code of Settings JPanel public class GameOptionsPanel extends GamePanel { private GameButton backButton = new GameButton("Back"); private GameOptionsPanel that; public GameOptionsPanel() { super((int) (Game.SCREEN_DIMENSION.getWidth()/3), (int) (Game.SCREEN_DIMENSION.getHeight()/2), new Color(50,50,50)); that=this; setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill=gbc.HORIZONTAL; add(backButton); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Game.container.remove(that); Game.container.revalidate(); Game.container.repaint(); } }); } } I glad to see some suggestions. Thanks.

    Read the article

  • Icon in titledBorder title

    - by Venno
    Hi is it possible to place an icon in the title of a titledBorder for example the following code: import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.TitledBorder; public class TitledExample extends JPanel { public TitledExample() { super(true); this.setLayout(new GridLayout(1, 1, 5, 5)); JLabel label = new JLabel("Titled Border"); label.setHorizontalAlignment(JLabel.CENTER); TitledBorder titled = new TitledBorder("Image here ?? Title"); label.setBorder(titled); add(label); } Thanks , Cheers

    Read the article

  • LookAndFeel not changing in Ubuntu

    - by Tom Brito
    Anyone knows Why the laf is not changing in the following code? (running in Ubuntu) import java.awt.Dialog; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelInfo; public class TEST extends JPanel { public TEST() { final LookAndFeelInfo[] lafArray = UIManager.getInstalledLookAndFeels(); String[] names = new String[lafArray.length]; for (int i = 0; i < names.length; i++) { names[i] = lafArray[i].getName(); } final JComboBox cb = new JComboBox(names); cb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { int index = cb.getSelectedIndex(); LookAndFeelInfo lafInfo = lafArray[index]; String lafClassName = lafInfo.getClassName(); System.out.println(lafClassName); UIManager.setLookAndFeel(lafClassName); } catch (Exception e) { e.printStackTrace(); } } }); add(cb); } public static void main(String[] args) throws Exception { System.out.println("start"); JDialog dialog = new JDialog(null, Dialog.ModalityType.APPLICATION_MODAL); dialog.setContentPane(new TEST()); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); dialog.dispose(); System.out.println("end"); } }

    Read the article

  • JPanel Appears Behind JMenuBar

    - by Matt H
    import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @SuppressWarnings("serial") public class Main extends JFrame { final int FRAME_HEIGHT = 400; final int FRAME_WIDTH = 400; public static void main(String args[]) { new Main(); } public Main() { super("Game"); GameCanvas canvas = new GameCanvas(); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem startMenuItem = new JMenuItem("Pause"); menuBar.add(fileMenu); fileMenu.add(startMenuItem); super.setVisible(true); super.setSize(FRAME_WIDTH, FRAME_WIDTH); super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); super.setJMenuBar(menuBar); } } import java.awt.Canvas; import java.awt.Graphics; import javax.swing.JPanel; @SuppressWarnings("serial") public class GameCanvas extends JPanel { public void paint(Graphics g) { g.drawString("hI", 0, 0); } } This code causes the string to appear behind the JMenuBar. To see the string, you must draw it at (0,10). I'm sure this must be something simple, so do you guys have any ideas?

    Read the article

  • Change input text to regular text on blur and ability to edit jQuery

    - by eknown
    I'm creating a form where I'm eliminating the use of a save button. The form is made up of input text boxes and textareas. After the user enters data into the input field, I want to trigger an onBlur function and change the input into a span that contains the information that the user entered. I also want to have the ability to edit this information, so if the user clicks on the newly created span with text, it will turn back into the input field with the current information for their editing pleasure. For reference, I'm looking to have a functionality pretty much like on editing a photo title on Flickr. If possible, I'd also like to have the textbox show "saving..." for half a second after the blur to reflect interaction with server.

    Read the article

  • Issue with parsed text with HTMLCleaner - spaces at the begining of text

    - by ansol90
    Im able to get text using HTMLCleaner from website. The problem is that when I set the text to a TextView it shows the beginning of the text with a big space on it. Here is the screenshot of what im talking about. I have tried android:gravity but nothing happened. Please help. Here is my Code: private class SiteParser extends AsyncTask<String, Void, String> { protected String doInBackground(String... arg) { String output = null; try { HtmlHelper hh = new HtmlHelper(new URL(arg[0])); List<TagNode> news = hh.getnewsByClass("TextoPrint"); for (Iterator<TagNode> iterator = newss.iterator(); iterator .hasNext();) { TagNode divElement = (TagNode) iterator.next(); output = divElement.getText().toString(); } } catch (Exception e) { e.printStackTrace(); } return output; } protected void onPostExecute(String output) { Bundle bundle=new Bundle(); bundle.putString("body",output); Intent mainIntent = new Intent(act, MyView.class); mainIntent.putExtras(bundle); startActivity(mainIntent); act.finish(); } } public class HtmlHelper { TagNode rootNode; public HtmlHelper(URL htmlPage) throws IOException, XPatherException { HtmlCleaner cleaner = new HtmlCleaner(); rootNode = cleaner.clean(htmlPage); } List<TagNode> getnewsByClass(String Classname){ List<TagNode> newsList = new ArrayList<TagNode>(); TagNode divElements[] = rootNode.getElementsByName("div", true); for (int i = 0; divElements != null && i < divElements.length; i++) { String classType = divElements[i].getAttributeByName("id"); if (classType != null && classType.equals(Classname)) { newsList.add(divElements[i]); } } return newsList; } }

    Read the article

  • ASP.NET Conditionally Change ButtonField text at runTime

    - by Rodney Vinyard
    ASP.NET Conditionally Change ButtonField text at runTime   <asp:ButtonField CommandName="Edit" HeaderText="" Text="Edit" ButtonType="Link" />       protected void gvRequests_RowDataBound(object sender, GridViewRowEventArgs e)     {         if (e.Row.RowType == DataControlRowType.DataRow)         {             //----------------------------------------------------             // If status = "Saved", change buttonField.LinkButton.Text to "Copy"             //----------------------------------------------------             if (e.Row.Cells[(int)gCol.Status].Text == "Saved")             {                 //----------------------------------------------------                 // no !                 //----------------------------------------------------                 //string x = e.Row.Cells[(int)gCol.EditLink].Text;                 //e.Row.Cells[(int)gCol.EditLink].Text = "Copy";                   //----------------------------------------------------                 // yes !                 //----------------------------------------------------                 LinkButton linkButton = (LinkButton)e.Row.Cells[(int)gCol.EditLink].Controls[0];                 linkButton.Text = "Copy";             }         }     }

    Read the article

  • Send SMS text messages for FREE using Java ME

    - by hinkmond
    Here's a way to get around those nasty SMS text messages charges (and maybe a way to get around the Pakistan SMS text censors too!). Use this Java ME SMS text app for your Java ME mobile phone, called JaxtrSMS: See: JaxtrSMS free Java ME SMS Here's a quote: JaxtrSMS lets you send FREE SMS and txt messages to any mobile phone in the world. Best of all, the receiver does not have to have the JaxtrSMS app. International and local SMS/texting can be expensive but with JaxtrSMS you can text anyone in the world for FREE! Great! Now, you can send 2,000 text messages from your phone every month and not worry about a huge bill. You don't send 2,000 text message in a month? Well, get it for your teenage kids then. They certainly send 2,000 text messages in a month... Hinkmond

    Read the article

  • Parse a text file into multiple text file

    - by Vijay Kumar Singh
    I want to get multiple file by parsing a input file Through Java. The Input file contains many fasta format of thousands of protein sequence and I want to generate raw format(i.e., without any comma semicolon and without any extra symbol like "", "[", "]" etc) of each protein sequence. A fasta sequence starts form "" symbol followed by description of protein and then sequence of protein. For example ? lcl|NC_000001.10_cdsid_XP_003403591.1 [gene=LOC100652771] [protein=hypothetical protein LOC100652771] [protein_id=XP_003403591.1] [location=join(12190..12227,12595..12721,13403..13639)] MSESINFSHNLGQLLSPPRCVVMPGMPFPSIRSPELQKTTADLDHTLVSVPSVAESLHHPEITFLTAFCL PSFTRSRPLPDRQLHHCLALCPSFALPAGDGVCHGPGLQGSCYKGETQESVESRVLPGPRHRH Like above formate the input file contains 1000s of protein sequence. I have to generate thousands of raw file containing only individual protein sequence without any special symbol or gaps. I have developed the code for it in Java but out put is : Cannot open a file followed by cannot find file. Please help me to solve my problem. Regards Vijay Kumar Garg Varanasi Bharat (India) The code is /*Java code to convert FASTA format to a raw format*/ import java.io.*; import java.util.*; import java.util.regex.*; import java.io.FileInputStream; // java package for using regular expression public class Arrayren { public static void main(String args[]) throws IOException { String a[]=new String[1000]; String b[][] =new String[1000][1000]; /*open the id file*/ try { File f = new File ("input.txt"); //opening the text document containing genbank ids FileInputStream fis = new FileInputStream("input.txt"); //Reading the file contents through inputstream BufferedInputStream bis = new BufferedInputStream(fis); // Writing the contents to a buffered stream DataInputStream dis = new DataInputStream(bis); //Method for reading Java Standard data types String inputline; String line; String separator = System.getProperty("line.separator"); // reads a line till next line operator is found int i=0; while ((inputline=dis.readLine()) != null) { i++; a[i]=inputline; a[i]=a[i].replaceAll(separator,""); //replaces unwanted patterns like /n with space a[i]=a[i].trim(); // trims out if any space is available a[i]=a[i]+".txt"; //takes the file name into an array try // to handle run time error /*take the sequence in to an array*/ { BufferedReader in = new BufferedReader (new FileReader(a[i])); String inline = null; int j=0; while((inline=in.readLine()) != null) { j++; b[i][j]=inline; Pattern q=Pattern.compile(">"); //Compiling the regular expression Matcher n=q.matcher(inline); //creates the matcher for the above pattern if(n.find()) { /*appending the comment line*/ b[i][j]=b[i][j].replaceAll(">gi",""); //identify the pattern and replace it with a space b[i][j]=b[i][j].replaceAll("[a-zA-Z]",""); b[i][j]=b[i][j].replaceAll("|",""); b[i][j]=b[i][j].replaceAll("\\d{1,15}",""); b[i][j]=b[i][j].replaceAll(".",""); b[i][j]=b[i][j].replaceAll("_",""); b[i][j]=b[i][j].replaceAll("\\(",""); b[i][j]=b[i][j].replaceAll("\\)",""); } /*printing the sequence in to a text file*/ b[i][j]=b[i][j].replaceAll(separator,""); b[i][j]=b[i][j].trim(); // trims out if any space is available File create = new File(inputline+"R.txt"); try { if(!create.exists()) { create.createNewFile(); // creates a new file } else { System.out.println("file already exists"); } } catch(IOException e) // to catch the exception and print the error if cannot open a file { System.err.println("cannot create a file"); } BufferedWriter outt = new BufferedWriter(new FileWriter(inputline+"R.txt", true)); outt.write(b[i][j]); // printing the contents to a text file outt.close(); // closing the text file System.out.println(b[i][j]); } } catch(Exception e) { System.out.println("cannot open a file"); } } } catch(Exception ex) // catch the exception and prints the error if cannot find file { System.out.println("cannot find file "); } } } If you provide me correct it will be much easier to understand.

    Read the article

  • Set size of JTable in JScrollPane and in JPanel with the size of the JFrame

    - by user1761818
    I want the table with the same width as the frame and also when I resize the frame the table need to be resized too. I think setSize() of JTable doesn't work correctly. Can you help me? import java.awt.Color; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; public class Main extends JFrame { public Main() { setSize(400, 600); String[] columnNames = {"A", "B", "C"}; Object[][] data = { {"Moni", "adsad", 2}, {"Jhon", "ewrewr", 4}, {"Max", "zxczxc", 6} }; JTable table = new JTable(data, columnNames); JScrollPane tableSP = new JScrollPane(table); int A = this.getWidth(); int B = this.getHeight(); table.setSize(A, B); JPanel tablePanel = new JPanel(); tablePanel.add(tableSP); tablePanel.setBackground(Color.red); add(tablePanel); setTitle("Marks"); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Main ex = new Main(); ex.setVisible(true); } }); } }

    Read the article

  • Changing Text colour in text field by dropdown menu - Visual Studio 2008

    - by Wayne
    Hey, i'm just doing some testing on Visual Studio 2008, what i'm trying to do is to change the text colour inside the multi-textfield which isn't working and I don't know why... Public Class Form1 Dim ColourValue As Color Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load rbBlue.Checked = False rbRed.Checked = False rbGreen.Checked = False End Sub Private Sub rbRed_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbRed.CheckedChanged txtSpace.BackColor = Color.Red End Sub Private Sub rbBlue_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbBlue.CheckedChanged txtSpace.BackColor = Color.Blue End Sub Private Sub rbGreen_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbGreen.CheckedChanged txtSpace.BackColor = Color.Green End Sub Private Sub cbColours_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbColours.SelectedValueChanged ColourValue = cbColours.SelectedValue txtSpace.BackColor = ColourValue End Sub End Class Basically i have the radio buttons that would change the background colour of the textfield, but i just need the dropdown menu to change the text colour. Many thanks :)

    Read the article

  • knockout bind text label to dropdown value selected option text

    - by Adam Levitt
    Is there a simple way to bind the textbox of a div to change based on the text value of the selected option in a dropdown on the same page? <div data-bind="text: dropdownValue"></div> <select> <option value="1">Value1</option> <option value="2">Value2</option> </select> Please note, I don't want to put the values into the select element using javascript. I'd like to bind to the value straight from the HTML. I can also include jQuery to make it work.

    Read the article

  • When page loads display 1st image text - hide all other text

    - by Jonah1289
    Hi I have created http://techavid.com/design/test3.html and when you load the page you see there are 3 images. The sun image is focused(in color), while the others are greyed out until clicked. That is how it should be for the images. Also when you load the page you see under each image it's own text(i.e. 1st: Sun, 2nd: Airplane, 3rd: Nano), but on page load I only want 1st:Sun to display and hide all other text until their respective image is clicked. Any idea how to do this? thanks :) J

    Read the article

  • Best way to implement game loop without freezing UI thread

    - by Matt H
    I'm trying to make a simple 2D game in Java. So far I have a JFrame, with a menubar, and a class which extends JPanel and overrides it's paint method. Now, I need to get a game loop going, where I will update the position of images and so on. However, I'm stuck at how best to achieve this. Should I use multi-threading, because surely, if you put an infinite loop on the main thread, the UI (and thus my menu bar) will freeze up? Here's my code so far: import java.awt.Color; import java.awt.Graphics; import javax.swing.JPanel; @SuppressWarnings("serial") public class GameCanvas extends JPanel { public void paint(Graphics g) { while (true) { g.setColor(Color.DARK_GRAY); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } } import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; @SuppressWarnings("serial") public class Main extends JFrame { GameCanvas canvas = new GameCanvas(); final int FRAME_HEIGHT = 400; final int FRAME_WIDTH = 400; public static void main(String args[]) { new Main(); } public Main() { super("Game"); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem startMenuItem = new JMenuItem("Pause"); menuBar.add(fileMenu); fileMenu.add(startMenuItem); super.add(canvas); super.setVisible(true); super.setSize(FRAME_WIDTH, FRAME_WIDTH); super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); super.setJMenuBar(menuBar); } } Any pointers/tips? Also, where should I put my loop? In my main class, or my GameCanvas class? Any help is appreciated, thanks.

    Read the article

  • ToolTip flicker in Java if outside JFrame? [closed]

    - by Skarion
    Hi! I am implementing ToolTip in Java as to make users having an easier time to use the product. Though tooltip that are at the borders of the JFrame and ends up outside the JFrame starts to "flicker". I've tried lots of things (like moving the tooltip so it should be inside the Jframe, controlling the painting so it ends up within the JFrame and so on) though it doesn't work. Anyone got any expertise within the field that know how to avoid this problem? Cheers, Skarion

    Read the article

  • JTable how to change BackGround Color

    - by mKorbel
    I inspired by MeBigFatGuy interesting question, in this conection I have very specific question about Graphisc2D, how to change BackGround Color by depends if is JTables Row visible in the JViewPort, 1) if 1st. & last JTables Row will be visible in the JViewPort, then BackGround would be colored to the Color.red 2) if 1st. & last JTables Row will not be visible in the JViewPort, then BackGround would be colored to the Color.whatever from SSCCE import java.awt.*; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; import javax.swing.*; import javax.swing.RepaintManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.TableModel; /* http://stackoverflow.com/questions/1249278/ how-to-disable-the-default-painting-behaviour-of-wheel-scroll-event-on-jscrollpan * and * http://stackoverflow.com/questions/8195959/ swing-jtable-event-when-row-is-visible-or-when-scrolled-to-the-bottom */ public class ViewPortFlickering { private JFrame frame = new JFrame("Table"); private JViewport viewport = new JViewport(); private Rectangle RECT = new Rectangle(); private Rectangle RECT1 = new Rectangle(); private JTable table = new JTable(50, 3); private javax.swing.Timer timer; private int count = 0; public ViewPortFlickering() { GradientViewPort tableViewPort = new GradientViewPort(table); viewport = tableViewPort.getViewport(); viewport.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { RECT = table.getCellRect(0, 0, true); RECT1 = table.getCellRect(table.getRowCount() - 1, 0, true); Rectangle viewRect = viewport.getViewRect(); if (viewRect.intersects(RECT)) { System.out.println("Visible RECT -> " + RECT); } else if (viewRect.intersects(RECT1)) { System.out.println("Visible RECT1 -> " + RECT1); } else { // } } }); frame.add(tableViewPort); frame.setPreferredSize(new Dimension(600, 300)); frame.pack(); frame.setLocation(50, 100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); RepaintManager.setCurrentManager(new RepaintManager() { @Override public void addDirtyRegion(JComponent c, int x, int y, int w, int h) { Container con = c.getParent(); while (con instanceof JComponent) { if (!con.isVisible()) { return; } if (con instanceof GradientViewPort) { c = (JComponent) con; x = 0; y = 0; w = con.getWidth(); h = con.getHeight(); } con = con.getParent(); } super.addDirtyRegion(c, x, y, w, h); } }); frame.setVisible(true); start(); } private void start() { timer = new javax.swing.Timer(100, updateCol()); timer.start(); } public Action updateCol() { return new AbstractAction("text load action") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { System.out.println("updating row " + (count + 1)); TableModel model = table.getModel(); int cols = model.getColumnCount(); int row = 0; for (int j = 0; j < cols; j++) { row = count; table.changeSelection(row, 0, false, false); timer.setDelay(100); Object value = "row " + (count + 1) + " item " + (j + 1); model.setValueAt(value, count, j); } count++; if (count >= table.getRowCount()) { timer.stop(); table.changeSelection(0, 0, false, false); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { table.clearSelection(); } }); } } }; } public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { ViewPortFlickering viewPortFlickering = new ViewPortFlickering(); } }); } } class GradientViewPort extends JScrollPane { private static final long serialVersionUID = 1L; private final int h = 50; private BufferedImage img = null; private BufferedImage shadow = new BufferedImage(1, h, BufferedImage.TYPE_INT_ARGB); private JViewport viewPort; public GradientViewPort(JComponent com) { super(com); viewPort = this.getViewport(); viewPort.setScrollMode(JViewport.BLIT_SCROLL_MODE); viewPort.setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); viewPort.setScrollMode(JViewport.SIMPLE_SCROLL_MODE); Graphics2D g2 = shadow.createGraphics(); g2.setPaint(new Color(250, 150, 150)); g2.fillRect(0, 0, 1, h); g2.setComposite(AlphaComposite.DstIn); g2.setPaint(new GradientPaint(0, 0, new Color(0, 0, 0, 0f), 0, h, new Color(0.5f, 0.8f, 0.8f, 0.5f))); g2.fillRect(0, 0, 1, h); g2.dispose(); } @Override public void paint(Graphics g) { if (img == null || img.getWidth() != getWidth() || img.getHeight() != getHeight()) { img = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); } Graphics2D g2 = img.createGraphics(); super.paint(g2); Rectangle bounds = getViewport().getVisibleRect(); g2.scale(bounds.getWidth(), -1); int y = (getColumnHeader() == null) ? 0 : getColumnHeader().getHeight(); g2.drawImage(shadow, bounds.x, -bounds.y - y - h, null); g2.scale(1, -1); g2.drawImage(shadow, bounds.x, bounds.y + bounds.height - h + y, null); g2.dispose(); g.drawImage(img, 0, 0, null); } }

    Read the article

  • Does anybody develops Java desktop applications? [closed]

    - by Eirc man
    I was just wondering if there are there developers making java software for desktops. Is it even worth it, do any developers do that for living. I am making a chat application using sockets and and java GUI, just for fun, but then I wanted to see some examples of desktop apps, but did not find many. I have heard that Netbeans, is made using java, but the Netbeans in my Windows to me it seems like any other native Windows application

    Read the article

  • Rendering only a part of text FTGL, OpenGL

    - by Mosquito
    I'm using FTGL library to render text in my C++ project. I can easily render text by using: CFontManager::Instance().renderWrappedText(font, lineLength, position, text); Unfortunately there is a situation in which this Button which displays text, is partly hidden because of resizing container in which it is situated. I'm able without any problem to draw Button's background to fit the container, but I've got a problem with doing the same with a text. Is it possible to somehow draw only text for given width and the rest just ignore? This is a screen which presents my problem: As you can see, the Button "Click here" is being drawn properly, but I can't do the same with "Click here" text.

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >